Skip to content

Workflow scripting updates #367

Workflow scripting updates

Workflow scripting updates #367

Workflow file for this run

on:
push:
branches:
- main
pull_request:
name: tidyCode
jobs:
tidyCode:
runs-on: ${{ matrix.config.os }}
name: tidyCode
strategy:
fail-fast: false
matrix:
config:
# Running on mac as it's quicker to build
- {os: macOS-latest, r: 'release'}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
RENV_PATHS_ROOT: ~/.local/share/renv
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v1
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
- name: Restore renv snapshot
shell: Rscript {0}
run: |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
renv::restore()
- name: Tidy code
shell: Rscript {0}
run: |
source("global.R")
codeChecks <- tidy_code()
if(any(is.na(codeChecks))) {
stop("There is a breaking error in the code.")
} else {
if(TRUE %in% codeChecks) {
stop("The code is not styled correctly. Open the project in RStudio and use tidy_code() to restyle the code.")
} else {
message("----------------------------------------")
message("The code is beautiful, go you!")
message("----------------------------------------")
}
}
- name: Upload test results
if: failure()
uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-tests
path: tests