CI: improve tests reporting (extract failed tests + uncaught tracebacks)

This commit is contained in:
0penBrain
2023-02-16 16:47:38 +01:00
committed by Chris Hennes
parent 3a6c9ffc69
commit a69f656c61

View File

@@ -48,17 +48,32 @@ runs:
shell: bash
if: always()
run: |
sed -ne "/^FAIL[[:alpha:]]*:/,/^[[:blank:]]*$/bF; /^Traceback/,/^[^[:blank:]]/{/^Traceback/bT; /^[^[:blank:]]/G; bT}; b; :T w ${{ inputs.logFile }}_tracebacks" -e "b; :F w ${{ inputs.logFile }}_failedtests" ${{ inputs.logFile }}
icon=""
if [ $( cat ${{ inputs.logFile }}_tracebacks | wc -l ) -gt 0 ]
then
icon=" :fire:"
fi
if [ ${{ steps.runTests.outcome }} == 'success' ]
then
echo "<details><summary>:heavy_check_mark: ${{ inputs.testDescription }} succeeded</summary>" >> ${{ inputs.reportFile}}
echo "<details><summary>:heavy_check_mark: ${{ inputs.testDescription }} succeeded$icon</summary>" >> ${{ inputs.reportFile }}
else
echo "<details><summary>:fire: ${{ inputs.testDescription }} failed</summary>" >> ${{ inputs.reportFile}}
echo "<details><summary>:fire: ${{ inputs.testDescription }} failed$icon</summary>" >> ${{ inputs.reportFile }}
echo "" >> ${{ inputs.reportFile }}
echo "Failed tests" >> ${{ inputs.reportFile }}
echo "" >> ${{ inputs.reportFile }}
echo '```' >> ${{ inputs.reportFile }}
cat ${{ inputs.logFile }}_failedtests >> ${{ inputs.reportFile }}
echo '```' >> ${{ inputs.reportFile }}
fi
echo "" >> ${{ inputs.reportFile}}
echo "Below is presented only the 20 last lines of the test log" >> ${{ inputs.reportFile}}
echo "" >> ${{ inputs.reportFile}}
echo '```' >> ${{ inputs.reportFile}}
cat ${{ inputs.logFile }} | tail -n 20 >> ${{ inputs.reportFile}}
echo '```' >> ${{ inputs.reportFile}}
echo "</details>">> ${{ inputs.reportFile}}
echo "" >> ${{ inputs.reportFile}}
echo "" >> ${{ inputs.reportFile }}
if [ $( cat ${{ inputs.logFile }}_tracebacks | wc -l ) -gt 0 ]
then
echo "Uncaught tracebacks -- these tracebacks appeared during test but didn't fail a test --" >> ${{ inputs.reportFile }}
echo "" >> ${{ inputs.reportFile }}
echo '```' >> ${{ inputs.reportFile }}
cat ${{ inputs.logFile }}_tracebacks >> ${{ inputs.reportFile }}
echo '```' >> ${{ inputs.reportFile }}
fi
echo "</details>">> ${{ inputs.reportFile }}
echo "" >> ${{ inputs.reportFile }}