Skip to content

Commit 701e7ac

Browse files
committed
Unit Test failures now output a job summary, listing the failure messages
1 parent c77e09d commit 701e7ac

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

.github/workflows/run_integration_tests.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
source $HOME/BYOND/byond/bin/byondsetup
6262
tools/build/build --ci dm -DCIBUILDING -DANSICOLORS -Werror
6363
- name: Run Tests
64+
id: run_tests
6465
run: |
6566
source $HOME/BYOND/byond/bin/byondsetup
6667
bash tools/ci/run_server.sh ${{ inputs.map }}
@@ -71,6 +72,29 @@ jobs:
7172
name: test_artifacts_${{ inputs.map }}_${{ inputs.major }}_${{ inputs.minor }}
7273
path: data/screenshots_new/
7374
retention-days: 1
75+
- name: On test fail, write a step summary
76+
if: always() && steps.run_tests.outcome == 'failure'
77+
run: |
78+
# Get a JSON array of failed unit tests
79+
FAILED_UNIT_TESTS=$(jq 'to_entries | map(.value | select(.status == 1))' data/unit_tests.json)
80+
81+
FAIL_COUNT=$(echo $FAILED_UNIT_TESTS | jq 'length')
82+
83+
echo "# Test failures" >> $GITHUB_STEP_SUMMARY
84+
echo "$FAIL_COUNT tests failed." >> $GITHUB_STEP_SUMMARY
85+
echo "" >> $GITHUB_STEP_SUMMARY
86+
87+
for i in $( seq $FAIL_COUNT ); do
88+
CURRENT_FAIL=$(echo $FAILED_UNIT_TESTS | jq --arg i $i '.[($i | tonumber) - 1]')
89+
90+
TEST=$(echo $CURRENT_FAIL | jq --raw-output '.name')
91+
92+
echo "### $TEST" >> $GITHUB_STEP_SUMMARY
93+
echo '```' >> $GITHUB_STEP_SUMMARY
94+
echo $CURRENT_FAIL | jq --raw-output '.message' >> $GITHUB_STEP_SUMMARY
95+
echo '```' >> $GITHUB_STEP_SUMMARY
96+
echo "" >> $GITHUB_STEP_SUMMARY
97+
done
7498
- name: Check client Compatibility
7599
if: always() && steps.compile_tests.outcome == 'success'
76100
uses: tgstation/byond-client-compatibility-check@v3

tools/ci/run_server.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ cd ..
2222

2323
mkdir -p data/screenshots_new
2424
cp -r ci_test/data/screenshots_new data/screenshots_new
25+
cp ci_test/data/unit_tests.json data/unit_tests.json
2526

2627
cat ci_test/data/logs/ci/clean_run.lk

0 commit comments

Comments
 (0)