Publish Unit Test Results #5
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
name: Publish Unit Test Results | |
on: | |
workflow_run: | |
workflows: ["SWT Matrix Build"] | |
types: | |
- completed | |
permissions: | |
contents: read | |
jobs: | |
unit-test-results: | |
name: Unit Test Results | |
runs-on: ubuntu-latest | |
if: github.event.workflow_run.conclusion != 'skipped' | |
permissions: | |
checks: write | |
pull-requests: write | |
contents: read | |
issues: read | |
actions: read | |
steps: | |
- name: Download and Extract Artifacts | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
run: | | |
mkdir -p artifacts && cd artifacts | |
artifacts_url=${{ github.event.workflow_run.artifacts_url }} | |
gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact | |
do | |
IFS=$'\t' read name url <<< "$artifact" | |
gh api $url > "$name.zip" | |
unzip -d "$name" "$name.zip" | |
done | |
- name: Publish Unit Test Results | |
uses: EnricoMi/publish-unit-test-result-action@30eadd5010312f995f0d3b3cff7fe2984f69409e # v2.16.1 | |
id: test-results | |
with: | |
commit: ${{ github.event.workflow_run.head_sha }} | |
event_file: artifacts/Event File/event.json | |
event_name: ${{ github.event.workflow_run.event }} | |
files: "artifacts/**/*.xml" | |
- name: Set badge color | |
if: github.ref == 'refs/heads/master' | |
shell: bash | |
run: | | |
case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in | |
success) | |
echo "BADGE_COLOR=31c653" >> $GITHUB_ENV | |
;; | |
failure) | |
echo "BADGE_COLOR=800000" >> $GITHUB_ENV | |
;; | |
neutral) | |
echo "BADGE_COLOR=696969" >> $GITHUB_ENV | |
;; | |
esac | |
- name: Create badge | |
if: github.ref == 'refs/heads/master' | |
uses: emibcn/badge-action@808173dd03e2f30c980d03ee49e181626088eee8 | |
with: | |
label: Tests | |
status: '${{ fromJSON( steps.test-results.outputs.json ).stats.tests }} tests, ${{ fromJSON( steps.test-results.outputs.json ).stats.runs }} runs: ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}' | |
color: ${{ env.BADGE_COLOR }} | |
path: badge.svg | |
- name: Upload badge to Gist | |
if: github.ref == 'refs/heads/master' | |
uses: andymckay/append-gist-action@6e8d64427fe47cbacf4ab6b890411f1d67c07f3e | |
with: | |
token: ${{ secrets.GIST_TOKEN }} | |
gistURL: https://gist.githubusercontent.com/eclipse-releng-bot/78d110a601baa4ef777ccb472f584038 | |
file: badge.svg |