Skip to content

ci: Permissions, better tests for missing suggests, lints #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:

permissions:
contents: write
statuses: write

# Begin custom: services
# End custom: services
Expand Down Expand Up @@ -265,6 +266,18 @@ jobs:
- uses: ./.github/workflows/custom/after-install
if: hashFiles('.github/workflows/custom/after-install/action.yml') != ''

- name: Must allow NOTEs if packages are missing, even with _R_CHECK_FORCE_SUGGESTS_
run: |
if (Sys.getenv("RCMDCHECK_ERROR_ON") %in% c("", "note")) {
pkgs <- setdiff(desc::desc_get_deps()$package, "R")
installable <- vapply(pkgs, FUN.VALUE = logical(1), requireNamespace, quietly = TRUE)
if (any(!installable)) {
message("Missing packages: ", paste(pkgs[!installable], collapse = ", "))
cat('RCMDCHECK_ERROR_ON="warning"\n', file = Sys.getenv("GITHUB_ENV"), append = TRUE)
}
}
shell: Rscript {0}

- uses: ./.github/workflows/update-snapshots
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository

Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/dep-suggests-matrix/action.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,25 @@ if (Sys.getenv("GITHUB_BASE_REF") != "") {
# Use .. to avoid having to fetch the entire history
# https://github.com/krlmlr/actions-sync/issues/45
diff_cmd <- "git diff origin/${GITHUB_BASE_REF}.. -- R/ tests/ | egrep '^[+][^+]' | grep -q ::"
has_diff <- (system(diff_cmd) == 0)
if (has_diff) {
writeLines(system(diff_cmd, intern = TRUE))
diff_lines <- system(diff_cmd, intern = TRUE)
if (length(diff_lines) > 0) {
writeLines("Changes using :: in R/ or tests/:")
writeLines(diff_lines)
packages <- get_deps()
} else {
writeLines("No changes using :: found, not checking without suggested packages")
writeLines("No changes using :: found in R/ or tests/, not checking without suggested packages")
packages <- character()
}
} else {
writeLines("No GITHUB_BASE_REF, checking without suggested packages")
packages <- get_deps()
}

if (length(packages) > 0) {
json <- paste0(
'{"package":[',
paste0('"', packages, '"', collapse = ","),
']}'
"]}"
)
writeLines(paste0("matrix=", json), Sys.getenv("GITHUB_OUTPUT"))
writeLines(json)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/versions-matrix/action.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (file.exists(".github/versions-matrix.R")) {

print(include_list)

filter <- read.dcf("DESCRIPTION")[1,]["Config/gha/filter"]
filter <- read.dcf("DESCRIPTION")[1, ]["Config/gha/filter"]
if (!is.na(filter)) {
filter_expr <- parse(text = filter)[[1]]
subset_fun_expr <- bquote(function(x) subset(x, .(filter_expr)))
Expand All @@ -57,7 +57,7 @@ to_json <- function(x) {
}

configs <- unlist(lapply(include_list, to_json))
json <- paste0('{"include":[', paste(configs, collapse = ","), ']}')
json <- paste0('{"include":[', paste(configs, collapse = ","), "]}")

if (Sys.getenv("GITHUB_OUTPUT") != "") {
writeLines(paste0("matrix=", json), Sys.getenv("GITHUB_OUTPUT"))
Expand Down