|
| 1 | +# Workflow derived from |
| 2 | +# https://github.com/Gilead-BioStats/qcthat/tree/v1.1.1/inst/workflows/qcthat.yaml. |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, edited, reopened, synchronize, milestoned] |
| 6 | + release: |
| 7 | + types: [released] |
| 8 | + issues: |
| 9 | + types: [closed] |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + pr: |
| 13 | + description: PR number to which reports should be added (leave blank for none). |
| 14 | + required: false |
| 15 | + milestone: |
| 16 | + description: Milestone name to use for the milestone report (leave blank for none). |
| 17 | + required: false |
| 18 | + tag: |
| 19 | + description: Release tag to which the report should be attached (leave blank for none). |
| 20 | + required: false |
| 21 | + issueNumber: |
| 22 | + description: The closed issue number to process to update user acceptance testing information. |
| 23 | + required: false |
| 24 | + |
| 25 | +name: qcthat Quality Control |
| 26 | + |
| 27 | +permissions: |
| 28 | + # read: Required for generating reports and updating UAT status. |
| 29 | + # write: Required for initiating the UAT process. |
| 30 | + issues: write |
| 31 | + # read: Required for updating UAT status. |
| 32 | + # write: Required for adding reports to pull requests. |
| 33 | + pull-requests: write |
| 34 | + # write: Required for attaching reports to releases. |
| 35 | + contents: write |
| 36 | + # write: Required for updating UAT status. |
| 37 | + actions: write |
| 38 | + |
| 39 | +# Configuration variables for controlling workflow behavior |
| 40 | +env: |
| 41 | + qcthat_UAT: true |
| 42 | + qcthat_PR_REPORT: true |
| 43 | + qcthat_COMPLETED_REPORT: true |
| 44 | + qcthat_MILESTONE_REPORT: true |
| 45 | + qcthat_RELEASE_REPORT: true |
| 46 | + qcthat_FAIL_FOR_TEST_FAILURES: true |
| 47 | + |
| 48 | +jobs: |
| 49 | + qcthat: |
| 50 | + runs-on: ubuntu-latest |
| 51 | + container: |
| 52 | + image: ghcr.io/api2r/pkgskills-ci:release |
| 53 | + if: >- |
| 54 | + (github.event_name == 'issues' && contains(github.event.issue.labels.*.name, 'qcthat-uat')) || |
| 55 | + github.event_name != 'issues' |
| 56 | + env: |
| 57 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v6 |
| 60 | + |
| 61 | + - uses: api2r/actions/install@v1 |
| 62 | + with: |
| 63 | + use-container: "true" |
| 64 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + extra-packages: Gilead-BioStats/qcthat@main local::. |
| 66 | + |
| 67 | + - name: Manage User Acceptance Testing |
| 68 | + if: >- |
| 69 | + env.qcthat_UAT == 'true' && ( |
| 70 | + (github.event_name == 'issues' && contains(github.event.issue.labels.*.name, 'qcthat-uat')) || |
| 71 | + (github.event_name == 'workflow_dispatch' && inputs.issueNumber != '') |
| 72 | + ) |
| 73 | + run: | |
| 74 | + Rscript -e "qcthat::TriggerUAT()" |
| 75 | +
|
| 76 | + - name: Generate Issue-Test Matrix |
| 77 | + if: >- |
| 78 | + (env.qcthat_PR_REPORT == 'true' || env.qcthat_RELEASE_REPORT == 'true' || env.qcthat_FAIL_FOR_TEST_FAILURES == 'true') && ( |
| 79 | + github.event_name == 'pull_request' || |
| 80 | + github.event_name == 'release' || |
| 81 | + (github.event_name == 'workflow_dispatch' && inputs.issueNumber == '') |
| 82 | + ) |
| 83 | + run: | |
| 84 | + # Generate the full matrix for the package |
| 85 | + IssueTestMatrix <- qcthat::QCPackage() |
| 86 | + print(IssueTestMatrix) |
| 87 | +
|
| 88 | + # Save the matrix and UAT data for subsequent steps |
| 89 | + saveRDS(IssueTestMatrix, "ITM.rds") |
| 90 | + qcthat::SaveUATIssues() |
| 91 | + shell: Rscript {0} |
| 92 | + |
| 93 | + - name: Update PR Reports |
| 94 | + if: >- |
| 95 | + env.qcthat_PR_REPORT == 'true' && ( |
| 96 | + github.event_name == 'pull_request' || |
| 97 | + (github.event_name == 'workflow_dispatch' && inputs.pr != '') |
| 98 | + ) |
| 99 | + run: | |
| 100 | + issueTestMatrix <- readRDS("ITM.rds") |
| 101 | + qcthat::LoadUATIssues() |
| 102 | + qcthat::CommentAllReports( |
| 103 | + dfITM = issueTestMatrix, |
| 104 | + lglPR = as.logical("${{ env.qcthat_PR_REPORT }}"), |
| 105 | + lglMilestone = as.logical("${{ env.qcthat_MILESTONE_REPORT }}"), |
| 106 | + lglCompleted = as.logical("${{ env.qcthat_COMPLETED_REPORT }}"), |
| 107 | + lglUAT = as.logical("${{ env.qcthat_UAT }}") |
| 108 | + ) |
| 109 | + shell: Rscript {0} |
| 110 | + |
| 111 | + - name: Update Release Reports |
| 112 | + if: >- |
| 113 | + env.qcthat_RELEASE_REPORT == 'true' && ( |
| 114 | + github.event_name == 'release' || inputs.tag != '' |
| 115 | + ) |
| 116 | + run: | |
| 117 | + issueTestMatrix <- readRDS("ITM.rds") |
| 118 | + qcthat::LoadUATIssues() |
| 119 | + qcthat::AttachReleaseReports( |
| 120 | + dfITM = issueTestMatrix, |
| 121 | + lglCompleted = as.logical("${{ env.qcthat_COMPLETED_REPORT }}"), |
| 122 | + lglMilestone = as.logical("${{ env.qcthat_MILESTONE_REPORT }}") |
| 123 | + ) |
| 124 | + shell: Rscript {0} |
| 125 | + |
| 126 | + - name: Flag failure for PR |
| 127 | + if: >- |
| 128 | + env.qcthat_FAIL_FOR_TEST_FAILURES == 'true' && ( |
| 129 | + github.event_name == 'pull_request' || |
| 130 | + (github.event_name == 'workflow_dispatch' && inputs.pr != '') |
| 131 | + ) |
| 132 | + run: | |
| 133 | + issueTestMatrix <- readRDS("ITM.rds") |
| 134 | + dfPR <- qcthat::QCPR(dfITM = issueTestMatrix) |
| 135 | + if (any(dfPR$Disposition == "fail", na.rm = TRUE)) { |
| 136 | + cli::cli_abort( |
| 137 | + "One or more tests failed or were skipped for PR-associated issues." |
| 138 | + ) |
| 139 | + } |
| 140 | + shell: Rscript {0} |
| 141 | + |
| 142 | + - name: Flag failure for completed |
| 143 | + if: >- |
| 144 | + env.qcthat_FAIL_FOR_TEST_FAILURES == 'true' && ( |
| 145 | + github.event_name == 'pull_request' || |
| 146 | + github.event_name == 'release' || |
| 147 | + (github.event_name == 'workflow_dispatch' && inputs.issueNumber == '') |
| 148 | + ) |
| 149 | + run: | |
| 150 | + issueTestMatrix <- readRDS("ITM.rds") |
| 151 | + dfCompleted = qcthat::QCCompletedIssues(dfITM = issueTestMatrix) |
| 152 | + if (any(dfCompleted$Disposition == "fail", na.rm = TRUE)) { |
| 153 | + cli::cli_abort( |
| 154 | + "One or more tests failed or were skipped for completed issues." |
| 155 | + ) |
| 156 | + } |
| 157 | + shell: Rscript {0} |
0 commit comments