Test Results #1092
This file contains hidden or 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: Test Results | |
| on: | |
| workflow_run: # will only run on default branch, after CI finished elsewhere | |
| workflows: [ "CI" ] | |
| types: | |
| - completed | |
| permissions: {} | |
| jobs: | |
| test-results: | |
| name: Test Results | |
| runs-on: ubuntu-latest | |
| if: github.event.workflow_run.conclusion != 'skipped' | |
| permissions: | |
| checks: write | |
| pull-requests: write | |
| actions: read | |
| steps: | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: artifacts | |
| run-id: ${{ github.event.workflow_run.id }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish Test Results | |
| uses: EnricoMi/publish-unit-test-result-action@v2 | |
| 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 colour | |
| 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 | |
| uses: emibcn/badge-action@v2.0.3 | |
| with: | |
| label: Tests | |
| status: '${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests }} tests: ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}' | |
| color: ${{ env.BADGE_COLOR }} | |
| path: badge.svg | |
| - name: Upload badge to Gist | |
| if: > | |
| github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main' || | |
| github.event_name != 'workflow_run' && github.ref == 'refs/heads/main' | |
| uses: andymckay/append-gist-action@0.3 | |
| with: | |
| token: ${{ secrets.GIST_TOKEN }} | |
| gistURL: https://gist.githubusercontent.com/auto-differentiation-dev/e0eab86863fac6da5e44d20df215f836 | |
| file: badge.svg |