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 899a15f commit 77dd955
Show file tree
Hide file tree
Showing 9 changed files with 292 additions and 20 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/R-CMD-check-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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') != ''
Expand Down Expand Up @@ -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') != ''
Expand Down
198 changes: 193 additions & 5 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
# End custom: services

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: ./.github/workflows/rate-limit
with:
Expand All @@ -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

Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
# End custom: services

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ needs.rcc-smoke.outputs.sha }}

Expand Down Expand Up @@ -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 }}

Expand Down Expand Up @@ -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 }}

Expand All @@ -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}
28 changes: 28 additions & 0 deletions .github/workflows/install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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
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
4 changes: 2 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
# End custom: services

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: ./.github/workflows/rate-limit
with:
Expand All @@ -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
Loading

0 comments on commit 77dd955

Please sign in to comment.