forked from ReactionMechanismGenerator/RMG-Py
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge PR ReactionMechanismGenerator#2501. Expand and fix regression t…
…est comments. The results of the regression tests were largely buried in the logs of the continuous integration action workflow, rather than being nicely summarized on the annotation to the pull request. The summaries and comparisons that are generated by the CI running the regression tests are captured, and used to make the annotation. The summary is stored as a text file, with the pull request number stored on the first line. This is then uploaded as an artifact. A new workflow runs whenever the CI workflow completes, then downloads the artifact, extracts the summary, and posts a comment. This complicated runaround is needed because workflows run by pull requests from forks do not have permission to write comments directly. Also fixed up some markdown formatting.
- Loading branch information
Showing
3 changed files
with
103 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Annotate pull request with regression summaries | ||
# Takes a regression summary from a workflow run and annotates the pull request with it | ||
# The pull request number is taken from the first line of the summary.txt file. | ||
# The summary file is in an artifact called regression_summary associated | ||
# with the workflow run that triggered this workflow. | ||
# based on https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow | ||
|
||
on: | ||
workflow_run: | ||
workflows: | ||
- Continuous Integration | ||
types: | ||
- completed | ||
|
||
jobs: | ||
on-success: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
steps: | ||
- run: echo 'The triggering workflow passed' | ||
- name: 'Download regression_summary artifact' | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: context.payload.workflow_run.id, | ||
}); | ||
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { | ||
return artifact.name == "regression_summary" | ||
})[0]; | ||
let download = await github.rest.actions.downloadArtifact({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
artifact_id: matchArtifact.id, | ||
archive_format: 'zip', | ||
}); | ||
let fs = require('fs'); | ||
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/regression_summary.zip`, Buffer.from(download.data)); | ||
- name: 'Unzip artifact' | ||
run: unzip regression_summary.zip | ||
|
||
- name: 'Get pull request number' | ||
id: pr_number | ||
run: | | ||
echo "PR_NUMBER=$( head -n 1 summary.txt )" >> $GITHUB_ENV | ||
# remove the first line from the file | ||
sed -i '1d' summary.txt | ||
- name: Write summary to pull request as a comment | ||
uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
filePath: summary.txt | ||
pr_number: ${{ env.PR_NUMBER }} | ||
|
||
on-failure: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'failure' }} | ||
steps: | ||
- run: echo 'The triggering workflow failed' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters