Skip to content
Open
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
132 changes: 61 additions & 71 deletions .github/workflows/manual-debug.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,61 @@
name: manual-debug

on:
workflow_dispatch:
inputs:
path:
description: |
Path to the R package root, if the package is not at the top level of
the repository.
default: "."
required: false
type: string
package:
description: |
Package to check. If provided, it would have priority over the
package on the repo.
required: false
default: ""
type: string
statuses:
description: |
Create an issue if one or more of the following statuses are
reported on the check report. This is a comma-separated string of
statuses. Default value is ''WARN,ERROR'. Allowed statuses are
'NOTE', 'WARN', and 'ERROR'.
default: "WARN,ERROR"
required: false
type: string
fail-on-error:
description: |
Logical, should the action error if CRAN checks are not ok?
default: "false"
required: false
type: boolean
create-issue:
description: |
Logical, create an issue on CRAN failed checks
default: "true"
required: false
type: boolean
issue-assignees:
description: |
Whom should the issue be assigned to if errors are
encountered in the CRAN status checks?
This is a comma-separated string of GitHub usernames.
If undefined or empty, no assignments are made.
default: ""
required: false
type: string

jobs:
check:
runs-on: ubuntu-latest
permissions: write-all
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Check
uses: dieghernan/cran-status-check@main
with:
path: ${{ inputs.path }}
package: ${{ inputs.package }}
statuses: ${{ inputs.statuses }}
fail-on-error: ${{ inputs.fail-on-error }}
create-issue: ${{ inputs.create-issue }}
issue-assignees: ${{ inputs.issue-assignees }}

name: manual-debug

on:
workflow_dispatch:
inputs:
path:
description: |
Path to the R package root, if the package is not at the top level of
the repository.
default: "."
required: false
type: string
package:
description: |
Package to check. If provided, it would have priority over the
package on the repo.
required: false
default: ""
type: string
fail-on-error:
description: |
Logical, should the action error if CRAN checks are not ok?
default: "false"
required: false
type: boolean
create-issue:
description: |
Logical, create an issue on CRAN failed checks
default: "true"
required: false
type: boolean
issue-assignees:
description: |
Whom should the issue be assigned to if errors are
encountered in the CRAN status checks?
This is a comma-separated string of GitHub usernames.
If undefined or empty, no assignments are made.
default: ""
required: false
type: string

jobs:
check:
runs-on: ubuntu-latest
permissions: write-all
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Check
uses: dieghernan/cran-status-check@main
with:
path: ${{ inputs.path }}
package: ${{ inputs.package }}
fail-on-error: ${{ inputs.fail-on-error }}
create-issue: ${{ inputs.create-issue }}
issue-assignees: ${{ inputs.issue-assignees }}

22 changes: 9 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ inputs:
required: false
default: ""
type: string
statuses:
description: |
CRAN status to check. This is a comma-separated string of
statuses. Default value is ''WARN,ERROR'. Allowed statuses are
'NOTE', 'WARN', and 'ERROR'.
default: "WARN,ERROR"
required: false
type: string
fail-on-error:
description: |
Logical, should the action error if CRAN checks are not ok?
Expand All @@ -48,7 +40,12 @@ inputs:
default: ""
required: false
type: string

statuses:
description: |
DEPRECATED
default: ""
required: false
type: string
# Workflow derived from pharmaverse/admiralci
# See for the original work from which this workflow is derived
# https://github.com/pharmaverse/admiralci/blob/61347fe11955297818b3ca7814fc7328f2ad7840/.github/workflows/cran-status.yml
Expand Down Expand Up @@ -85,7 +82,6 @@ runs:
- name: Compute Cran Status codes
uses: dieghernan/cran-status-check/docker@main
with:
statuses: "${{ inputs.statuses }}"
package: "${{ steps.pkg.outputs.package_name }}"

# Report check
Expand Down Expand Up @@ -116,9 +112,9 @@ runs:

- name: Report Status
if: steps.err.outputs.error == 'true' && inputs.create-issue == 'true'
uses: peter-evans/create-issue-from-file@v5
uses: peter-evans/create-issue-from-file@v6
with:
title: "URGENT! Failed CRAN Checks for ${{ steps.pkg.outputs.package_name }}: ${{ steps.today.outputs.date }}"
title: "URGENT! ${{ steps.pkg.outputs.package_name }} at risk on CRAN: ${{ steps.today.outputs.date }}"
content-filepath: ././cran-status.md
assignees: ${{ inputs.issue-assignees }}

Expand All @@ -127,6 +123,6 @@ runs:
shell: bash
run: |
# Stop action
echo "::error::CRAN checks are not OK, see Job Summary of this GH action for details"
echo "::error::Package at risk, see Job Summary of this GH action for details"
exit 1

44 changes: 16 additions & 28 deletions docker/action.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
# Workflow derived from https://github.com/pharmaverse/admiralci

name: CRAN Status Check
description: Creates a summary of issues reported on the CRAN status check page for a given R package

inputs:
package:
description: |
Package name of the current R package deployed to CRAN
required: true
type: string
statuses:
description: |
Create an issue if one or more of the following
statuses are reported on the check report.
This is a comma-separated string of statuses.
Allowed statuses are 'NOTE', 'WARN', and 'ERROR'
default: 'ERROR'
required: false
type: string

runs:
using: 'docker'
image: './Dockerfile'
args:
- ${{ inputs.package }}
- ${{ inputs.statuses }}

# Workflow derived from https://github.com/pharmaverse/admiralci

name: CRAN Status Check
description: Creates a summary of issues reported on the CRAN status check page for a given R package

inputs:
package:
description: |
Package name of the current R package deployed to CRAN
required: true
type: string
runs:
using: 'docker'
image: './Dockerfile'
args:
- ${{ inputs.package }}
85 changes: 40 additions & 45 deletions docker/check-status.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ option_list <- list(
type = "character",
help = "package name (REQUIRED)",
metavar = "character"
),
make_option(c("-s", "--statuses"),
type = "character", default = "ERROR,WARN,NOTE",
help = "status types (comma separated list, e.g. ERROR,WARN,NOTE",
metavar = "character"
)
)
opt_parser <- OptionParser(option_list = option_list)
Expand All @@ -43,17 +38,21 @@ cran_status <- function(x) {

# 2. Get Inputs ----
pkg <- opt$package # paste(desc::desc_get(keys = "Package"))
# Get input status
status_types <- opt$statuses
statuses <- unlist(strsplit(status_types, split = ","))

url <- sprintf("https://cran.r-project.org/web/checks/check_results_%s.html", pkg)

# 3. Tests -----
cat("Testing package:", pkg, "\n-----\n")
## a. Url not reachable ----

if (httr::http_error(url)) {
# Getting database
options(repos = c(CRAN = "https://cloud.r-project.org"))
pkg_db <- tools::CRAN_package_db() %>%
as_tibble() %>%
filter(Package == pkg)


## a. Not in database ----

if (nrow(pkg_db) == 0) {
cat(
paste0("::warning::Package ", pkg, " not found on CRAN.")
)
Expand All @@ -62,41 +61,57 @@ if (httr::http_error(url)) {
paste0(":x: **Package ", pkg, " not found on CRAN**:\n\n")
)

cran_status(paste0("Error accessing url:\n", url))
cran_status(paste0("Check url:\n", url))

# Copy to issue
file.copy("cran-status.md", "issue.md")
}

## b. Found on CRAN, check issues ----
## b. Found on CRAN, check deadline ----

if (!file.exists("cran-status.md")) {
deadline <- pkg_db %>% pull(Deadline)

scrap <- url %>%
read_html()

cranchecks <- scrap %>%
html_element("table") %>%
html_table()

any_error <- any(cranchecks$Status %in% statuses)
additional <- grepl("Additional", html_text(scrap), ignore.case = TRUE)

### i. Has issues ----
if (any_error) {
# Is on deadline?
is_deadline <- !is.na(deadline)

if (is_deadline) {
# Notify
cran_status(sprintf(
":x: **CRAN checks for %s resulted in one or more (`%s`)s**:\n\n",
":x: **Package %s at risk for removal by `%s`**:\n\n",
pkg,
status_types
deadline
))
cran_status("\nSee the table below for a summary of the checks run by CRAN:\n\n")
cran_status(knitr::kable(cranchecks))

cat("::warning::Package at risk for removal")
} else {
cran_status(sprintf(
"\n\nAll details and logs are available here: %s\n\n", url
":white_check_mark: **Package %s is not at risk for removal",
pkg
))
cat("::warning::One or more CRAN checks resulted in an invalid status\n")

cat("Package is not at risk for removal")
}

### ii. Has additional issues ----
# Additional info

# Add checks
cran_status("\nSee the table below for a summary of the checks run by CRAN:\n\n")
cran_status(knitr::kable(cranchecks))
cran_status(sprintf(
"\n\nAll details and logs are available here: %s", url
))

# Additional issues

if (additional) {
cran_status(sprintf(
Expand All @@ -109,27 +124,7 @@ if (!file.exists("cran-status.md")) {
cat(paste0("::warning::", pkg, " has Additional issues\n"))
}

## So far if cran-status.md exists, generate issue
if (file.exists("cran-status.md")) file.copy("cran-status.md", "issue.md")

### iii. All OK ----
# If no issue has been generated

if (!file.exists("cran-status.md")) {
cat(
sprintf("None of this status found in the CRAN table. (status=%s)", status_types)
)

cran_status(sprintf(
":white_check_mark: **CRAN error for %s not found with (`%s`)s**:\n\n",
pkg,
status_types
))

cran_status("\nSee the table below for a summary of the checks run by CRAN:\n\n")
cran_status(knitr::kable(cranchecks))
cran_status(sprintf(
"\n\nAll details and logs are available here: %s", url
))
}
# Prepare the issue
if (is_deadline) file.copy("cran-status.md", "issue.md")
}
2 changes: 1 addition & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
Rscript /app/check-status.R -p "${INPUT_PACKAGE}" -s "${INPUT_STATUSES}"
Rscript /app/check-status.R -p "${INPUT_PACKAGE}"