2022-12-16 12:02:05 +00:00
|
|
|
name: Report flaky test
|
2022-12-19 16:22:11 +00:00
|
|
|
description: Finds flaky tests and uploads reports
|
2023-01-02 13:02:20 +00:00
|
|
|
inputs:
|
|
|
|
job-name:
|
|
|
|
description: 'Job name to help identify the job'
|
|
|
|
required: true
|
2022-12-16 12:02:05 +00:00
|
|
|
|
|
|
|
runs:
|
|
|
|
using: composite
|
|
|
|
steps:
|
|
|
|
- id: flaky-tests
|
|
|
|
name: Find flaky tests
|
|
|
|
if: github.repository == 'keycloak/keycloak'
|
|
|
|
shell: bash
|
2022-12-16 14:31:46 +00:00
|
|
|
# language=bash
|
2022-12-16 12:02:05 +00:00
|
|
|
run: |
|
2022-12-19 16:22:11 +00:00
|
|
|
FLAKES=""
|
|
|
|
SEP=""
|
2023-01-06 08:15:01 +00:00
|
|
|
for dir in $(find -type d -name 'surefire-reports*'); do
|
2023-08-23 09:57:20 +00:00
|
|
|
for i in $(grep -l -E '<flakyFailure|<flakyError' $dir/TEST-*.xml); do
|
2022-12-19 16:22:11 +00:00
|
|
|
FLAKES="$FLAKES$SEP$i"
|
|
|
|
SEP=$'\n'
|
2022-12-16 12:02:05 +00:00
|
|
|
done
|
|
|
|
done
|
2022-12-19 16:22:11 +00:00
|
|
|
|
|
|
|
if [ "$FLAKES" != "" ]; then
|
2023-01-02 13:02:20 +00:00
|
|
|
PR="${{ github.event.number }}"
|
|
|
|
JOB_NAME="${{ inputs.job-name }}"
|
|
|
|
|
|
|
|
MATRIX="${{ join(matrix.*, ' - ') }}"
|
|
|
|
if [ "$MATRIX" != "" ]; then
|
|
|
|
JOB_NAME="$JOB_NAME ($MATRIX)"
|
|
|
|
fi
|
|
|
|
|
2023-12-19 12:43:31 +00:00
|
|
|
JOB_URL=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs --paginate --jq ".jobs | map(select(.name == \"$JOB_NAME\")) | .[].html_url")
|
2023-01-02 13:02:20 +00:00
|
|
|
|
|
|
|
echo "job_name=$JOB_NAME" >> job-summary.properties
|
|
|
|
echo "job_url=$JOB_URL" >> job-summary.properties
|
|
|
|
if [ "$PR" != "" ]; then
|
|
|
|
echo "pr=$PR" >> job-summary.properties
|
|
|
|
echo "pr_url=https://github.com/${{ github.repository }}/pull/$PR" >> job-summary.properties
|
|
|
|
fi
|
|
|
|
|
2022-12-19 16:22:11 +00:00
|
|
|
echo "flakes<<EOF" >> $GITHUB_OUTPUT
|
2023-01-02 13:02:20 +00:00
|
|
|
echo "job-summary.properties" >> $GITHUB_OUTPUT
|
2022-12-19 16:22:11 +00:00
|
|
|
echo "$FLAKES" >> $GITHUB_OUTPUT
|
|
|
|
echo "EOF" >> $GITHUB_OUTPUT
|
|
|
|
fi
|
|
|
|
|
2023-12-20 18:01:16 +00:00
|
|
|
- uses: actions/upload-artifact@v3
|
2022-12-19 16:22:11 +00:00
|
|
|
if: ${{ steps.flaky-tests.outputs.flakes }}
|
|
|
|
with:
|
2023-01-02 13:02:20 +00:00
|
|
|
name: flaky-tests-${{ github.job }}-${{ join(matrix.*, '-') }}
|
2022-12-19 16:22:11 +00:00
|
|
|
path: ${{ steps.flaky-tests.outputs.flakes }}
|
2024-01-02 15:01:00 +00:00
|
|
|
if-no-files-found: error
|