forked from uutils/findutils
-
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.
Provide GNU test comparison comments for PRs in Github Actions. (uuti…
- Loading branch information
Showing
3 changed files
with
207 additions
and
137 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,70 @@ | ||
on: | ||
workflow_run: | ||
workflows: [External testsuites] | ||
types: [completed] | ||
|
||
name: Comment Test results on the PR | ||
|
||
jobs: | ||
upload-pr-comment: | ||
name: Upload PR comment | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'pull_request' | ||
permissions: | ||
actions: read | ||
pull-requests: write | ||
|
||
steps: | ||
- name: List Annotations | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
let runs = await github.rest.checks.listForRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: '${{ github.event.pull_request.head.sha }}' | ||
}); | ||
let names = ['Run GNU findutils tests', 'Run BFS tests']; | ||
let results = []; | ||
runs.data.check_runs.filter(check => names.includes(check.name)).forEach(run => results.push(run)); | ||
let annotations = { data: []}; | ||
for (let result of results) { | ||
let run = await github.rest.checks.listAnnotations({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
check_run_id: result.id | ||
}); | ||
run.data.forEach(data => { | ||
annotations.data.push({ | ||
run: result.name, | ||
annotation: data | ||
}); | ||
}); | ||
} | ||
let fs = require('fs'); | ||
fs.writeFileSync('${{ github.workspace }}/annotations.json', JSON.stringify(annotations)); | ||
- name: Comment on PR | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
let fs = require('fs'); | ||
let annotations = JSON.parse(fs.readFileSync('${{ github.workspace }}/annotations.json', 'utf8')); | ||
let annotationContent = annotations | ||
.data | ||
.map(annotation => `${annotation.run}: ${annotation.annotation.message}`) | ||
.join('\n'); | ||
console.log(annotationContent); | ||
github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: ${{ github.event.number }}, | ||
body: 'GNU testsuite comparison:\n```\n' + annotationContent + '```' | ||
}); |
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