Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report unit test results via GitHub Actions #1370

Merged
merged 2 commits into from
Jun 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ jobs:
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
# We need multiple builds to run even if the 1st one is failing, because
# test failures may be OS-specific (or the tests themselves flaky).
fail-fast: false
matrix:
os: [ windows-latest, macos-latest ]
steps:
Expand Down Expand Up @@ -147,10 +150,71 @@ jobs:
mvn -B -T1C clean install
shell: cmd

# This step needs a Git repository, so it's impossible to extract it
# into a separate job (or, otherwise, we'd need to upload the content
# of the whole `.git` folder as an artifact).
- name: JUnit Tests (dorny/test-reporter@v1)
uses: dorny/test-reporter@v1
petertrr marked this conversation as resolved.
Show resolved Hide resolved
if: ${{ always() }}
with:
name: JUnit Tests (${{ runner.os }}, dorny/test-reporter@v1)
# Comma-separated values.
path: "**/target/*-reports/TEST-*.xml, **/build/test-results/*/TEST-*.xml"
reporter: java-junit

- name: Upload test results
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: xml-test-reports-${{ runner.os }}
path: |
**/target/*-reports/TEST-*.xml
**/build/test-results/*/TEST-*.xml
retention-days: 1

- name: Upload gradle reports
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: gradle-test-report-${{ matrix.os }}
path: 'diktat-gradle-plugin/build/reports/'
retention-days: 1

report:
name: Publish JUnit test results
if: ${{ always() }}
needs: build_and_test
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ windows-latest, macos-latest ]
petertrr marked this conversation as resolved.
Show resolved Hide resolved

permissions:
checks: write
pull-requests: write

steps:
- uses: actions/download-artifact@v3
if: ${{ always() }}
with:
name: xml-test-reports-${{ runner.os }}

# Uses Docker, that's why Linux-only.
- name: JUnit Tests (EnricoMi/publish-unit-test-result-action@v1, Linux)
uses: EnricoMi/publish-unit-test-result-action@v1
if: ${{ runner.os == 'Linux' }}
with:
check_name: JUnit Tests (${{ runner.os }}, EnricoMi/publish-unit-test-result-action@v1)
files: |
**/target/*-reports/TEST-*.xml
**/build/test-results/*/TEST-*.xml

- name: JUnit Tests (EnricoMi/publish-unit-test-result-action@v1, Windows or Mac OS X)
uses: EnricoMi/publish-unit-test-result-action/composite@v1
if: ${{ runner.os == 'Windows' || runner.os == 'macOS' }}
with:
check_name: JUnit Tests (${{ runner.os }}, EnricoMi/publish-unit-test-result-action@v1)
files: |
**/target/*-reports/TEST-*.xml
**/build/test-results/*/TEST-*.xml