Skip to content

Commit

Permalink
Renovate, check without suggested packages, parallel and ccache
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Oct 8, 2023
1 parent b231595 commit 758a208
Show file tree
Hide file tree
Showing 7 changed files with 252 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ name: rcc dev

jobs:
matrix:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

Expand Down
190 changes: 189 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,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

Expand Down Expand Up @@ -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}
56 changes: 56 additions & 0 deletions .github/workflows/dep-matrix-suggests/action.yml
Original file line number Diff line number Diff line change
@@ -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}
2 changes: 1 addition & 1 deletion .github/workflows/lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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::.

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/update-snapshots/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand Down

0 comments on commit 758a208

Please sign in to comment.