Skip to content

Commit 1501b28

Browse files
committed
CI/CD: Add badge generation and upload for test results
1 parent bf975f6 commit 1501b28

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

.github/workflows/vunit.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,46 @@ jobs:
7171
title: HDL Core Library Test Results
7272

7373
- name: Publish Test Results
74+
id: test-results
7475
uses: EnricoMi/publish-unit-test-result-action@12fa20e14d449d310778f2d0af1e3b2f57dde2a7 # v2
7576
if: always()
7677
with:
7778
files: test-reports/vunit_results.xml
7879
check_name: VUnit Test Results
7980

81+
- name: Set badge color
82+
shell: bash
83+
run: |
84+
case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in
85+
success)
86+
echo "BADGE_COLOR=31c653" >> $GITHUB_ENV
87+
;;
88+
failure)
89+
echo "BADGE_COLOR=800000" >> $GITHUB_ENV
90+
;;
91+
neutral)
92+
echo "BADGE_COLOR=696969" >> $GITHUB_ENV
93+
;;
94+
esac
95+
96+
- name: Create badge
97+
uses: emibcn/badge-action@808173dd03e2f30c980d03ee49e181626088eee8
98+
with:
99+
label: Tests
100+
status: '${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests }} tests, ${{ env.BADGE_COLOR }}'
101+
color: ${{ env.BADGE_COLOR }}
102+
path: badge.svg
103+
104+
- name: Upload badge to Gist
105+
if: >
106+
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main' ||
107+
github.event_name != 'workflow_run' && github.ref == 'refs/heads/main'
108+
uses: andymckay/append-gist-action@6e8d64427fe47cbacf4ab6b890411f1d67c07f3e
109+
with:
110+
token: ${{ secrets.GIST_TOKEN }}
111+
gistURL: https://gist.githubusercontent.com/nselvara/cc050d27587b0722b2e41f143fa9e2d5
112+
file: badge.svg
113+
80114
- name: Upload test results
81115
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
82116
if: always()

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[![GPLv3 License](https://img.shields.io/badge/License-GPL%20v3-yellow.svg)](https://opensource.org/licenses/)
22
[![VUnit Tests](https://github.com/nselvara/chipdev.io/workflows/VUnit%20Tests/badge.svg)](https://github.com/nselvara/chipdev.io/actions)
3+
[![Tests](https://gist.githubusercontent.com/nselvara/cc050d27587b0722b2e41f143fa9e2d5/raw/badge.svg)](https://github.com/nselvara/chipdev.io/actions/workflows/vunit.yml)
34

45
# ChipDev.io Quest Solutions – in VHDL-2008
56

0 commit comments

Comments
 (0)