Skip to content

Commit 2f7f58b

Browse files
authored
ci: Permissions, better tests for missing suggests, lints (#52)
1 parent c6eff9c commit 2f7f58b

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

.github/workflows/R-CMD-check.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454

5555
permissions:
5656
contents: write
57+
statuses: write
5758

5859
# Begin custom: services
5960
# End custom: services
@@ -265,6 +266,18 @@ jobs:
265266
- uses: ./.github/workflows/custom/after-install
266267
if: hashFiles('.github/workflows/custom/after-install/action.yml') != ''
267268

269+
- name: Must allow NOTEs if packages are missing, even with _R_CHECK_FORCE_SUGGESTS_
270+
run: |
271+
if (Sys.getenv("RCMDCHECK_ERROR_ON") %in% c("", "note")) {
272+
pkgs <- setdiff(desc::desc_get_deps()$package, "R")
273+
installable <- vapply(pkgs, FUN.VALUE = logical(1), requireNamespace, quietly = TRUE)
274+
if (any(!installable)) {
275+
message("Missing packages: ", paste(pkgs[!installable], collapse = ", "))
276+
cat('RCMDCHECK_ERROR_ON="warning"\n', file = Sys.getenv("GITHUB_ENV"), append = TRUE)
277+
}
278+
}
279+
shell: Rscript {0}
280+
268281
- uses: ./.github/workflows/update-snapshots
269282
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
270283

.github/workflows/dep-suggests-matrix/action.R

+7-5
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,25 @@ if (Sys.getenv("GITHUB_BASE_REF") != "") {
2525
# Use .. to avoid having to fetch the entire history
2626
# https://github.com/krlmlr/actions-sync/issues/45
2727
diff_cmd <- "git diff origin/${GITHUB_BASE_REF}.. -- R/ tests/ | egrep '^[+][^+]' | grep -q ::"
28-
has_diff <- (system(diff_cmd) == 0)
29-
if (has_diff) {
30-
writeLines(system(diff_cmd, intern = TRUE))
28+
diff_lines <- system(diff_cmd, intern = TRUE)
29+
if (length(diff_lines) > 0) {
30+
writeLines("Changes using :: in R/ or tests/:")
31+
writeLines(diff_lines)
3132
packages <- get_deps()
3233
} else {
33-
writeLines("No changes using :: found, not checking without suggested packages")
34+
writeLines("No changes using :: found in R/ or tests/, not checking without suggested packages")
3435
packages <- character()
3536
}
3637
} else {
38+
writeLines("No GITHUB_BASE_REF, checking without suggested packages")
3739
packages <- get_deps()
3840
}
3941

4042
if (length(packages) > 0) {
4143
json <- paste0(
4244
'{"package":[',
4345
paste0('"', packages, '"', collapse = ","),
44-
']}'
46+
"]}"
4547
)
4648
writeLines(paste0("matrix=", json), Sys.getenv("GITHUB_OUTPUT"))
4749
writeLines(json)

.github/workflows/versions-matrix/action.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if (file.exists(".github/versions-matrix.R")) {
3838

3939
print(include_list)
4040

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

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

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

0 commit comments

Comments
 (0)