Skip to content

Commit

Permalink
chore: support go-junit-report (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaiszaher authored Dec 28, 2022
1 parent 25872e3 commit 522da11
Show file tree
Hide file tree
Showing 12 changed files with 1,945 additions and 1,791 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,32 @@ jobs:
java-version: 8
distribution: 'zulu'
- run: cd tests && mvn clean test --batch-mode -Dmaven.test.failure.ignore=true
- uses: scacap/action-surefire-report@master
- uses: ./
if: github.ref != 'refs/heads/master'
with:
check_name: Example Surefire Test Report
- uses: cclauss/GitHub-Action-for-pytest@0.5.0
with:
args: pytest --junit-xml=python/report.xml python/ || exit 0
- uses: scacap/action-surefire-report@master
- uses: ./
if: github.ref != 'refs/heads/master'
with:
check_name: Example Pytest Report
report_paths: python/report.xml
- uses: actions/setup-go@v3
with:
go-version: 1.18.x
- run: |
cd go &&
go install github.com/jstemmer/go-junit-report/v2@latest &&
go test -v 2>&1 ./... |
go-junit-report -out report.xml
- uses: ./
if: github.ref != 'refs/heads/master'
with:
check_name: Example Go Report
report_paths: go/report.xml
file_name_in_stack_trace: true
- uses: actions/setup-node@v3
with:
node-version: 16
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ Optional. Skip the test report publishing (check run creation). The default is `

Optional. Usually in form of `github_token: ${{ secrets.GITHUB_TOKEN }}`. The default is `${{ github.token }}`.

### `file_name_in_stack_trace`

Optional. Set to `true` to get the file name from the stack trace. The default is `false`.

## Example usage

```yml
Expand Down
3 changes: 2 additions & 1 deletion action.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ const action = async () => {
const failOnFailedTests = core.getInput('fail_on_test_failures') === 'true';
const failIfNoTests = core.getInput('fail_if_no_tests') === 'true';
const skipPublishing = core.getInput('skip_publishing') === 'true';
const isFilenameInStackTrace = core.getInput('file_name_in_stack_trace') === 'true';

let { count, skipped, annotations } = await parseTestReports(reportPaths);
let { count, skipped, annotations } = await parseTestReports(reportPaths, isFilenameInStackTrace);
const foundResults = count > 0 || skipped > 0;
const conclusion =
(foundResults && annotations.length === 0) || (!foundResults && !failIfNoTests)
Expand Down
12 changes: 9 additions & 3 deletions action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ const {

jest.setTimeout(20000);

let inputs = {};
let outputs = {};
let failed = null;
let inputs;
let outputs;
let failed;

beforeEach(() => {
inputs = {};
outputs = {};
failed = null;
});

describe('action should work', () => {
beforeAll(() => {
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ inputs:
description: 'skip test report publishing'
required: false
default: 'false'
file_name_in_stack_trace:
description: 'get filename from stack trace'
required: false
default: 'false'
outputs:
outcome:
description: 'the test outcome, either `success` or `failure`'
Expand Down
Loading

0 comments on commit 522da11

Please sign in to comment.