Skip to content

Commit

Permalink
test-summary action examples for various languages
Browse files Browse the repository at this point in the history
Examples for various languages and test frameworks for using the
[test-summary action](https://github.com/test-summary/examples).
  • Loading branch information
ethomson committed Mar 20, 2022
0 parents commit 8f02e0d
Show file tree
Hide file tree
Showing 38 changed files with 18,441 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
139 changes: 139 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Examples

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:

# This runs C tests using the Clar test framework
c-clar:
name: C / Clar
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Build and test
run: |
make
./test -rresults/tests.xml
working-directory: c-clar
- name: Create test summary
uses: test-summary/action@dist
with:
paths: c-clar/results/**/*.xml
output: c-clar/results/test-summary.md
if: always()
- name: Upload test summary
uses: actions/upload-artifact@v3
with:
name: c-clar
path: c-clar/results/test-summary.md
if: always()

# This runs .NET tests using the standard .NET test driver
dotnet:
name: .NET
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Build and test
run: |
dotnet build
dotnet test --logger "junit;LogFilePath=results/tests.xml"
working-directory: dotnet
- name: Create test summary
uses: test-summary/action@dist
with:
paths: dotnet/results/**/*.xml
output: dotnet/results/test-summary.md
if: always()
- name: Upload test summary
uses: actions/upload-artifact@v3
with:
name: dotnet
path: dotnet/results/test-summary.md
if: always()

# This runs Java tests using the JUnit test framework
java-junit:
name: Java / JUint
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Build and test
run: |
ant
working-directory: java-junit
- name: Create test summary
uses: test-summary/action@dist
with:
paths: java-junit/results/**/*.xml
output: java-junit/results/test-summary.md
if: always()
- name: Upload test summary
uses: actions/upload-artifact@v3
with:
name: java-junit
path: java-junit/results/test-summary.md
if: always()

# This runs JavaScript tests using the Mocha test framework
javascript-mocha:
name: JavaScript / Mocha
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Build and test
run: |
npm ci
npm run test
working-directory: javascript-mocha
- name: Create test summary
uses: test-summary/action@dist
with:
paths: javascript-mocha/results/**/*.xml
output: javascript-mocha/results/test-summary.md
if: always()
- name: Upload test summary
uses: actions/upload-artifact@v3
with:
name: javascript-mocha
path: javascript-mocha/results/test-summary.md
if: always()

# This runs JavaScript tests using the Node-Tap test framework
javascript-tap:
name: JavaScript / Node-Tap
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Build and test
run: |
npm ci
npm run test
working-directory: javascript-tap
- name: Create test summary
uses: test-summary/action@dist
with:
paths: javascript-tap/results/**/*.tap
output: javascript-tap/results/test-summary.md
if: always()
- name: Upload test summary
uses: actions/upload-artifact@v3
with:
name: javascript-tap
path: javascript-tap/results/test-summary.md
if: always()
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
test-summary examples
=====================
![Test dashboard: 4 tests passed, 4 tests failed, 2 tests skipped](http://svg.test-summary.com/dashboard.svg?p=4&f=4&s=2)

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.

Examples:

* [C with the Clar test framework](c-clar/)
* [Java with the JUnit test framework](java-junit/)
* [JavaScript with the mocha test framework](javascript-mocha/)
* [JavaScript with the node-tap test framework](javascript-tap/)
* [.NET](dotnet/)

For more information about how to configure the test-summary action, visit the [test-summary action](https://github.com/test-summary/action) repository.
6 changes: 6 additions & 0 deletions c-clar/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.o
example
clar.suite
.clarcache
results/
test
21 changes: 21 additions & 0 deletions c-clar/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
SRCS=clar.c test.c
OBJS=$(SRCS:.c=.o)
CFLAGS=-g -I. -Wall -Wextra -Werror -Wno-unused-function

.PHONY: clean

all: test

.c.o:
${CC} ${CFLAGS} -c $<

clar.suite: test.c
python generate.py

clar.c: clar.suite .clarcache

test: $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS)

clean:
$(RM) $(OBJS) test .clarcache clar.suite
45 changes: 45 additions & 0 deletions c-clar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
test-summary example: C with Clar
=================================

This produces a test summary for a C project using the [Clar test framework](https://github.com/clar-test/clar).

GitHub Actions Workflow
-----------------------

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.

```yaml
name: Build and Test .NET Core

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Build and test
run: |
make
./test -rresults/tests.xml
- name: Create test summary
uses: test-summary/action@dist
with:
paths: results/**/*.xml
output: results/test-summary.md
if: always()
- name: Upload test summary
uses: actions/upload-artifact@v3
with:
name: test-summary
path: results/test-summary.md
if: always()
```
Loading

0 comments on commit 8f02e0d

Please sign in to comment.