Skip to content

Commit f6ff4aa

Browse files
committed
Add cran-status-check workflow
Fix #7008 Supersedes #7020
1 parent a080833 commit f6ff4aa

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
on:
2+
workflow_dispatch:
3+
schedule:
4+
- cron: '0 6 * * 1,3,5' # Runs at 06:00 on Mon/Wed/Fri
5+
6+
name: check-cran-status
7+
8+
jobs:
9+
fetch-deadlines:
10+
runs-on: ubuntu-latest
11+
env:
12+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
13+
permissions:
14+
issues: write
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: r-lib/actions/setup-r@v2
19+
with:
20+
use-public-rspm: true
21+
22+
- uses: r-lib/actions/setup-r-dependencies@v2
23+
with:
24+
packages: gh
25+
26+
- name: Check for existing CRAN issues
27+
id: check-issues
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
run: |
31+
# Count open issues with CRAN-related labels
32+
ISSUE_COUNT=$(gh issue list --label "cran-deadline" --state open --json number | jq length)
33+
if [ $ISSUE_COUNT -eq 0 ]; then
34+
SHOULD_RUN="true"
35+
echo "✅ Will run CRAN check"
36+
else
37+
SHOULD_RUN="false"
38+
echo "⏭️ Skipping CRAN check - existing issues found"
39+
fi
40+
echo "should-run=$SHOULD_RUN" >> $GITHUB_OUTPUT
41+
42+
- name: Fetch deadline for this package
43+
if: steps.check-issues.outputs.should-run == 'true'
44+
shell: Rscript {0}
45+
run: |
46+
crandb <- tools::CRAN_package_db()
47+
48+
pkgname <- drop(read.dcf("DESCRIPTION", "Package"))
49+
50+
deadline <- crandb[crandb$Package == pkgname, "Deadline"]
51+
52+
if (!is.na(deadline)) {
53+
gh::gh(
54+
"POST /repos/{owner_repo}/issues",
55+
owner_repo = Sys.getenv("GITHUB_REPOSITORY"),
56+
title = paste("Fix CRAN R CMD check issues by", deadline),
57+
body = paste0(
58+
"This package is failing CRAN checks and is at risk of archival.\n",
59+
"https://cran.r-project.org/web/checks/check_results_",
60+
pkgname,
61+
".html"
62+
),
63+
labels = list("cran-deadline")
64+
)
65+
}

0 commit comments

Comments
 (0)