-
Notifications
You must be signed in to change notification settings - Fork 1.6k
75 lines (63 loc) · 2.15 KB
/
Copy pathtest-results-master.yml
File metadata and controls
75 lines (63 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Test results for the master branch
on:
workflow_call:
defaults:
run:
shell: bash
jobs:
test-results:
name: Publish
runs-on: ubuntu-22.04
env:
BADGES_BRANCH: badges
BADGE_PATH: test-results.svg
permissions:
checks: write
pull-requests: write
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: "${{ env.BADGES_BRANCH }}"
- uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
pattern: test-results-*
path: test-results
merge-multiple: true
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@c950f6fb443cb5af20a377fd0dfaa78838901040 # v2.23.0
id: test-results
with:
files: "test-results/*/*.xml"
- name: Set badge color
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@808173dd03e2f30c980d03ee49e181626088eee8 # v2.0.3
with:
label: Tests
status: "${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests }} tests, ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.runs }} runs, ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests_fail }} failed"
color: "${{ env.BADGE_COLOR }}"
path: "${{ env.BADGE_PATH }}"
- name: Configure Git for GitHub Actions bot
run: |-
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
- name: Commit if stats have changed
run: |-
git add "${{ env.BADGE_PATH }}"
if git commit -m "Update test results from ${{ github.sha }}"; then
git push
else
echo "Nothing has changed"
fi