From e518d8f0f095e25ce714d06ff5c0f9dfce833a75 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Sun, 14 Jul 2024 16:48:34 +0200 Subject: [PATCH] legacy compatibility is no longer explicitly tested, people who udpate the R package should also update the hook revision. This is explicitly required for new issues. --- .github/workflows/hook-tests-legacy.yml | 102 ------------------------ vignettes/testing.Rmd | 14 ---- 2 files changed, 116 deletions(-) delete mode 100644 .github/workflows/hook-tests-legacy.yml diff --git a/.github/workflows/hook-tests-legacy.yml b/.github/workflows/hook-tests-legacy.yml deleted file mode 100644 index 61871542e..000000000 --- a/.github/workflows/hook-tests-legacy.yml +++ /dev/null @@ -1,102 +0,0 @@ -on: - pull_request: - branches: - - '*' - - -name: Legacy hook tests -jobs: - hook-test: - runs-on: ${{ matrix.config.os }} - - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - - strategy: - fail-fast: false - matrix: - config: - - {os: macOS-latest, r: 'release'} - - {os: windows-latest, r: 'release'} - - {os: ubuntu-latest, r: 'release', use-public-rspm: true} - env: - RSPM: ${{ matrix.config.rspm }} - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v4 - - uses: r-lib/actions/setup-r@v2 - with: - r-version: ${{ matrix.config.r }} - - name: checkout old hook scripts - run: | - git fetch origin refs/tags/v0.1.3:refs/tags/v0.1.3 - git checkout v0.1.3 -- inst/bin - git checkout v0.1.3 -- tests/testthat/test-all.R - git checkout v0.1.3 -- R/testing.R - - name: Query dependencies - run: | - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - name: Cache R packages (macOs) - if: startsWith(runner.os, 'macOS') - uses: actions/cache@v4 - with: - path: ~/Library/Application Support/renv - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('renv.lock') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - name: Cache R packages (Linux) - if: startsWith(runner.os, 'Linux') - uses: actions/cache@v4 - with: - path: ~/.local/share/renv - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('renv.lock') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - name: Cache R packages (Windows) - if: startsWith(runner.os, 'Windows') - uses: actions/cache@v4 - with: - path: ~\AppData\Local\renv - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('renv.lock') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- - - uses: r-lib/actions/setup-r-dependencies@v2 - - name: Perpare testing environment - run: | - # testing dependencies (incl. {precommit}) live in global R library, - # hook dependencies in renv, which is only activated when child R - # process is invoked, e.g. as in run_test() - if (!requireNamespace("renv", quietly = TRUE)) { - install.packages("renv", repos = c(CRAN = "https://cloud.r-project.org")) - } - # avoid build-time deps - options(install.packages.compile.from.source = "never") - renv::install(c('testthat', 'devtools', 'desc', 'git2r')) - renv::install(desc::desc_get_deps()$package) # install all deps - renv::install(getwd()) - shell: Rscript {0} - - name: Session info (testing environment) - run: | - renv::install('sessioninfo', repos = 'cloud.r-project.org') - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript {0} - - name: Test - run: | - devtools::load_all() - testthat::test_file( - "tests/testthat/test-all.R", - reporter = testthat::MultiReporter$new(list( - testthat::CheckReporter$new(), testthat::FailReporter$new() - )) - ) - shell: Rscript {0} - - name: Show testthat output - if: always() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main - with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check diff --git a/vignettes/testing.Rmd b/vignettes/testing.Rmd index e34fd840a..1aa82416b 100644 --- a/vignettes/testing.Rmd +++ b/vignettes/testing.Rmd @@ -35,20 +35,6 @@ This package has five testing workflows: `run_test()` and check in the user R profile if it is set, and then activate the renv. This is done with `R_PRECOMMIT_HOOK_ENV`. -- Legacy hook testing: It is possible that someone updates the R - package {precommit}, but not the hook revision (e.g. with - `precommit::autoupdate()`) or vice versa. If the hook revision is - updated to `>= 0.2.0`, all hook scripts and {precommit} functions - called from the hook script are from the same version of - {precommit}, so we don't need to test hook compatibility. If the R - package is updated but not the hook revision, old hook scripts are - called with while the {precommit} functions in them are from a new - package version. Hence, we need compatibility between new packages - and old hook scripts, which is exactly what is tested with this - workflow. Until there are breaking changes in the *hook script - helpers* family of exported functions, there should not be a - problem. - - complete testing: Tests hooks as well as usethis like access functionality with latest CRAN packages, on all platforms, with all installation methods.