Publish Unit Test Results #4023
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@170bf24d20d201b842d7a52403b73ed297e6645b # v2.18.0 | |
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@ab30bf28df67017c7ad696500b218558c7c04db3 | |
with: | |
token: ${{ secrets.GIST_TOKEN }} | |
gistURL: https://gist.githubusercontent.com/eclipse-releng-bot/78d110a601baa4ef777ccb472f584038 | |
file: badge.svg |