From 72e86a4ffcc4cf0ddd3aedd543bd0d8fea9806de Mon Sep 17 00:00:00 2001 From: Henrik Bengtsson Date: Mon, 30 Dec 2024 14:57:55 -0800 Subject: [PATCH] GHA: modernize --- .github/workflows/R-CMD-check.yaml | 6 +- .github/workflows/covr.yaml | 82 ---------------------------- .github/workflows/test-coverage.yaml | 56 +++++++++++++++++++ 3 files changed, 59 insertions(+), 85 deletions(-) delete mode 100644 .github/workflows/covr.yaml create mode 100644 .github/workflows/test-coverage.yaml diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 9261083..bb26c13 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -27,7 +27,7 @@ jobs: - {os: ubuntu-latest, r: 'oldrel' } - {os: ubuntu-latest, r: 'oldrel-1' } - {os: ubuntu-latest, r: 'oldrel-2' } - - {os: ubuntu-latest, r: '3.4' } + - {os: ubuntu-latest, r: '4.0' } - {os: windows-latest, r: 'release' , prune_functions: true, label: 'prune' } - {os: macOS-latest, r: 'release' , prune_functions: true, label: 'prune' } - {os: ubuntu-latest, r: 'devel' , prune_functions: true, label: 'prune' } @@ -50,7 +50,7 @@ jobs: R_FUTURE_GLOBALS_KEEPWHERE: ${{ matrix.config.globals_keepWhere }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-pandoc@v2 @@ -104,7 +104,7 @@ jobs: - name: Upload check results if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ runner.os }}-r${{ matrix.config.r }}-results path: check diff --git a/.github/workflows/covr.yaml b/.github/workflows/covr.yaml deleted file mode 100644 index 298fa54..0000000 --- a/.github/workflows/covr.yaml +++ /dev/null @@ -1,82 +0,0 @@ -on: [push] - -name: covr - -jobs: - covr: - if: "! contains(github.event.head_commit.message, '[ci skip]')" - - timeout-minutes: 30 - - runs-on: ubuntu-latest - - name: covr - - strategy: - fail-fast: false - - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - RSPM: https://packagemanager.rstudio.com/cran/__linux__/jammy/latest - R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - ## R CMD check - _R_CHECK_LENGTH_1_CONDITION_: true - _R_CHECK_LENGTH_1_LOGIC2_: true - _R_CHECK_MATRIX_DATA_: true - _R_CHECK_CRAN_INCOMING_: false - - steps: - - uses: actions/checkout@v3 - - - uses: r-lib/actions/setup-pandoc@v2 - - - uses: r-lib/actions/setup-r@v2 - with: - r-version: release - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - uses: actions/cache@v3 - 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 system dependencies - env: - RHUB_PLATFORM: linux-x86_64-ubuntu-gcc - run: | - Rscript -e "remotes::install_github('r-hub/sysreqs')" - sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))") - sudo -s eval "$sysreqs" - - - name: Install dependencies - run: | - install.packages(c("covr", "sessioninfo")) - remotes::install_deps(dependencies = TRUE) - install.packages(".", repos=NULL, type="source") - shell: Rscript {0} - - - name: Session info - run: | - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript {0} - - - name: Test coverage - run: | - ## 1. Get 'Repository Upload Token' from Codecov: - ## https://app.codecov.io/gh///settings - ## 2. Set 'CODECOV_TOKEN' in GitHub Secrets: - ## https://github.com///settings/environments/ - coverage <- covr::package_coverage() - print(coverage) - covr::codecov(coverage = coverage, token="${{secrets.CODECOV_TOKEN}}") - shell: Rscript {0} diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..cd2c74a --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,56 @@ +on: [push] + +name: test-coverage.yaml + +permissions: read-all + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + + - name: Assert CODECOV_TOKEN is set + run: | + if [[ -z "${{secrets.CODECOV_TOKEN}}" ]]; then + >&2 echo "::error::ERROR: 'secrets.CODECOV_TOKEN' not set" + exit 1 + fi + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr, any::xml2 + needs: coverage + + - name: Test coverage + run: | + cov <- covr::package_coverage( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + print(cov) + 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: Upload test results + if: failure() + uses: actions/upload-artifact@v4 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package