Skip to content

Instantly share code, notes, and snippets.

@krissrex
Created July 5, 2024 08:25
Show Gist options
  • Save krissrex/2c7ee9237957ec37b1f4daf00db9932c to your computer and use it in GitHub Desktop.
Save krissrex/2c7ee9237957ec37b1f4daf00db9932c to your computer and use it in GitHub Desktop.
Maven Surefire and Failsafe errors to GitHub Actions Summary
#- name: build and test
# do mvn verify here
- name: show errors
if: ${{ failure() }}
env:
FAILS_FILE: ${{ runner.temp }}/fails.txt
run: |
echo '## Build failure ' >> $GITHUB_STEP_SUMMARY
{ find . -type f -path '*target/surefire-reports/*.txt' -exec grep -l -E '(Failures: [^0]|Errors: [^0])' {} >> "${FAILS_FILE}" \; || :; }
{ find . -type f -path '*target/failsafe-reports/*.txt' -exec grep -l -E '(Failures: [^0]|Errors: [^0])' {} >> "${FAILS_FILE}" \; || :; }
while IFS="" read -r errorFile || [ -n "$errorFile" ]; do
echo "**${errorFile}** " >> $GITHUB_STEP_SUMMARY
echo '```text' >> $GITHUB_STEP_SUMMARY
cat "${errorFile}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo '---' >> $GITHUB_STEP_SUMMARY
done < "${FAILS_FILE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment