Skip to content

Commit 15a39c6

Browse files
laeubiakurtakov
authored andcommitted
Generate a badge with the test results
1 parent bb8fd2d commit 15a39c6

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

.github/workflows/junit.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,39 @@ jobs:
3030
3131
- name: Publish Unit Test Results
3232
uses: EnricoMi/publish-unit-test-result-action@v1
33+
id: test-results
3334
with:
3435
commit: ${{ github.event.workflow_run.head_sha }}
3536
files: "artifacts/**/*.xml"
37+
- name: Set badge color
38+
if: github.ref == 'refs/heads/master'
39+
shell: bash
40+
run: |
41+
case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in
42+
success)
43+
echo "BADGE_COLOR=31c653" >> $GITHUB_ENV
44+
;;
45+
failure)
46+
echo "BADGE_COLOR=800000" >> $GITHUB_ENV
47+
;;
48+
neutral)
49+
echo "BADGE_COLOR=696969" >> $GITHUB_ENV
50+
;;
51+
esac
52+
53+
- name: Create badge
54+
if: github.ref == 'refs/heads/master'
55+
uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1
56+
with:
57+
label: Tests
58+
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 }}'
59+
color: ${{ env.BADGE_COLOR }}
60+
path: badge.svg
3661

62+
- name: Upload badge to Gist
63+
if: github.ref == 'refs/heads/master'
64+
uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d
65+
with:
66+
token: ${{ secrets.GIST_TOKEN }}
67+
gistURL: https://gist.githubusercontent.com/eclipse-platform/eclipse.platform.swt/
68+
file: test_results_badge.svg

0 commit comments

Comments
 (0)