Skip to content

Commit

Permalink
Merge branch 'krlmlr:main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
vgherard authored Oct 16, 2023
2 parents f7b376d + 2b837ba commit 6c6d340
Show file tree
Hide file tree
Showing 18 changed files with 388 additions and 59 deletions.
15 changes: 7 additions & 8 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@v2
- uses: actions/checkout@v4

- uses: ./.github/workflows/rate-limit
with:
Expand All @@ -34,7 +34,7 @@ jobs:
uses: ./.github/workflows/dep-matrix

check-matrix:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
needs: matrix

name: Check deps
Expand All @@ -52,7 +52,7 @@ jobs:
echo $matrix | json2yaml
R-CMD-check-base:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04

name: base

Expand All @@ -61,10 +61,9 @@ jobs:

strategy:
fail-fast: false
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}

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

- uses: ./.github/workflows/custom/before-install
if: hashFiles('.github/workflows/custom/before-install/action.yml') != ''
Expand Down Expand Up @@ -100,7 +99,7 @@ jobs:
- matrix
- R-CMD-check-base

runs-on: ubuntu-18.04
runs-on: ubuntu-22.04

name: ${{ matrix.package }}

Expand All @@ -112,7 +111,7 @@ jobs:
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}

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

- uses: ./.github/workflows/custom/before-install
if: hashFiles('.github/workflows/custom/before-install/action.yml') != ''
Expand Down
147 changes: 134 additions & 13 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
- cron: "10 0 * * *"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.sha }}-${{ github.base_ref || '' }}
cancel-in-progress: true

name: rcc
Expand All @@ -34,7 +34,7 @@ jobs:
# End custom: services

steps:
- uses: actions/checkout@v2
- 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@v2
- uses: actions/checkout@v4
with:
ref: ${{ needs.rcc-smoke.outputs.sha }}

Expand Down Expand Up @@ -137,10 +137,11 @@ jobs:
matrix:
config:
- {os: windows-latest, r: 'release'}
# Broken checks on R 3.6
# Use 3.6 to trigger usage of RTools35
- {os: windows-latest, r: '3.6'}

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

Expand Down Expand Up @@ -178,31 +179,32 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: macos-latest, r: 'release'}

- {os: ubuntu-20.04, r: 'release'}

# Use older ubuntu to maximise backward compatibility
- {os: ubuntu-18.04, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-18.04, r: 'release', covr: true, desc: 'with covr'}
- {os: ubuntu-18.04, r: 'oldrel-1'}
- {os: ubuntu-22.04, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-22.04, r: 'release', covr: true, desc: 'with covr'}
- {os: ubuntu-22.04, r: 'oldrel-1'}

# Begin custom: R 3.6
- {os: ubuntu-18.04, r: 'oldrel-2'}
- {os: ubuntu-22.04, r: 'oldrel-2'}
# End custom: R 3.6

# Begin custom: R 3.5
- {os: ubuntu-18.04, r: 'oldrel-3'}
- {os: ubuntu-22.04, r: 'oldrel-3'}
# End custom: R 3.5

# Begin custom: R 3.4
- {os: ubuntu-22.04, r: 'oldrel-4'}
# End custom: R 3.4

# Begin custom: matrix elements
# End custom: matrix elements

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

Expand All @@ -225,3 +227,122 @@ 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 }}
2 changes: 2 additions & 0 deletions .github/workflows/check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ runs:
steps:
- uses: r-lib/actions/check-r-package@v2
with:
# Fails on R 3.6 on Windows, remove when this job is removed?
args: 'c("--no-manual", "--as-cran", "--no-multiarch")'
error-on: ${{ env.RCMDCHECK_ERROR_ON || '"note"' }}

- name: Run coverage check
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/commit/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ runs:
git add .
git commit -m "Auto-update from GitHub Actions"$'\n'$'\n'"Run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
git push -u origin HEAD
echo ::set-output name=sha::$(git rev-parse HEAD)
echo sha=$(git rev-parse HEAD) >> $GITHUB_OUTPUT
fi
shell: bash
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/dep-matrix/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,5 @@ runs:
']}'
)
writeLines(json)
writeLines(paste0("::set-output name=matrix::", json))
writeLines(paste0("matrix=", json), Sys.getenv("GITHUB_OUTPUT"))
shell: Rscript {0}
Loading

0 comments on commit 6c6d340

Please sign in to comment.