diff --git a/.github/workflows/R-CMD-check-dev.yaml b/.github/workflows/R-CMD-check-dev.yaml index 36aa93e..23c4a6b 100644 --- a/.github/workflows/R-CMD-check-dev.yaml +++ b/.github/workflows/R-CMD-check-dev.yaml @@ -13,14 +13,14 @@ name: rcc dev jobs: matrix: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 outputs: matrix: ${{ steps.set-matrix.outputs.matrix }} name: Collect deps steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ./.github/workflows/rate-limit with: @@ -63,7 +63,7 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ./.github/workflows/custom/before-install if: hashFiles('.github/workflows/custom/before-install/action.yml') != '' @@ -111,7 +111,7 @@ jobs: matrix: ${{fromJson(needs.matrix.outputs.matrix)}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ./.github/workflows/custom/before-install if: hashFiles('.github/workflows/custom/before-install/action.yml') != '' diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index e0cec84..dfe2dc8 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -34,7 +34,7 @@ jobs: # End custom: services steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ./.github/workflows/rate-limit with: @@ -49,7 +49,7 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} install-r: false - cache-version: rcc-smoke-1 + cache-version: rcc-smoke-2 needs: check extra-packages: any::rcmdcheck any::roxygen2 r-lib/styler @@ -86,7 +86,7 @@ jobs: # End custom: services steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ needs.rcc-smoke.outputs.sha }} @@ -141,7 +141,7 @@ jobs: - {os: windows-latest, r: '3.6'} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ needs.rcc-smoke.outputs.sha }} @@ -204,7 +204,7 @@ jobs: # End custom: matrix elements steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ needs.rcc-smoke.outputs.sha }} @@ -227,3 +227,191 @@ jobs: - uses: ./.github/workflows/check with: results: ${{ runner.os }}-r${{ matrix.config.r }} + + suggests-matrix: + runs-on: ubuntu-22.04 + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + + name: Collect suggests deps + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: ./.github/workflows/rate-limit + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - uses: r-lib/actions/setup-r@v2 + with: + install-r: false + use-public-rspm: true + + - id: set-matrix + uses: ./.github/workflows/dep-matrix-suggests + + check-matrix: + runs-on: ubuntu-22.04 + needs: suggests-matrix + + name: Check deps + + if: ${{ needs.matrix.outputs.matrix != '' }} + + steps: + - name: Install json2yaml + run: | + sudo npm install -g json2yaml + + - name: Check matrix definition + run: | + matrix='${{ needs.matrix.outputs.matrix }}' + echo $matrix + echo $matrix | jq . + echo $matrix | json2yaml + + rcc-suggests: + needs: + - suggests-matrix + - rcc-smoke + + runs-on: ubuntu-22.04 + + name: Without ${{ matrix.package }} + + if: ${{ needs.suggests-matrix.outputs.matrix != '' }} + + # Begin custom: services + # End custom: services + + strategy: + fail-fast: false + matrix: ${{fromJson(needs.suggests-matrix.outputs.matrix)}} + + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/workflows/custom/before-install + if: hashFiles('.github/workflows/custom/before-install/action.yml') != '' + + - uses: ./.github/workflows/install + with: + install-r: false + cache-version: rcc-dev-${{ matrix.package }}-1 + needs: check + extra-packages: "any::rcmdcheck any::remotes ." + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Remove ${{ matrix.package }} and all strong dependencies + run: | + pkg <- "${{ matrix.package }}" + pkgs <- tools::package_dependencies(pkg, reverse = TRUE)[[1]] + installed <- rownames(utils::installed.packages()) + to_remove <- c(pkg, intersect(pkgs, installed)) + print(to_remove) + remove.packages(to_remove) + shell: Rscript {0} + + - name: Session info + run: | + options(width = 100) + if (!requireNamespace("sessioninfo", quietly = TRUE)) install.packages("sessioninfo") + pkgs <- installed.packages()[, "Package"] + sessioninfo::session_info(pkgs, include_base = TRUE) + shell: Rscript {0} + + - uses: ./.github/workflows/custom/after-install + if: hashFiles('.github/workflows/custom/after-install/action.yml') != '' + + - name: Define _R_CHECK_FORCE_SUGGESTS_ + run: | + cat('_R_CHECK_FORCE_SUGGESTS_=false\n', file = Sys.getenv("GITHUB_ENV"), append = TRUE) + shell: Rscript {0} + + - name: Must allow NOTEs, even with _R_CHECK_FORCE_SUGGESTS_ + run: | + if (Sys.getenv("RCMDCHECK_ERROR_ON") %in% c("", "note")) { + cat('RCMDCHECK_ERROR_ON="warning"\n', file = Sys.getenv("GITHUB_ENV"), append = TRUE) + } + shell: Rscript {0} + + - name: Check env vars + run: | + print(Sys.getenv('_R_CHECK_FORCE_SUGGESTS_')) + print(Sys.getenv('RCMDCHECK_ERROR_ON')) + shell: Rscript {0} + + - uses: ./.github/workflows/check + with: + results: ${{ matrix.package }} + + # FIXME: integrate with dynamic matrix creation + validate: + needs: + - rcc-smoke + + runs-on: ${{ matrix.config.os }}${{ matrix.config.os-version }} + + name: ${{ matrix.config.os }}${{ matrix.config.os-version }} (${{ matrix.config.r }}) ${{ matrix.config.desc }} + + # Begin custom: services + # End custom: services + + strategy: + fail-fast: false + matrix: + config: + - { os: ubuntu-, os-version: 22.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest" } + + env: + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true + RSPM: ${{ matrix.config.rspm }} + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + # prevent rgl issues because no X11 display is available + RGL_USE_NULL: true + # Begin custom: env vars + # End custom: env vars + + steps: + - uses: actions/checkout@v4 + + - uses: ./.github/workflows/custom/before-install + if: hashFiles('.github/workflows/custom/before-install/action.yml') != '' + + - uses: ./.github/workflows/install + with: + token: ${{ secrets.GITHUB_TOKEN }} + install-r: false + cache-version: rcc-smoke-1 + needs: check + extra-packages: any::rcmdcheck any::roxygen2 r-lib/styler + + - uses: ./.github/workflows/custom/after-install + if: hashFiles('.github/workflows/custom/after-install/action.yml') != '' + + - name: Instrument R code for validation + run: | + if [ $(git status --porcelain | wc -l) -gt 0 ]; then + echo "Fatal: git working copy not clean" + fi + sed -i -r '/INSTRUMENT: validate/ s/^( +)# /\1/g' R/* + if [ $(git status --porcelain | wc -l) -eq 0 ]; then + echo "Fatal: substitution did not change anything" + fi + + - name: Run tests + run: | + testthat::test_local(reporter = testthat::ProgressReporter$new(max_failures = Inf, update_interval = Inf)) + shell: Rscript {0} + + - name: Show test output + if: always() + run: | + find check -name '*.Rout*' -exec head -n 1000000 '{}' \; || true + shell: bash + + - name: Test coverage + run: covr::codecov() + shell: Rscript {0} diff --git a/.github/workflows/dep-matrix-suggests/action.yml b/.github/workflows/dep-matrix-suggests/action.yml new file mode 100644 index 0000000..deafab9 --- /dev/null +++ b/.github/workflows/dep-matrix-suggests/action.yml @@ -0,0 +1,56 @@ +name: "Actions to compute a matrix with all suggested packages" +outputs: + matrix: + description: "Generated matrix" + value: ${{ steps.set-matrix.outputs.matrix }} + +runs: + using: "composite" + steps: + - id: set-matrix + run: | + get_deps <- function() { + # Determine package dependencies + if (!requireNamespace("desc", quietly = TRUE)) { + install.packages("desc") + } + + deps_df <- desc::desc_get_deps() + deps_df_optional <- deps_df$package[deps_df$type %in% c("Suggests", "Enhances")] + deps_df_hard <- deps_df$package[deps_df$type %in% c("Depends", "Imports", "LinkingTo")] + + packages <- sort(deps_df_optional) + packages <- intersect(packages, rownames(available.packages())) + + # Too big to fail, or can't be avoided: + off_limits <- c("testthat", "rmarkdown", "rcmdcheck", deps_df_hard) + off_limits_dep <- unlist(tools::package_dependencies(off_limits, recursive = TRUE, which = "strong")) + setdiff(packages, c(off_limits, off_limits_dep)) + } + + if (Sys.getenv("GITHUB_BASE_REF") != "") { + print(Sys.getenv("GITHUB_BASE_REF")) + has_diff <- (system("git diff ${{ github.event.pull_request.base.sha }}... | egrep '^[+][^+]' | grep -q ::") == 0) + if (has_diff) { + system("git diff ${{ github.event.pull_request.base.sha }}... | egrep '^[+][^+]' | grep -q ::") + packages <- get_deps() + } else { + writeLines("No changes using :: found, not checking without suggested packages") + packages <- character() + } + } else { + packages <- get_deps() + } + + if (length(packages) > 0) { + json <- paste0( + '{"package":[', + paste0('"', packages, '"', collapse = ","), + ']}' + ) + writeLines(json) + writeLines(paste0("matrix=", json), Sys.getenv("GITHUB_OUTPUT")) + } else { + writeLines("Package list empty!") + } + shell: Rscript {0} diff --git a/.github/workflows/install/action.yml b/.github/workflows/install/action.yml index bbd0001..896d69f 100644 --- a/.github/workflows/install/action.yml +++ b/.github/workflows/install/action.yml @@ -83,3 +83,31 @@ runs: sudo ln -s $(which true) /usr/local/bin/qpdf sudo ln -s $(which true) /usr/local/bin/checkbashisms shell: bash + + - name: Install ccache + uses: hendrikmuhs/ccache-action@v1.2.10 + with: + max-size: 10G + verbose: 1 + save: false + restore: false + + - name: Use ccache for compiling R code, and parallelize + run: | + mkdir -p ~/.R + echo 'CC := ccache $(CC)' >> ~/.R/Makevars + echo 'CXX := ccache $(CXX)' >> ~/.R/Makevars + echo 'CXX11 := ccache $(CXX11)' >> ~/.R/Makevars + echo 'CXX14 := ccache $(CXX14)' >> ~/.R/Makevars + echo 'CXX17 := ccache $(CXX17)' >> ~/.R/Makevars + echo 'MAKEFLAGS = -j2' >> ~/.R/Makevars + cat ~/.R/Makevars + + echo 'CCACHE_SLOPPINESS=locale,time_macros' | tee -a $GITHUB_ENV + + # echo 'CCACHE_DEBUG=true' | tee -a $GITHUB_ENV + # echo "CCACHE_DEBUGDIR=$(dirname $(pwd))/ccache-debug" | tee -a $GITHUB_ENV + # mkdir -p $(dirname $(pwd))/.ccache-debug + + echo 'PKG_BUILD_EXTRA_FLAGS=false' | tee -a $GITHUB_ENV + shell: bash diff --git a/.github/workflows/lock.yaml b/.github/workflows/lock.yaml index 9e33a1f..5b19556 100644 --- a/.github/workflows/lock.yaml +++ b/.github/workflows/lock.yaml @@ -8,7 +8,7 @@ jobs: lock: runs-on: ubuntu-latest steps: - - uses: dessant/lock-threads@v2 + - uses: dessant/lock-threads@v4 with: github-token: ${{ github.token }} issue-lock-inactive-days: "365" diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index ccd3b19..7400040 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -24,7 +24,7 @@ jobs: # End custom: services steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ./.github/workflows/rate-limit with: @@ -40,7 +40,7 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} install-r: false - cache-version: pkgdown-1 + cache-version: pkgdown-2 needs: website extra-packages: r-lib/pkgdown local::. diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml index 9ec2f17..3ce95aa 100644 --- a/.github/workflows/pr-commands.yaml +++ b/.github/workflows/pr-commands.yaml @@ -11,7 +11,7 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/pr-fetch@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} @@ -50,7 +50,7 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/pr-fetch@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} @@ -83,7 +83,7 @@ jobs: merge: if: startsWith(github.event.comment.body, '/merge') name: merge - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Create and merge pull request run: | @@ -98,6 +98,6 @@ jobs: # curl -s -X PUT --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" $PR_URL/merge # A mock job just to ensure we have a successful build status finish: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - run: true diff --git a/.github/workflows/revdep.yaml b/.github/workflows/revdep.yaml index f58f0b6..4a0d511 100644 --- a/.github/workflows/revdep.yaml +++ b/.github/workflows/revdep.yaml @@ -29,7 +29,7 @@ jobs: curl -s --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit shell: bash - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # FIXME: Avoid reissuing succesful jobs # https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-jobs-for-a-workflow-run @@ -91,7 +91,7 @@ jobs: curl -s --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/rate_limit shell: bash - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Begin custom: before install # End custom: before install diff --git a/.github/workflows/update-snapshots/action.yml b/.github/workflows/update-snapshots/action.yml index dd7bc90..2e1db0e 100644 --- a/.github/workflows/update-snapshots/action.yml +++ b/.github/workflows/update-snapshots/action.yml @@ -50,7 +50,7 @@ runs: if: ${{ steps.run-tests.outputs.changed }} id: check-changed run: | - echo "changed=$(git status --porcelain -- tests/testthat/_snaps)" >> $GITHUB_OUTPUT + echo "changed=$(git status --porcelain -- tests/testthat/_snaps | head -n 1)" >> $GITHUB_OUTPUT shell: bash - name: Derive branch name @@ -65,7 +65,7 @@ runs: - name: Create pull request if: ${{ steps.check-changed.outputs.changed }} id: cpr - uses: peter-evans/create-pull-request@v4 + uses: peter-evans/create-pull-request@v5 with: base: ${{ github.head_ref }} branch: snapshot-${{ github.ref_name }}-${{ github.job }}-${{ steps.matrix-desc.outputs.branch }}