diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..494738c --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,56 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + +name: lint.yaml + +permissions: read-all + +jobs: + lint: + 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: Install proj library (terra depdencies) + run: sudo apt-get install libproj-dev + + - name: Install gdal library (terra dependencies) + run: sudo apt-get install libgdal-dev + + - name: Install udunits library (units dependencies) + run: sudo apt-get install libudunits2-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: Restore renv snapshot + shell: Rscript {0} + run: | + if (!requireNamespace("lintr", quietly = TRUE)) install.packages("lintr") + + - name: Lint + run: lintr::lint_dir() + shell: Rscript {0} + env: + LINTR_ERROR_ON_LINT: true diff --git a/.github/workflows/lintr.yml b/.github/workflows/lintr.yml deleted file mode 100644 index 6edc13a..0000000 --- a/.github/workflows/lintr.yml +++ /dev/null @@ -1,53 +0,0 @@ -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: ubuntu-latest - - permissions: - contents: read # for checkout to fetch code - security-events: write # for github/codeql-action/upload-sarif to upload SARIF results - - container: - image: ghcr.io/dfe-analytical-services/dfe-r-base:latest - options: --user root - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v4 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - name: Restore renv snapshot - shell: Rscript {0} - run: | - if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv") - renv::restore() - 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 diff --git a/.github/workflows/tidyCode.yaml b/.github/workflows/tidyCode.yaml index 3753f17..8efe224 100644 --- a/.github/workflows/tidyCode.yaml +++ b/.github/workflows/tidyCode.yaml @@ -32,9 +32,8 @@ jobs: - name: Tidy code shell: Rscript {0} run: | - source("global.R") - - codeChecks <- tidy_code() + + codeChecks <- dfeshiny::tidy_code() if(any(is.na(codeChecks))) { stop("There is a breaking error in the code.")