Skip to content

Commit

Permalink
GHA: modernize
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Feb 9, 2025
1 parent 3fdf6bc commit 8524a43
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 35 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
- {os: ubuntu-latest, r: 'release' , language: ko, label: ko }
- {os: ubuntu-latest, r: 'release' , globals_keepWhere: true, label: 'keepWhere' }
- {os: ubuntu-latest, r: 'release' , globals_keepWhere: false, label: '!keepWhere' }
- {os: ubuntu-latest, r: 'release', future_version: develop, label: 'w/ future-develop' }
- {os: ubuntu-latest, r: 'release', future_version: feature/evalFuture-3, label: 'w/ future-feature/evalFuture-3' }

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -48,6 +50,7 @@ jobs:
## Specific to futures
R_FUTURE_RNG_ONMISUSE: error
R_FUTURE_GLOBALS_KEEPWHERE: ${{ matrix.config.globals_keepWhere }}
R_FUTURE_VERSION: ${{ matrix.config.future_version }}

steps:
- uses: actions/checkout@v4
Expand All @@ -70,6 +73,15 @@ jobs:
install.packages(".", repos = NULL, type = "source") ## needed by parallel workers
shell: Rscript {0}

- name: Test with specific future version?
run: |
future_version <- Sys.getenv("R_FUTURE_VERSION")
if (nzchar(future_version)) {
install.packages("remotes")
remotes::install_github("futureverse/future", ref=future_version)
}
shell: Rscript {0}

- name: Session info
run: |
options(width = 100)
Expand Down
85 changes: 50 additions & 35 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,56 +1,71 @@
on: [push]

name: test-coverage.yaml

permissions: read-all
name: covr

jobs:
test-coverage:
covr:
if: "! contains(github.event.head_commit.message, '[ci skip]')"

timeout-minutes: 45

runs-on: ubuntu-latest

name: covr

strategy:
fail-fast: false

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
## Test in other locale (optional)
LANGUAGE: ${{ matrix.config.language }}
## R CMD check
_R_CHECK_CRAN_INCOMING_: false
_R_CHECK_MATRIX_DATA_: true
_R_CHECK_SUGGESTS_ONLY_: true
_R_CHECK_THINGS_IN_TEMP_DIR_: true
RCMDCHECK_ERROR_ON: note
## Specific to futures
R_FUTURE_RNG_ONMISUSE: error

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
extra-packages: |
any::rcmdcheck
any::remotes
any::sessioninfo
any::covr
needs: check

- name: Test coverage
- name: Install dependencies
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)
remotes::install_deps(dependencies = TRUE)
install.packages(".", repos=NULL, type="source")
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
- 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/<org>/<repo>/settings
## 2. Set 'CODECOV_TOKEN' in GitHub Secrets:
## https://github.com/<org>/<repo>/settings/environments/
coverage <- covr::package_coverage(quiet = FALSE)
print(coverage)
covr::codecov(coverage = coverage, token="${{secrets.CODECOV_TOKEN}}")
shell: Rscript {0}

0 comments on commit 8524a43

Please sign in to comment.