Skip to content

Commit b190ada

Browse files
committed
feat: show badges generated from test data
1 parent fbf2932 commit b190ada

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

.github/workflows/tests.yaml

+36-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,15 @@ jobs:
3737
version: ${{ matrix.version }}
3838

3939
- name: Test Nu-Test
40-
run: "nu -c 'use nutest; nutest run-tests --fail --report { type: junit, path: test-report.xml }'"
40+
shell: nu {0}
41+
run: |
42+
nu -c 'use nutest; (
43+
nutest run-tests
44+
--fail
45+
--display terminal
46+
--report { type: junit, path: test-report.xml }
47+
--returns summary | to json | save --force test-summary.json
48+
)'
4149
4250
- name: Publish Test Results
4351
uses: EnricoMi/publish-unit-test-result-action@v2
@@ -57,6 +65,33 @@ jobs:
5765
with:
5866
files: test-report.xml
5967

68+
- name: Publish Test Summary
69+
if: runner.os == 'Linux' && matrix.version == '*' && github.ref == 'refs/heads/main'
70+
shell: nu {0}
71+
run: |
72+
let gist_id = "0cbdca67f966d7ea2e6e1eaf7c9083a3"
73+
let filename = "test-summary.json"
74+
75+
let data = {
76+
files: {
77+
"test-summary.json": {
78+
content: (open --raw $filename)
79+
}
80+
}
81+
}
82+
83+
(
84+
$data | http patch
85+
--redirect-mode "follow"
86+
--content-type "application/json"
87+
--headers {
88+
"Authorization": $"Bearer ${{ secrets.GIST_TOKEN }}"
89+
"Accept": "application/vnd.github+json"
90+
"X-GitHub-Api-Version": "2022-11-28"
91+
}
92+
$"https://api.github.com/gists/($gist_id)"
93+
) | ignore
94+
6095
nushell-tests:
6196
name: Run Nushell Tests
6297

PLAN.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111

1212
## Milestone: Version 1.0
1313

14-
- Get Topiary Nushell formatting working as commit hook (if it's readable)
15-
- JUnit test reports:
16-
- Add [a badge](https://github.com/EnricoMi/publish-unit-test-result-action/?tab=readme-ov-file#create-a-badge-from-test-results) for test results in CI serving as an example
14+
- Use step outputs for file references
1715
- Versioning strategy, labels and docs/automation
1816
- Basic contributor agreement if needed
1917

2018
## Post v1 Roadmap
2119

20+
- Get Topiary Nushell formatting working as commit hook (if it's readable)
2221
- JUnit test reports:
2322
- Add error information into the expected JUnit failure elements
2423
- Add test output

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Nu-test
22

3+
![CI/CD](https://github.com/vyadh/nu-test/actions/workflows/tests.yaml/badge.svg)
4+
![Tests](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgist.githubusercontent.com%2Fvyadh%2F0cbdca67f966d7ea2e6e1eaf7c9083a3%2Fraw%2Ftest-summary.json&query=%24.total&label=Tests)
5+
![Passed](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgist.githubusercontent.com%2Fvyadh%2F0cbdca67f966d7ea2e6e1eaf7c9083a3%2Fraw%2Ftest-summary.json&query=%24.passed&label=Passed&color=%2331c654)
6+
![Failed](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgist.githubusercontent.com%2Fvyadh%2F0cbdca67f966d7ea2e6e1eaf7c9083a3%2Fraw%2Ftest-summary.json&query=%24.failed&label=Failed&color=red)
7+
![Skipped](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fgist.githubusercontent.com%2Fvyadh%2F0cbdca67f966d7ea2e6e1eaf7c9083a3%2Fraw%2Ftest-summary.json&query=%24.skipped&label=Skipped&color=yellow)
8+
39
A [Nushell](https://www.nushell.sh) test runner.
410

511
![An example nu-test run](resources/test-run.png)

0 commit comments

Comments
 (0)