Skip to content

Publish Test Report

Publish Test Report #1

name: Publish Test Report
on:
workflow_run:
workflows: [Test]
types: [completed]
jobs:
publish:
if: github.event.workflow_run.conclusion == 'success'
name: Publish Surefire Report
runs-on: ubuntu-latest
steps:
- name: Install xmlstarlet tool
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y xmlstarlet
# Downloading surefire report artifact containing
# zip file with reports and file
# containing commit sha
- name: Download a Build Artifact
uses: actions/[email protected]
with:
name: surefire-test-report
github-token: ${{ github.token }}
run-id: ${{ github.event.workflow_run.id }}
- name: Get github sha
id: github_sha
uses: juliangruber/read-file-action@v1
with:
path: ./github-sha.txt
- name: Remove flaky tests from failure report
if: (success() || failure())
run: |
find . -name "TEST-*Test.xml" | while read f
do
xmlstarlet ed --inplace -d "//testcase[flakyFailure]" "$f"
done
- name: Publish Test Report
if: success() || failure()
uses: ScaCap/action-surefire-report@v1
with:
commit: ${{ steps.github_sha.outputs.content }}
check_name: Test Report Result
report_paths: |
**/surefire-reports/TEST-*.xml
- name: Check test number
if: success() || failure()
id: test-number
env:
MIN_TEST_NUM: 30000
GH_TOKEN: ${{ github.token }}
run: |
COUNT=$(find . -name "TEST-*.xml" | while read f; do xmlstarlet sel -t -c "count(//testcase)" -n "$f"; done | awk '{s+=$1} END {print s}')
echo "test_count=$COUNT" >> $GITHUB_OUTPUT
echo "test_min=$MIN_TEST_NUM" >> $GITHUB_OUTPUT
- name: set-commit-status-pending
if: steps.test-number.outputs.test_count < steps.test-number.outputs.test_min
uses: myrotvorets/[email protected]
with:
status: failure
sha: ${{ steps.github_sha.outputs.content }}
context: Tests number check
description: Fail. ${{ steps.test-number.outputs.test_count }} test ran, minimum required is ${{ steps.test-number.outputs.test_min }}
targetUrl: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}