Skip to content

Commit

Permalink
Update to workflows for 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbielby committed Dec 5, 2024
1 parent 4be9556 commit 6bb5c5f
Show file tree
Hide file tree
Showing 6 changed files with 360 additions and 391 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/automated-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
on:
push:
branches:
- main

pull_request:

name: Automated tests

jobs:
automatedTests:
runs-on: ubuntu-latest

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Install git2r dependencies
run: sudo apt-get install -y libgit2-dev

- name: Cache renv packages
id: cache-renv
uses: actions/cache@v4
with:
path: cache-renv
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-
- uses: r-lib/actions/setup-renv@v2

- name: Run tests
shell: Rscript {0}
run: |
shinytest2::test_app()
47 changes: 12 additions & 35 deletions .github/workflows/deploy-shiny.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,37 @@ on:
branches:
- main
- development
pull_request:

name: deploy-shiny

jobs:
deployShiny:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
# Running on mac as it's quicker to build
- {os: macOS-latest, r: 'release'}
runs-on: ubuntu-latest

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
RENV_PATHS_ROOT: ~/.local/share/renv
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
r-version: 4.2.1
r-version: 4.4.1
use-public-rspm: true

- name: Set env vars (dev)
if: endsWith(github.ref, '/development')
run: |
echo "SHINYAPP_NAME='dev-KS4-ready-reckoners'" >> $GITHUB_ENV
echo "SHINYAPP_NAME='dev-ks4-ready-reckoners'" >> $GITHUB_ENV
- name: Set env vars (prod)
if: endsWith(github.ref, '/main')
run: |
echo "SHINYAPP_NAME='KS4-ready-reckoners'">> $GITHUB_ENV
echo "SHINYAPP_NAME='ks4-ready-reckoners'">> $GITHUB_ENV
- 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: Install git2r dependencies
run: sudo apt-get install -y libgit2-dev

- name: Cache renv packages
uses: actions/cache@v1
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-
- name: Restore renv snapshot
shell: Rscript {0}
run: |
Expand All @@ -67,15 +44,15 @@ jobs:
shell: Rscript {0}
run: |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
renv::install("rsconnect@0.8.29")
renv::install("rsconnect")
# Tokens are stored as secrets in GitHub to make sure only DfE analysts can publish apps in our shiny.io area
# Navigate to Settings > Secrets to add and view secrets. These can also be things like admin login and passwords for SQL databases.
# Get in touch with the Stats Development team if you need to add the below secrets to publish to shinyapps.io

- name: Push to shiny.io
if: github.event_name != 'pull_request'
run: >
Rscript
-e "rsconnect::setAccountInfo(name = 'department-for-education', token = '${{secrets.SHINYAPPS_TOKEN}}', secret = '${{secrets.SHINYAPPS_SECRET}}')"
-e "rsconnect::deployApp(appName=${{env.SHINYAPP_NAME}})"
-e "rsconnect::deployApp(appName=${{env.SHINYAPP_NAME}}, forceUpdate = TRUE)"
59 changes: 59 additions & 0 deletions .github/workflows/lintr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '20 3 * * 0'

name: lintr

permissions:
contents: read

jobs:
lintr:
runs-on: ${{ matrix.config.os }}

name: Run lintr scanning

strategy:
fail-fast: false
matrix:
config:
# Running on mac as it's quicker to build
- {os: macOS-latest, r: 'release'}

permissions:
contents: read # for checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup R
uses: r-lib/actions/setup-r@4e1feaf90520ec1215d1882fdddfe3411c08e492
with:
r-version: 4.2.1
use-public-rspm: true

- name: restore renv
uses: r-lib/actions/setup-renv@v2

- name: Install lintr
shell: Rscript {0}
run: |
renv::install("lintr")
- name: Run lintr
run: lintr::sarif_output(lintr::lint_dir("."), "lintr-results.sarif")
shell: Rscript {0}
continue-on-error: true

- name: Upload analysis results to GitHub
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: lintr-results.sarif
wait-for-processing: true
64 changes: 0 additions & 64 deletions .github/workflows/shiny-tests.yaml

This file was deleted.

39 changes: 7 additions & 32 deletions .github/workflows/tidyCode.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,22 @@ name: tidyCode

jobs:
tidyCode:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
# Running on mac as it's quicker to build
- {os: macOS-latest, r: 'release'}
runs-on: ubuntu-latest

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
RENV_PATHS_ROOT: ~/.local/share/renv
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
r-version: 4.4.1
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: Install git2r dependencies
run: sudo apt-get install -y libgit2-dev

- name: Cache renv packages
uses: actions/cache@v1
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-
- name: Restore renv snapshot
shell: Rscript {0}
run: |
Expand All @@ -56,9 +33,7 @@ jobs:
- name: Tidy code
shell: Rscript {0}
run: |
source("global.R")
codeChecks <- tidy_code_function()
codeChecks <- dfeshiny::tidy_code()
if(any(is.na(codeChecks))) {
stop("There is a breaking error in the code.")
Expand Down
Loading

0 comments on commit 6bb5c5f

Please sign in to comment.