Add an R port of the terminology encoder #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Checks for the R package in `r/`. | |
| # | |
| # Derived from https://github.com/r-lib/actions/tree/v2/examples. Every action | |
| # that touches the package is pointed at the `r/` subdirectory through its | |
| # `working-directory` input, because the repository root holds the Python | |
| # package rather than an R package. | |
| # | |
| # Live terminology server access: the unit suite answers every request from | |
| # canned fixtures, so it needs no network. The one exception is | |
| # `r/tests/testthat/test-integration.R`, which runs the README example against | |
| # the CSIRO public Ontoserver. It skips here for two independent reasons: | |
| # | |
| # 1. `skip_on_cran()` skips unless `NOT_CRAN` is set. Neither `R CMD check` nor | |
| # covr sets it, so both jobs below skip the test on that ground alone. | |
| # 2. It also skips whenever `CI` is set, which GitHub Actions always sets. This | |
| # covers anyone who later adds a job running `devtools::test()` or | |
| # `testthat::test_local()`, both of which do set `NOT_CRAN`. | |
| # | |
| # A terminology server outage or a content change on the server therefore | |
| # cannot fail this workflow. The live check runs locally, where `CI` is unset | |
| # and `devtools::test()` sets `NOT_CRAN`. | |
| name: R check | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| permissions: read-all | |
| jobs: | |
| check: | |
| runs-on: ${{ matrix.os }} | |
| name: R CMD check (${{ matrix.os }}) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| env: | |
| GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
| R_KEEP_PKG_SOURCE: yes | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: r-lib/actions/setup-r@v2 | |
| with: | |
| r-version: release | |
| use-public-rspm: true | |
| - uses: r-lib/actions/setup-r-dependencies@v2 | |
| with: | |
| working-directory: r | |
| extra-packages: any::rcmdcheck | |
| needs: check | |
| - uses: r-lib/actions/check-r-package@v2 | |
| with: | |
| working-directory: r | |
| upload-snapshots: true | |
| coverage: | |
| runs-on: ubuntu-latest | |
| name: Coverage | |
| env: | |
| GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: r-lib/actions/setup-r@v2 | |
| with: | |
| use-public-rspm: true | |
| - uses: r-lib/actions/setup-r-dependencies@v2 | |
| with: | |
| working-directory: r | |
| extra-packages: any::covr | |
| needs: coverage | |
| # Results are printed to the job log. There is no external coverage | |
| # service; read the per-file table in the step output. | |
| # | |
| # `covr::zero_coverage()` is deliberately avoided: it calls | |
| # `rstudioapi::isAvailable()` to decide whether to open the source marker | |
| # pane, and rstudioapi is not installed on the runner. | |
| - name: Report coverage | |
| run: | | |
| coverage <- covr::package_coverage("r", quiet = FALSE) | |
| print(coverage) | |
| tally <- covr::tally_coverage(coverage) | |
| uncovered <- tally[tally$value == 0, c("filename", "line")] | |
| if (nrow(uncovered) > 0) { | |
| print(uncovered) | |
| stop(sprintf("%d uncovered line(s)", nrow(uncovered))) | |
| } | |
| message("All lines covered.") | |
| shell: Rscript {0} |