Skip to content

Commit 2c7f79b

Browse files
committed
GH: separate into 3 different badges
1 parent e5a1dd9 commit 2c7f79b

File tree

2 files changed

+67
-12
lines changed

2 files changed

+67
-12
lines changed

.github/workflows/build-and-test.yml

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,37 +226,80 @@ jobs:
226226
shell: bash
227227
run: |
228228
conclusion="${{ fromJSON( steps.test.outputs.json ).conclusion }}"
229+
num_suites="${{ fromJSON( steps.test.outputs.json ).stats.suites }}"
230+
num_tests="${{ fromJSON( steps.test.outputs.json ).stats.tests }}"
231+
num_runs="${{ fromJSON( steps.test.outputs.json ).stats.runs }}"
232+
num_tests_skip="${{ fromJSON( steps.test.outputs.json ).stats.tests_skip }}"
233+
num_runs_skip="${{ fromJSON( steps.test.outputs.json ).stats.runs_skip }}"
234+
runs_error="${{ fromJSON( steps.test.outputs.json ).stats.runs_error }}"
235+
runs_fail="${{ fromJSON( steps.test.outputs.json ).stats.runs_fail }}"
236+
tests_fail="${{ fromJSON( steps.test.outputs.json ).stats.tests_fail }}"
237+
tests_error="${{ fromJSON( steps.test.outputs.json ).stats.tests_error }}"
238+
229239
case "${conclusion}" in
230240
success)
231241
color="31c653"
242+
conclusion_suite_text="${conclusion}"
243+
conclusion_test_text="${conclusion}"
244+
conclusion_run_text="${conclusion}"
232245
;;
233246
failure)
234247
color="800000"
248+
conclusion_suite_text="${conclusion}"
249+
conclusion_test_text="${conclusion} (${tests_error})"
250+
conclusion_run_text="${conclusion} (${runs_error})"
235251
;;
236252
neutral)
237253
color="696969"
254+
conclusion_suite_text="${conclusion}"
255+
conclusion_test_text="${conclusion}"
256+
conclusion_run_text="${conclusion}"
238257
;;
239258
esac
240259
241-
num_suites="${{ fromJSON( steps.test.outputs.json ).stats.suites }}"
242-
num_tests="${{ fromJSON( steps.test.outputs.json ).stats.tests }}"
243-
num_runs="${{ fromJSON( steps.test.outputs.json ).stats.runs }}"
244-
num_tests_skip="${{ fromJSON( steps.test.outputs.json ).stats.tests_skip }}"
245-
num_runs_skip="${{ fromJSON( steps.test.outputs.json ).stats.runs_skip }}"
246260
cat << EOF >> $GITHUB_OUTPUT
247261
color=${color}
248-
badge_text=${num_suites} suites / $(printf "%'d" ${num_tests}) tests ($(printf "%'d" ${num_tests_skip}) skipped) / $(printf "%'d" ${num_runs}) executions ($(printf "%'d" ${num_runs_skip}) skipped): ${conclusion}
262+
suites_badge_text=${num_suites}: ${conclusion_suite_text}
263+
tests_badge_text=$(printf "%'d" ${num_tests}) ($(printf "%'d" ${num_tests_skip}) skipped): ${conclusion_test_text}
264+
runs_badge_text=$(printf "%'d" ${num_runs}) ($(printf "%'d" ${num_runs_skip}) skipped): ${conclusion_run_text}
249265
EOF
250266
251-
- name: Create badge
267+
- name: Create suites badge
268+
uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1
269+
with:
270+
label: Suites
271+
status: '${{ steps.badgeprops.outputs.suites_badge_text }}'
272+
color: ${{ steps.badgeprops.outputs.color }}
273+
path: vxsort-suites-badge.svg
274+
275+
- name: Create tests badge
252276
uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1
253277
with:
254278
label: Tests
255-
status: '${{ steps.badgeprops.outputs.badge_text }}'
279+
status: '${{ steps.badgeprops.outputs.tests_badge_text }}'
280+
color: ${{ steps.badgeprops.outputs.color }}
281+
path: vxsort-tests-badge.svg
282+
283+
- name: Create runs badge
284+
uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1
285+
with:
286+
label: Executions
287+
status: '${{ steps.badgeprops.outputs.runs_badge_text }}'
256288
color: ${{ steps.badgeprops.outputs.color }}
257-
path: vxsort-test-badge.svg
289+
path: vxsort-runs-badge.svg
290+
291+
- name: Upload suites badge to Gist
292+
# Upload only for master branch
293+
if: >
294+
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'master' ||
295+
github.event_name != 'workflow_run' && github.ref == 'refs/heads/master'
296+
uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d
297+
with:
298+
token: ${{ secrets.GIST_TOKEN }}
299+
gistURL: https://gist.githubusercontent.com/damageboy/dfd9d01f2c710f96b444532b92539321
300+
file: vxsort-suites-badge.svg
258301

259-
- name: Upload badge to Gist
302+
- name: Upload tests badge to Gist
260303
# Upload only for master branch
261304
if: >
262305
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'master' ||
@@ -265,5 +308,15 @@ jobs:
265308
with:
266309
token: ${{ secrets.GIST_TOKEN }}
267310
gistURL: https://gist.githubusercontent.com/damageboy/dfd9d01f2c710f96b444532b92539321
268-
file: vxsort-test-badge.svg
311+
file: vxsort-tests-badge.svg
269312

313+
- name: Upload runs badge to Gist
314+
# Upload only for master branch
315+
if: >
316+
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'master' ||
317+
github.event_name != 'workflow_run' && github.ref == 'refs/heads/master'
318+
uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d
319+
with:
320+
token: ${{ secrets.GIST_TOKEN }}
321+
gistURL: https://gist.githubusercontent.com/damageboy/dfd9d01f2c710f96b444532b92539321
322+
file: vxsort-runs-badge.svg

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# vxsort-cpp
22

33
[![Build and Test](https://github.com/damageboy/vxsort-cpp/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/damageboy/vxsort-cpp/actions/workflows/build-and-test.yml)
4-
![Latest Test Status](https://gist.githubusercontent.com/damageboy/dfd9d01f2c710f96b444532b92539321/raw/vxsort-test-badge.svg)
4+
![Latest Test Status](https://gist.githubusercontent.com/damageboy/dfd9d01f2c710f96b444532b92539321/raw/vxsort-suites-badge.svg)
5+
![Latest Test Status](https://gist.githubusercontent.com/damageboy/dfd9d01f2c710f96b444532b92539321/raw/vxsort-tests-badge.svg)
6+
![Latest Test Status](https://gist.githubusercontent.com/damageboy/dfd9d01f2c710f96b444532b92539321/raw/vxsort-runs-badge.svg)
57

68
## What
79

0 commit comments

Comments
 (0)