Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Dorner committed Feb 18, 2021
1 parent 3340176 commit 577cc33
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 10 deletions.
71 changes: 63 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ This [Github Action](https://github.com/features/actions) displays test results

✔️ Provides final `conclusion` and counts of `passed`, `failed` and `skipped` tests as output parameters


**How it looks:**
|![](assets/fluent-validation-report.png)|![](assets/provider-error-summary.png)|![](assets/provider-error-details.png)|![](assets/provider-groups.png)|
|:--:|:--:|:--:|:--:|
Expand All @@ -21,15 +20,18 @@ This [Github Action](https://github.com/features/actions) displays test results

For more information see [Supported formats](#supported-formats) section.

**Support is planned for:**
- Java / [JUnit 5](https://junit.org/junit5/)

Do you miss support for your favorite language or framework?
Please create [Issue](https://github.com/dorny/test-reporter/issues/new) or contribute with PR.

## Example

Following setup does not work in workflows triggered by pull request from forked repository.
If that's fine for you, using this action is as simple as:

```yaml
on:
pull_request:
push:
jobs:
build-test:
name: Build & Test
Expand All @@ -44,8 +46,52 @@ jobs:
if: success() || failure() # run this step even if previous step failed
with:
name: JEST Tests # Name of the check run which will be created
path: reports/jest-*.xml # Path to test report
reporter: jest-junit # Format of test report
path: reports/jest-*.xml # Path to test results
reporter: jest-junit # Format of test results
```
## Recommended setup for public repositories
Workflows triggered by pull requests from forked repositories are executed with read-only token and therefore can't create check runs.
To workaround this security restriction it's required to use two separate workflows:
- `CI` runs in the context of PR head branch with read-only token. It executes the tests and uploads test results as build artifact
- `Test Report` runs in the context of repository main branch with read/write token. It will download test results and create reports

**PR head branch:** *.github/workflows/ci.yml*
```yaml
name: 'CI'
on:
pull_request:
jobs:
build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 # checkout the repo
- run: npm ci # install packages
- run: npm test # run tests (configured to use jest-junit reporter)
- uses: actions/upload-artifact@v2 # upload test results
with:
name: test-results
path: jest-junit.xml
```
**default branch:** *.github/workflows/test-report.yml*
```yaml
name: 'Test Report'
on:
workflow_run:
workflows: ['CI'] # runs after CI workflow
types:
- completed
jobs:
report:
runs-on: ubuntu-latest
steps:
- uses: dorny/test-reporter@v1
with:
artifact: test-results # artifact name
name: JEST Tests # Name of the check run which will be created
path: '*.xml' # Path to test results (inside artifact .zip)
reporter: jest-junit # Format of test results
```

## Usage
Expand All @@ -54,15 +100,24 @@ jobs:
- uses: dorny/test-reporter@v1
with:
# Name or regex of artifact containing test results
# Regular expression must be enclosed in '/'.
# Values from captured groups will replace occurrences of $N in report name.
# Example:
# artifact: /test-results-(.*)/
# name: 'Test report $1'
# -> Artifact 'test-result-ubuntu' would create report 'Test report ubuntu'
artifact: ''
# Name of the Check Run which will be created
name: ''
# Coma separated list of paths to test reports
# Coma separated list of paths to test results
# Supports wildcards via [fast-glob](https://github.com/mrmlnc/fast-glob)
# All matched result files must be of same format
path: ''
# Format of test report. Supported options:
# Format of test results. Supported options:
# dart-json
# dotnet-trx
# flutter-json
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ inputs:
required: true
path:
description: |
Coma separated list of paths to test reports
Coma separated list of paths to test results
Supports wildcards via [fast-glob](https://github.com/mrmlnc/fast-glob)
All matched result files must be of same format
required: true
reporter:
description: |
Format of test report. Supported options:
Format of test results. Supported options:
- dart-json
- dotnet-trx
- flutter-json
Expand Down

0 comments on commit 577cc33

Please sign in to comment.