From e075d702fcfe593a32abd991b08d65de7d160b93 Mon Sep 17 00:00:00 2001 From: aleksanderbl29 <73799306+aleksanderbl29@users.noreply.github.com> Date: Tue, 26 Nov 2024 10:51:23 +0100 Subject: [PATCH 1/3] Update actions and lintr --- .github/workflows/R-CMD-check.yaml | 54 +++++++++---------- .github/workflows/document.yaml | 60 +++++++++++++++++++++ .github/workflows/lint.yaml | 33 ++++++++++++ .github/workflows/render-readme.yaml | 50 ----------------- .github/workflows/rogtemplate-gh-pages.yaml | 11 ++-- .github/workflows/test-coverage.yaml | 53 ++++++++++++++---- .lintr | 2 + 7 files changed, 170 insertions(+), 93 deletions(-) create mode 100644 .github/workflows/document.yaml create mode 100644 .github/workflows/lint.yaml delete mode 100644 .github/workflows/render-readme.yaml create mode 100644 .lintr diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 4dd5961..60ef06e 100755 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,17 +1,17 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# 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 + branches: main pull_request: - branches: - - main - - master + workflow_dispatch: + schedule: + - cron: "30 17 * * 6" name: R-CMD-check +permissions: read-all + jobs: R-CMD-check: runs-on: ${{ matrix.config.os }} @@ -19,44 +19,42 @@ jobs: name: ${{ matrix.config.os }} (${{ matrix.config.r }}) strategy: + # fail-fast: true fail-fast: false matrix: config: + - {os: macos-latest, r: 'release'} - {os: windows-latest, r: 'release'} - - {os: macOS-latest, r: 'release'} - - {os: ubuntu-20.04, r: 'devel', http-user-agent: 'release'} - - {os: ubuntu-20.04, r: 'release'} - - {os: ubuntu-20.04, r: 'oldrel-1'} + - {os: ubuntu-22.04, r: 'release'} + - {os: ubuntu-24.04, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-24.04, r: 'release'} + - {os: ubuntu-24.04, r: 'oldrel-1'} + env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - uses: r-lib/actions/setup-pandoc@master + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@master + - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} http-user-agent: ${{ matrix.config.http-user-agent }} use-public-rspm: true - - uses: r-lib/actions/setup-r-dependencies@master + - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: rcmdcheck - - - uses: r-lib/actions/check-r-package@master - - - name: Show testthat output - if: always() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash + cache-version: 3 + extra-packages: | + any::rcmdcheck + needs: | + check - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main + - uses: r-lib/actions/check-r-package@v2 with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check \ No newline at end of file + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/document.yaml b/.github/workflows/document.yaml new file mode 100644 index 0000000..ebaed78 --- /dev/null +++ b/.github/workflows/document.yaml @@ -0,0 +1,60 @@ +# 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: + paths: + - "R/**" + - "README.Rmd" + - '.github/workflows/document.yaml' + workflow_dispatch: + +name: document.yaml + +permissions: read-all + +jobs: + document: + runs-on: ubuntu-24.04 + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup R + uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + r-version: 'renv' + + - name: Install dependencies + uses: r-lib/actions/setup-r-dependencies@v2 + with: + cache-version: 2 + extra-packages: | + any::roxygen2 + any::devtools + needs: | + roxygen2 + devtools + + - name: Document + run: roxygen2::roxygenise() + shell: Rscript {0} + + - name: Build readme + run: devtools::build_readme() + shell: Rscript {0} + + - name: Commit and push changes + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add man/\* NAMESPACE DESCRIPTION + git commit -m "(Github Actions): Update documentation" || echo "No changes to commit" + git pull --ff-only + git push origin diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..d75b6c5 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,33 @@ +# 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: + pull_request: + +name: lint.yaml + +permissions: read-all + +jobs: + lint: + runs-on: ubuntu-24.04 + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + r-version: 'renv' + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + cache-version: 2 + extra-packages: any::lintr, local::. + needs: lint + + - name: Lint + run: lintr::lint_package() + shell: Rscript {0} + env: + LINTR_ERROR_ON_LINT: true diff --git a/.github/workflows/render-readme.yaml b/.github/workflows/render-readme.yaml deleted file mode 100644 index c485205..0000000 --- a/.github/workflows/render-readme.yaml +++ /dev/null @@ -1,50 +0,0 @@ -# Workflow derived from https://github.com/r-lib/actions/blob/master/.github/workflows/render-readme.yaml -# and https://fromthebottomoftheheap.net/2020/04/30/rendering-your-readme-with-github-actions/ -# Workflow triggering derived from: https://stevenmortimer.com/running-github-actions-sequentially/ -on: - workflow_dispatch: - push: - paths: - - 'README.Rmd' - -name: Render README - -jobs: - render: - name: Render README - runs-on: macOS-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-pandoc@master - - - uses: r-lib/actions/setup-r@master - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@master - with: - extra-packages: | - rmarkdown - - needs: website - - name: Render README - run: Rscript -e 'rmarkdown::render("README.Rmd")' - - - name: Commit results - run: | - git config --local user.email "actions@github.com" - git config --local user.name "GitHub Actions" - git commit README.md -m 'Re-build README.Rmd' || echo "No changes to commit" - git push origin || echo "No changes to commit" - - - name: Trigger pkgdown workflow - if: success() - uses: peter-evans/repository-dispatch@v1 - with: - token: ${{ secrets.REPO_GHA_PAT }} - repository: ${{ github.repository }} - event-type: trigger-pkgdown-workflow - client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}' diff --git a/.github/workflows/rogtemplate-gh-pages.yaml b/.github/workflows/rogtemplate-gh-pages.yaml index 7d69b7d..5db6315 100644 --- a/.github/workflows/rogtemplate-gh-pages.yaml +++ b/.github/workflows/rogtemplate-gh-pages.yaml @@ -4,7 +4,7 @@ on: push: branches: [main, master] tags: ['*'] - paths-ignore: + paths-ignore: - 'README.Rmd' repository_dispatch: types: [trigger-pkgdown-workflow] @@ -18,15 +18,16 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - uses: r-lib/actions/setup-pandoc@v1 + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 with: use-public-rspm: true + r-version: 'renv' - - uses: r-lib/actions/setup-r-dependencies@v1 + - uses: r-lib/actions/setup-r-dependencies@v2 with: extra-packages: | magick diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 3c0da1c..b061aef 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -1,30 +1,63 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# 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] + branches: main pull_request: - branches: [main, master] -name: test-coverage +name: test-coverage.yaml + +permissions: read-all jobs: test-coverage: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 + # runs-on: macos-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 with: use-public-rspm: true + r-version: 'renv' - - uses: r-lib/actions/setup-r-dependencies@v1 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: covr + cache-version: 2 + extra-packages: any::covr, any::xml2 + needs: coverage - name: Test coverage - run: covr::codecov() + run: | + cov <- covr::package_coverage( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + covr::to_cobertura(cov) shell: Rscript {0} + + - uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }} + file: ./cobertura.xml + plugin: noop + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Show testthat output + if: always() + run: | + ## -------------------------------------------------------------------- + find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v4 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/.lintr b/.lintr new file mode 100644 index 0000000..3d4eb22 --- /dev/null +++ b/.lintr @@ -0,0 +1,2 @@ +linters: linters_with_defaults() # see vignette("lintr") +encoding: "UTF-8" From 206825b1b68c8f9a523cfd1941b6f25bf858078e Mon Sep 17 00:00:00 2001 From: aleksanderbl29 <73799306+aleksanderbl29@users.noreply.github.com> Date: Tue, 26 Nov 2024 11:27:31 +0100 Subject: [PATCH 2/3] Add dependabot for github actions --- .github/dependabot.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5ace460 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" From fd82f6440e9bc1e8bdb9ed18ae73718cac07189f Mon Sep 17 00:00:00 2001 From: aleksanderbl29 <73799306+aleksanderbl29@users.noreply.github.com> Date: Tue, 26 Nov 2024 11:28:44 +0100 Subject: [PATCH 3/3] Fail fast on check --- .github/workflows/R-CMD-check.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 60ef06e..bcdf126 100755 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -19,8 +19,7 @@ jobs: name: ${{ matrix.config.os }} (${{ matrix.config.r }}) strategy: - # fail-fast: true - fail-fast: false + fail-fast: true matrix: config: - {os: macos-latest, r: 'release'}