Skip to content

Commit c96f7d3

Browse files
authored
ci: Sync (#45)
1 parent bde7f8c commit c96f7d3

File tree

9 files changed

+84
-26
lines changed

9 files changed

+84
-26
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Can't be run as part of commits
33
on:
44
schedule:
5-
- cron: "5 0 * * *" # 05:00 UTC every day only run on main branch
5+
- cron: "0 5 * * *" # 05:00 UTC every day only run on main branch
66
push:
77
branches:
88
- "cran-*"
@@ -69,7 +69,7 @@ jobs:
6969
- uses: ./.github/workflows/install
7070
with:
7171
cache-version: rcc-dev-base-1
72-
needs: check
72+
needs: build, check
7373
extra-packages: "any::rcmdcheck any::remotes ."
7474
token: ${{ secrets.GITHUB_TOKEN }}
7575

@@ -116,7 +116,7 @@ jobs:
116116
- uses: ./.github/workflows/install
117117
with:
118118
cache-version: rcc-dev-${{ matrix.package }}-1
119-
needs: check
119+
needs: build, check
120120
extra-packages: "any::rcmdcheck any::remotes ."
121121
token: ${{ secrets.GITHUB_TOKEN }}
122122

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ jobs:
1616

1717
name: "Update commit status"
1818

19+
permissions:
20+
contents: read
21+
statuses: write
22+
1923
steps:
2024
- name: "Update commit status"
2125
# Only run if triggered by rcc workflow

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

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ on:
3333
types:
3434
- checks_requested
3535
schedule:
36-
- cron: "10 0 * * *"
36+
- cron: "10 1 * * *"
3737

3838
concurrency:
3939
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.ref || github.head_ref || github.sha }}-${{ github.base_ref || '' }}
@@ -44,13 +44,18 @@ name: rcc
4444
jobs:
4545
rcc-smoke:
4646
runs-on: ubuntu-24.04
47+
permissions:
48+
contents: write
4749
outputs:
4850
sha: ${{ steps.commit.outputs.sha }}
4951
versions-matrix: ${{ steps.versions-matrix.outputs.matrix }}
5052
dep-suggests-matrix: ${{ steps.dep-suggests-matrix.outputs.matrix }}
5153

5254
name: "Smoke test: stock R"
5355

56+
permissions:
57+
contents: write
58+
5459
# Begin custom: services
5560
# End custom: services
5661

@@ -104,18 +109,19 @@ jobs:
104109
with:
105110
token: ${{ secrets.GITHUB_TOKEN }}
106111
cache-version: rcc-smoke-2
107-
needs: check, website
112+
needs: build, check, website
108113
# Beware of using dev pkgdown here, has brought in dev dependencies in the past
109114
extra-packages: any::rcmdcheck r-lib/roxygen2 any::decor r-lib/styler r-lib/pkgdown deps::.
110115

116+
- uses: ./.github/workflows/custom/after-install
117+
if: hashFiles('.github/workflows/custom/after-install/action.yml') != ''
118+
119+
# Must come after the custom after-install workflow
111120
- name: Install package
112121
run: |
113122
_R_SHLIB_STRIP_=true R CMD INSTALL .
114123
shell: bash
115124

116-
- uses: ./.github/workflows/custom/after-install
117-
if: hashFiles('.github/workflows/custom/after-install/action.yml') != ''
118-
119125
- id: versions-matrix
120126
# Only run for pull requests if the base repo is different from the head repo, not for workflow_dispatch if not requested, always run for other events
121127
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository) && (github.event_name != 'workflow_dispatch' || inputs.versions-matrix)
@@ -255,7 +261,7 @@ jobs:
255261
r-version: ${{ matrix.r }}
256262
cache-version: rcc-full-1
257263
token: ${{ secrets.GITHUB_TOKEN }}
258-
needs: check
264+
needs: build, check
259265

260266
- uses: ./.github/workflows/custom/after-install
261267
if: hashFiles('.github/workflows/custom/after-install/action.yml') != ''
@@ -264,9 +270,15 @@ jobs:
264270
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
265271

266272
- uses: ./.github/workflows/check
273+
if: ${{ ! matrix.covr }}
267274
with:
268275
results: ${{ runner.os }}-r${{ matrix.r }}
269276

277+
- uses: ./.github/workflows/covr
278+
if: ${{ matrix.covr }}
279+
with:
280+
token: ${{ secrets.CODECOV_TOKEN }}
281+
270282
# The status update is taken care of by R-CMD-check-status.yaml
271283

272284
rcc-suggests:
@@ -295,7 +307,7 @@ jobs:
295307
- uses: ./.github/workflows/install
296308
with:
297309
cache-version: rcc-dev-${{ matrix.package }}-1
298-
needs: check
310+
needs: build, check
299311
extra-packages: "any::rcmdcheck any::remotes ."
300312
token: ${{ secrets.GITHUB_TOKEN }}
301313

.github/workflows/check/action.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,12 @@ runs:
88
using: "composite"
99
steps:
1010
- uses: r-lib/actions/check-r-package@v2
11+
if: ${{ ! inputs.covr }}
1112
with:
1213
# Fails on R 3.6 on Windows, remove when this job is removed?
1314
args: 'c("--no-manual", "--as-cran", "--no-multiarch")'
1415
error-on: ${{ env.RCMDCHECK_ERROR_ON || '"note"' }}
1516

16-
- name: Run coverage check
17-
if: ${{ matrix.config.covr }}
18-
run: |
19-
if (dir.exists("tests/testthat")) {
20-
covr::codecov()
21-
} else {
22-
message("No tests found, coverage not tested.")
23-
}
24-
shell: Rscript {0}
25-
2617
- name: Show test output
2718
if: always()
2819
run: |

.github/workflows/commit/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ runs:
2020
if [ -n "$(git status --porcelain)" ]; then
2121
echo "Changed"
2222
protected=${{ github.ref_protected }}
23-
foreign=${{ github.event.pull_request.head.repo.full_name != github.repository }}
23+
foreign=${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
2424
if [ "${foreign}" = "true" ]; then
2525
# https://github.com/krlmlr/actions-sync/issues/44
2626
echo "Can't push to foreign branch"

.github/workflows/covr/action.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: "Actions to run covr for an R package"
2+
inputs:
3+
token:
4+
description: codecov token
5+
required: false
6+
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: Run coverage check
11+
run: |
12+
if (dir.exists("tests/testthat")) {
13+
cov <- covr::package_coverage(
14+
quiet = FALSE,
15+
clean = FALSE,
16+
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
17+
)
18+
covr::to_cobertura(cov)
19+
} else {
20+
message("No tests found, coverage not tested.")
21+
}
22+
shell: Rscript {0}
23+
24+
- uses: codecov/codecov-action@v5
25+
with:
26+
# Fail if error if not on PR, or if on PR and token is given
27+
fail_ci_if_error: ${{ github.event_name != 'pull_request' || inputs.token }}
28+
files: ./cobertura.xml
29+
plugins: noop
30+
disable_search: true
31+
token: ${{ inputs.token }}
32+
33+
- name: Show testthat output
34+
if: always()
35+
run: |
36+
## --------------------------------------------------------------------
37+
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
38+
shell: bash
39+
40+
- name: Upload test results
41+
if: failure()
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: coverage-test-failures
45+
path: ${{ runner.temp }}/package

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ if (Sys.getenv("GITHUB_BASE_REF") != "") {
2424
system("git fetch origin ${GITHUB_BASE_REF}")
2525
# Use .. to avoid having to fetch the entire history
2626
# https://github.com/krlmlr/actions-sync/issues/45
27-
has_diff <- (system("git diff origin/${GITHUB_BASE_REF}.. | egrep '^[+][^+]' | grep -q ::") == 0)
27+
diff_cmd <- "git diff origin/${GITHUB_BASE_REF}.. -- R/ tests/ | egrep '^[+][^+]' | grep -q ::"
28+
has_diff <- (system(diff_cmd) == 0)
2829
if (has_diff) {
29-
system("git diff origin/${GITHUB_BASE_REF}.. | egrep '^[+][^+]' | grep -q ::")
30+
writeLines(system(diff_cmd, intern = TRUE))
3031
packages <- get_deps()
3132
} else {
3233
writeLines("No changes using :: found, not checking without suggested packages")

.github/workflows/install/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ runs:
104104
pak-version: stable
105105
needs: ${{ inputs.needs }}
106106
packages: ${{ inputs.packages }}
107-
extra-packages: ${{ inputs.extra-packages }} ${{ ( matrix.config.covr && 'any::covr' ) || '' }} ${{ steps.get-extra.outputs.packages }}
107+
extra-packages: ${{ inputs.extra-packages }} ${{ ( matrix.covr && 'any::covr' ) || '' }} ${{ steps.get-extra.outputs.packages }}
108108
cache-version: ${{ inputs.cache-version }}
109109

110110
- name: Add pkg.lock to .gitignore

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ include_list <- list(macos, windows, linux_devel, linux, covr)
3030

3131
if (file.exists(".github/versions-matrix.R")) {
3232
custom <- source(".github/versions-matrix.R")$value
33-
include_list <- c(include_list, list(custom))
33+
if (is.data.frame(custom)) {
34+
custom <- list(custom)
35+
}
36+
include_list <- c(include_list, custom)
3437
}
3538

3639
print(include_list)
@@ -56,5 +59,7 @@ to_json <- function(x) {
5659
configs <- unlist(lapply(include_list, to_json))
5760
json <- paste0('{"include":[', paste(configs, collapse = ","), ']}')
5861

59-
writeLines(paste0("matrix=", json), Sys.getenv("GITHUB_OUTPUT"))
62+
if (Sys.getenv("GITHUB_OUTPUT") != "") {
63+
writeLines(paste0("matrix=", json), Sys.getenv("GITHUB_OUTPUT"))
64+
}
6065
writeLines(json)

0 commit comments

Comments
 (0)