Add Yale Ventures Non-Commercial License #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: pre-commit | |
on: | |
push: | |
branches-ignore: | |
- 'master' | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/cancel-workflow-action@0.6.0 | |
with: | |
access_token: ${{ github.token }} | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Set up environment | |
run: | | |
echo "UBUNTU_VERSION=`grep DISTRIB_RELEASE /etc/lsb-release | sed 's/.*=//g'`" >> $GITHUB_ENV | |
mkdir -p .local/R/site-packages | |
echo "R_LIBS_USER=`pwd`/.local/R/site-packages" >> $GITHUB_ENV | |
- name: Install system dependencies | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get update -qq | |
sudo apt-get install -y libcurl4-openssl-dev | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.8" | |
architecture: "x64" | |
- name: Cache pre-commit | |
uses: actions/cache@v2 | |
with: | |
path: ~/.cache/pre-commit | |
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}- | |
- name: Run pre-commit | |
uses: pre-commit/action@v2.0.0 | |
- name: Cache R packages | |
uses: actions/cache@v2 | |
if: startsWith(runner.os, 'Linux') | |
with: | |
path: ${{env.R_LIBS_USER}} | |
key: precommit-${{env.UBUNTU_VERSION}}-renv-${{ hashFiles('Rmagic/.pre-commit.r_requirements.txt') }}-${{ hashFiles('Rmagic/DESCRIPTION') }}- | |
restore-keys: | | |
precommit-${{env.UBUNTU_VERSION}}-renv-${{ hashFiles('Rmagic/.pre-commit.r_requirements.txt') }}- | |
precommit-${{env.UBUNTU_VERSION}}-renv- | |
- name: Install R packages | |
run: | | |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv") | |
con = file("Rmagic/.pre-commit.r_requirements.txt", "r") | |
while ( length(pkg <- readLines(con, n = 1)) > 0 ) { | |
renv::install(pkg) | |
} | |
close(con) | |
if (!require("devtools")) install.packages("devtools", repos="http://cloud.r-project.org") | |
devtools::install_dev_deps("./Rmagic", upgrade=TRUE) | |
devtools::install("./Rmagic") | |
shell: Rscript {0} | |
- name: Run pre-commit for R | |
run: | | |
cd Rmagic | |
git init | |
git add * | |
pre-commit run --all-files | |
rm -rf .git | |
cd .. | |
- name: Commit files | |
if: failure() | |
run: | | |
git checkout -- .github/workflows | |
if [[ `git status --porcelain --untracked-files=no` ]]; then | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git commit -m "pre-commit" -a | |
fi | |
- name: Push changes | |
if: failure() | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} |