Skip to content
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
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
^\.positai$
^\.claude$
^AGENTS\.md$
^[.]?air[.]toml$
^\.vscode$
1 change: 1 addition & 0 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
any::testthat
any::usethis
any::withr
Gilead-BioStats/qcthat
local::.

- name: Install air
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/format-suggest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Workflow derived from https://github.com/posit-dev/setup-air/tree/main/examples

on:
# Using `pull_request_target` over `pull_request` for elevated `GITHUB_TOKEN`
# privileges, otherwise we can't set `pull-requests: write` when the pull
# request comes from a fork, which is our main use case (external contributors).
#
# `pull_request_target` runs in the context of the target branch (`main`, usually),
# rather than in the context of the pull request like `pull_request` does. Due
# to this, we must explicitly checkout `ref: ${{ github.event.pull_request.head.sha }}`.
# This is typically frowned upon by GitHub, as it exposes you to potentially running
# untrusted code in a context where you have elevated privileges, but they explicitly
# call out the use case of reformatting and committing back / commenting on the PR
# as a situation that should be safe (because we aren't actually running the untrusted
# code, we are just treating it as passive data).
# https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
pull_request_target:

name: format-suggest.yaml

jobs:
format-suggest:
name: format-suggest
runs-on: ubuntu-latest

permissions:
# Required to push suggestion comments to the PR
pull-requests: write

steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Install
uses: posit-dev/setup-air@v1

- name: Format
run: air format .

- name: Suggest
uses: reviewdog/action-suggester@v1
with:
level: error
fail_level: error
tool_name: air
33 changes: 33 additions & 0 deletions .github/workflows/pkgdown-cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow removes the pkgdown preview directory when a PR is closed.
name: Clean up pkgdown preview

on:
pull_request:
types: [closed]

permissions:
contents: write

jobs:
clean-pr-preview:
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v6
with:
repository: ${{ github.repository }}
token: ${{ secrets.GITHUB_TOKEN }}
ref: gh-pages

- name: Remove PR preview directory
run: |
pr_dir="pr/${{ github.event.number }}"
if [ -d "$pr_dir" ]; then
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git rm -rf "$pr_dir"
git commit -m "Remove preview for PR #${{ github.event.number }}"
git push
else
echo "Directory $pr_dir does not exist, skipping cleanup."
fi
4 changes: 2 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
use-container: "true"
token: ${{ secrets.GITHUB_TOKEN }}
needs: website
extra-packages: any::pkgdown gilead-biostats/qcthat local::.
extra-packages: any::pkgdown gilead-biostats/qcthat local::. any::glue

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
Expand All @@ -54,7 +54,7 @@ jobs:
strOwner <- tolower(qcthat::GetGHOwner())
strRepo <- qcthat::GetGHRepo()
strURL <- glue::glue(
"https://{strOwner}.github.io/{strRepo}/pr/{intPRNumber}/dev"
"https://{strOwner}.github.io/{strRepo}/pr/{intPRNumber}"
)
print(paste("🌐 URL:", strURL))
qcthat::CommentIssue(
Expand Down
157 changes: 157 additions & 0 deletions .github/workflows/qcthat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# Workflow derived from
# https://github.com/Gilead-BioStats/qcthat/tree/v1.1.1/inst/workflows/qcthat.yaml.
on:
pull_request:
types: [opened, edited, reopened, synchronize, milestoned]
release:
types: [released]
issues:
types: [closed]
workflow_dispatch:
inputs:
pr:
description: PR number to which reports should be added (leave blank for none).
required: false
milestone:
description: Milestone name to use for the milestone report (leave blank for none).
required: false
tag:
description: Release tag to which the report should be attached (leave blank for none).
required: false
issueNumber:
description: The closed issue number to process to update user acceptance testing information.
required: false

name: qcthat Quality Control

permissions:
# read: Required for generating reports and updating UAT status.
# write: Required for initiating the UAT process.
issues: write
# read: Required for updating UAT status.
# write: Required for adding reports to pull requests.
pull-requests: write
# write: Required for attaching reports to releases.
contents: write
# write: Required for updating UAT status.
actions: write

# Configuration variables for controlling workflow behavior
env:
qcthat_UAT: true
qcthat_PR_REPORT: true
qcthat_COMPLETED_REPORT: true
qcthat_MILESTONE_REPORT: true
qcthat_RELEASE_REPORT: true
qcthat_FAIL_FOR_TEST_FAILURES: true

jobs:
qcthat:
runs-on: ubuntu-latest
container:
image: ghcr.io/api2r/pkgskills-ci:release
if: >-
(github.event_name == 'issues' && contains(github.event.issue.labels.*.name, 'qcthat-uat')) ||
github.event_name != 'issues'
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v6

- uses: api2r/actions/install@v1
with:
use-container: "true"
token: ${{ secrets.GITHUB_TOKEN }}
extra-packages: Gilead-BioStats/qcthat@main local::.

- name: Manage User Acceptance Testing
if: >-
env.qcthat_UAT == 'true' && (
(github.event_name == 'issues' && contains(github.event.issue.labels.*.name, 'qcthat-uat')) ||
(github.event_name == 'workflow_dispatch' && inputs.issueNumber != '')
)
run: |
Rscript -e "qcthat::TriggerUAT()"

- name: Generate Issue-Test Matrix
if: >-
(env.qcthat_PR_REPORT == 'true' || env.qcthat_RELEASE_REPORT == 'true' || env.qcthat_FAIL_FOR_TEST_FAILURES == 'true') && (
github.event_name == 'pull_request' ||
github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && inputs.issueNumber == '')
)
run: |
# Generate the full matrix for the package
IssueTestMatrix <- qcthat::QCPackage()
print(IssueTestMatrix)

# Save the matrix and UAT data for subsequent steps
saveRDS(IssueTestMatrix, "ITM.rds")
qcthat::SaveUATIssues()
shell: Rscript {0}

- name: Update PR Reports
if: >-
env.qcthat_PR_REPORT == 'true' && (
github.event_name == 'pull_request' ||
(github.event_name == 'workflow_dispatch' && inputs.pr != '')
)
run: |
issueTestMatrix <- readRDS("ITM.rds")
qcthat::LoadUATIssues()
qcthat::CommentAllReports(
dfITM = issueTestMatrix,
lglPR = as.logical("${{ env.qcthat_PR_REPORT }}"),
lglMilestone = as.logical("${{ env.qcthat_MILESTONE_REPORT }}"),
lglCompleted = as.logical("${{ env.qcthat_COMPLETED_REPORT }}"),
lglUAT = as.logical("${{ env.qcthat_UAT }}")
)
shell: Rscript {0}

- name: Update Release Reports
if: >-
env.qcthat_RELEASE_REPORT == 'true' && (
github.event_name == 'release' || inputs.tag != ''
)
run: |
issueTestMatrix <- readRDS("ITM.rds")
qcthat::LoadUATIssues()
qcthat::AttachReleaseReports(
dfITM = issueTestMatrix,
lglCompleted = as.logical("${{ env.qcthat_COMPLETED_REPORT }}"),
lglMilestone = as.logical("${{ env.qcthat_MILESTONE_REPORT }}")
)
shell: Rscript {0}

- name: Flag failure for PR
if: >-
env.qcthat_FAIL_FOR_TEST_FAILURES == 'true' && (
github.event_name == 'pull_request' ||
(github.event_name == 'workflow_dispatch' && inputs.pr != '')
)
run: |
issueTestMatrix <- readRDS("ITM.rds")
dfPR <- qcthat::QCPR(dfITM = issueTestMatrix)
if (any(dfPR$Disposition == "fail", na.rm = TRUE)) {
cli::cli_abort(
"One or more tests failed or were skipped for PR-associated issues."
)
}
shell: Rscript {0}

- name: Flag failure for completed
if: >-
env.qcthat_FAIL_FOR_TEST_FAILURES == 'true' && (
github.event_name == 'pull_request' ||
github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && inputs.issueNumber == '')
)
run: |
issueTestMatrix <- readRDS("ITM.rds")
dfCompleted = qcthat::QCCompletedIssues(dfITM = issueTestMatrix)
if (any(dfCompleted$Disposition == "fail", na.rm = TRUE)) {
cli::cli_abort(
"One or more tests failed or were skipped for completed issues."
)
}
shell: Rscript {0}
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"Posit.air-vscode"
]
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"[r]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "Posit.air-vscode"
},
"[quarto]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "quarto.quarto"
}
}
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Imports:
snakecase,
stbl (>= 0.3.0),
tibble,
tibblify (>= 0.3.2),
tibblify (>= 0.4.0),
xml2,
yaml
Suggests:
Expand Down
22 changes: 14 additions & 8 deletions R/components-schema.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,20 @@ class_schema <- S7::new_class(
description = character_scalar_property("description"),
format = character_scalar_property("format")
),
constructor = function(type = c(
"string", "number", "integer",
"boolean", "array", "object"
),
...,
nullable = FALSE,
description = character(),
format = character()) {
constructor = function(
type = c(
"string",
"number",
"integer",
"boolean",
"array",
"object"
),
...,
nullable = FALSE,
description = character(),
format = character()
) {
check_dots_empty()
if (missing(type)) {
type <- character()
Expand Down
16 changes: 10 additions & 6 deletions R/components-security_scheme-api_key.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ class_api_key_security_scheme <- S7::new_class(
parameter_name = character_scalar_property("parameter_name"),
location = character_scalar_property("location")
),
constructor = function(parameter_name = character(),
location = c("query", "header", "cookie")) {
constructor = function(
parameter_name = character(),
location = c("query", "header", "cookie")
) {
if (length(parameter_name)) {
location <- rlang::arg_match(location)
} else {
Expand Down Expand Up @@ -75,10 +77,12 @@ S7::method(length, class_api_key_security_scheme) <- function(x) {
#' @export
#' @family components_security_schemes
#' @family components
as_api_key_security_scheme <- function(x,
...,
arg = caller_arg(x),
call = caller_env()) {
as_api_key_security_scheme <- function(
x,
...,
arg = caller_arg(x),
call = caller_env()
) {
as_api_object(
x,
class_api_key_security_scheme,
Expand Down
22 changes: 13 additions & 9 deletions R/components-security_scheme-oauth2-authorization_code_flow.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ class_oauth2_authorization_code_flow <- S7::new_class(
authorization_url = character_scalar_property("authorization_url"),
token_url = character_scalar_property("token_url")
),
constructor = function(authorization_url = character(),
token_url = character(),
...,
refresh_url = character(),
scopes = class_scopes()) {
constructor = function(
authorization_url = character(),
token_url = character(),
...,
refresh_url = character(),
scopes = class_scopes()
) {
check_dots_empty()
S7::new_object(
S7::S7_object(),
Expand Down Expand Up @@ -84,10 +86,12 @@ S7::method(length, class_oauth2_authorization_code_flow) <- function(x) {
#' @export
#' @family components_security_schemes
#' @family components
as_oauth2_authorization_code_flow <- function(x,
...,
arg = caller_arg(x),
call = caller_env()) {
as_oauth2_authorization_code_flow <- function(
x,
...,
arg = caller_arg(x),
call = caller_env()
) {
as_api_object(
x,
class_oauth2_authorization_code_flow,
Expand Down
Loading
Loading