Skip to content

Commit 8f02e0d

Browse files
committed
test-summary action examples for various languages
Examples for various languages and test frameworks for using the [test-summary action](https://github.com/test-summary/examples).
0 parents  commit 8f02e0d

38 files changed

+18441
-0
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.github/workflows/examples.yml

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Examples
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
12+
# This runs C tests using the Clar test framework
13+
c-clar:
14+
name: C / Clar
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Check out repository
19+
uses: actions/checkout@v3
20+
- name: Build and test
21+
run: |
22+
make
23+
./test -rresults/tests.xml
24+
working-directory: c-clar
25+
- name: Create test summary
26+
uses: test-summary/action@dist
27+
with:
28+
paths: c-clar/results/**/*.xml
29+
output: c-clar/results/test-summary.md
30+
if: always()
31+
- name: Upload test summary
32+
uses: actions/upload-artifact@v3
33+
with:
34+
name: c-clar
35+
path: c-clar/results/test-summary.md
36+
if: always()
37+
38+
# This runs .NET tests using the standard .NET test driver
39+
dotnet:
40+
name: .NET
41+
runs-on: ubuntu-latest
42+
43+
steps:
44+
- name: Check out repository
45+
uses: actions/checkout@v3
46+
- name: Build and test
47+
run: |
48+
dotnet build
49+
dotnet test --logger "junit;LogFilePath=results/tests.xml"
50+
working-directory: dotnet
51+
- name: Create test summary
52+
uses: test-summary/action@dist
53+
with:
54+
paths: dotnet/results/**/*.xml
55+
output: dotnet/results/test-summary.md
56+
if: always()
57+
- name: Upload test summary
58+
uses: actions/upload-artifact@v3
59+
with:
60+
name: dotnet
61+
path: dotnet/results/test-summary.md
62+
if: always()
63+
64+
# This runs Java tests using the JUnit test framework
65+
java-junit:
66+
name: Java / JUint
67+
runs-on: ubuntu-latest
68+
69+
steps:
70+
- name: Check out repository
71+
uses: actions/checkout@v3
72+
- name: Build and test
73+
run: |
74+
ant
75+
working-directory: java-junit
76+
- name: Create test summary
77+
uses: test-summary/action@dist
78+
with:
79+
paths: java-junit/results/**/*.xml
80+
output: java-junit/results/test-summary.md
81+
if: always()
82+
- name: Upload test summary
83+
uses: actions/upload-artifact@v3
84+
with:
85+
name: java-junit
86+
path: java-junit/results/test-summary.md
87+
if: always()
88+
89+
# This runs JavaScript tests using the Mocha test framework
90+
javascript-mocha:
91+
name: JavaScript / Mocha
92+
runs-on: ubuntu-latest
93+
94+
steps:
95+
- name: Check out repository
96+
uses: actions/checkout@v3
97+
- name: Build and test
98+
run: |
99+
npm ci
100+
npm run test
101+
working-directory: javascript-mocha
102+
- name: Create test summary
103+
uses: test-summary/action@dist
104+
with:
105+
paths: javascript-mocha/results/**/*.xml
106+
output: javascript-mocha/results/test-summary.md
107+
if: always()
108+
- name: Upload test summary
109+
uses: actions/upload-artifact@v3
110+
with:
111+
name: javascript-mocha
112+
path: javascript-mocha/results/test-summary.md
113+
if: always()
114+
115+
# This runs JavaScript tests using the Node-Tap test framework
116+
javascript-tap:
117+
name: JavaScript / Node-Tap
118+
runs-on: ubuntu-latest
119+
120+
steps:
121+
- name: Check out repository
122+
uses: actions/checkout@v3
123+
- name: Build and test
124+
run: |
125+
npm ci
126+
npm run test
127+
working-directory: javascript-tap
128+
- name: Create test summary
129+
uses: test-summary/action@dist
130+
with:
131+
paths: javascript-tap/results/**/*.tap
132+
output: javascript-tap/results/test-summary.md
133+
if: always()
134+
- name: Upload test summary
135+
uses: actions/upload-artifact@v3
136+
with:
137+
name: javascript-tap
138+
path: javascript-tap/results/test-summary.md
139+
if: always()

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
test-summary examples
2+
=====================
3+
![Test dashboard: 4 tests passed, 4 tests failed, 2 tests skipped](http://svg.test-summary.com/dashboard.svg?p=4&f=4&s=2)
4+
5+
Some example projects to show how to emit test output in various types of projects, and create a test summary to add to your GitHub Actions workflow.
6+
7+
Examples:
8+
9+
* [C with the Clar test framework](c-clar/)
10+
* [Java with the JUnit test framework](java-junit/)
11+
* [JavaScript with the mocha test framework](javascript-mocha/)
12+
* [JavaScript with the node-tap test framework](javascript-tap/)
13+
* [.NET](dotnet/)
14+
15+
For more information about how to configure the test-summary action, visit the [test-summary action](https://github.com/test-summary/action) repository.

c-clar/.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.o
2+
example
3+
clar.suite
4+
.clarcache
5+
results/
6+
test

c-clar/Makefile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
SRCS=clar.c test.c
2+
OBJS=$(SRCS:.c=.o)
3+
CFLAGS=-g -I. -Wall -Wextra -Werror -Wno-unused-function
4+
5+
.PHONY: clean
6+
7+
all: test
8+
9+
.c.o:
10+
${CC} ${CFLAGS} -c $<
11+
12+
clar.suite: test.c
13+
python generate.py
14+
15+
clar.c: clar.suite .clarcache
16+
17+
test: $(OBJS)
18+
$(CC) $(CFLAGS) -o $@ $(OBJS)
19+
20+
clean:
21+
$(RM) $(OBJS) test .clarcache clar.suite

c-clar/README.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
test-summary example: C with Clar
2+
=================================
3+
4+
This produces a test summary for a C project using the [Clar test framework](https://github.com/clar-test/clar).
5+
6+
GitHub Actions Workflow
7+
-----------------------
8+
9+
An example GitHub Actions workflow that builds a C project, runs the clar tests, runs the test-summary action and uploads the test summary markdown as an artifact.
10+
11+
```yaml
12+
name: Build and Test .NET Core
13+
14+
on:
15+
push:
16+
branches: [ main ]
17+
pull_request:
18+
branches: [ main ]
19+
workflow_dispatch:
20+
21+
jobs:
22+
build:
23+
name: Build and Test
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Check out repository
28+
uses: actions/checkout@v3
29+
- name: Build and test
30+
run: |
31+
make
32+
./test -rresults/tests.xml
33+
- name: Create test summary
34+
uses: test-summary/action@dist
35+
with:
36+
paths: results/**/*.xml
37+
output: results/test-summary.md
38+
if: always()
39+
- name: Upload test summary
40+
uses: actions/upload-artifact@v3
41+
with:
42+
name: test-summary
43+
path: results/test-summary.md
44+
if: always()
45+
```

0 commit comments

Comments
 (0)