2020-05-19 21:00:21 +08:00
# GitHub Action: Process maven surefire reports
2020-05-20 05:16:20 +08:00

2020-05-19 21:00:21 +08:00
This action processes maven surefire or failsafe XML reports on pull requests and shows the result as a PR check with summary and annotations.

## Inputs
### `report_paths`
Optional. [Glob ](https://github.com/actions/toolkit/tree/master/packages/glob ) expression to surefire or failsafe report paths. The default is `**/surefire-reports/TEST-*.xml` .
2022-12-27 02:37:04 +08:00
### `create_check`
Optional. Set to `false` to add annotations to the current job where this action is being executed. The default is `true` .
2020-05-19 21:00:21 +08:00
### `check_name`
Optional. Check name to use when creating a check run. The default is `Test Report` .
2020-08-15 16:43:48 +08:00
### `commit`
Optional. The commit sha to update the status. This is useful when you run it with `workflow_run` .
2020-10-16 16:08:30 +08:00
### `fail_on_test_failures`
Optional. Check will fail if there are test failures. The default is `false` .
### `fail_if_no_tests`
Optional. Check will fail if no tests were found. The default is `true` .
2021-05-26 19:25:22 +08:00
### `skip_publishing`
Optional. Skip the test report publishing (check run creation). The default is `false` .
2021-03-24 16:05:21 +08:00
### `github_token`
Optional. Usually in form of `github_token: ${{ secrets.GITHUB_TOKEN }}` . The default is `${{ github.token }}` .
2022-12-28 14:58:33 +08:00
### `file_name_in_stack_trace`
Optional. Set to `true` to get the file name from the stack trace. The default is `false` .
2023-02-17 01:51:04 +08:00
### `github_base_url`
Optional: If you use GitHub Enterprise, you can set this to the URL of your server (e.g. https://github.myorg.com/api/v3).
2020-05-19 21:00:21 +08:00
## Example usage
```yml
name: build
on:
pull_request:
jobs:
build:
name: Build and Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v1
- name: Build and Run Tests
2021-02-04 17:39:41 +08:00
run: mvn test --batch-mode --fail-at-end
2020-05-19 21:00:21 +08:00
- name: Publish Test Report
2023-02-10 16:50:37 +08:00
if: success() || failure()
2020-05-19 21:00:21 +08:00
uses: scacap/action-surefire-report@v1
2020-07-11 04:30:06 +08:00
```
## Tips for Gradle
2020-08-20 16:47:17 +08:00
As Gradle uses a different build directory than Maven by default, you might need to set the `report_paths` variable:
```yaml
report_paths: '**/build/test-results/test/TEST-*.xml'
2020-07-11 04:30:06 +08:00
```
2020-08-20 16:47:17 +08:00
You also need to enable JUnit XML reports as shown below.
```groovy
test {
reports {
junitXml.enabled = true
}
2020-07-11 04:30:06 +08:00
}
```