Skip to content

Commit

Permalink
[Infra] Unit Test Report
Browse files Browse the repository at this point in the history
  • Loading branch information
jisu15-kim authored Sep 15, 2024
1 parent dce1329 commit ce5c8cc
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/unitTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ jobs:
- name: Parse test results
id: parse_test_results
run: |
TOTAL_TESTS=$(grep -oE 'Test Suite .* executed ([0-9]+) tests' result.log | grep -oE '[0-9]+' | head -n 1)
FAILED_TESTS=$(grep -oE 'Failing tests:.*' -A 20 result.log | grep -oE '[0-9]+' | head -n 1)
TOTAL_TESTS=$(grep -oE 'Test Suite .* Executed ([0-9]+) tests' result.log | grep -oE '[0-9]+' | head -n 1)
FAILED_TESTS=$(grep -oE 'Executed [0-9]+ tests, with ([0-9]+) failures' result.log | grep -oE '[0-9]+' | head -n 1)
FAILED_TEST_NAMES=$(grep -oE '^[[:space:]]+[0-9]+\) (.*)' result.log | awk '{$1=""; print $0}')
echo "Total tests: $TOTAL_TESTS"
echo "Failed tests: $FAILED_TESTS"
echo "Failed test names: $FAILED_TEST_NAMES"

echo "TOTAL_TESTS=$TOTAL_TESTS" >> $GITHUB_ENV
echo "FAILED_TESTS=$FAILED_TESTS" >> $GITHUB_ENV
echo "FAILED_TEST_NAMES=$FAILED_TEST_NAMES" >> $GITHUB_ENV
Expand All @@ -45,11 +45,16 @@ jobs:
if: ${{ always() }}
run: |
if [ "${{ env.FAILED_TESTS }}" -eq "0" ]; then
MESSAGE="All tests passed! Total tests: ${{ env.TOTAL_TESTS }}"
# 성공 시
MESSAGE="iOS Unit Test Passed!\n- Total ${{ env.TOTAL_TESTS }} tests executed, all passed."
COLOR=5814783
else
MESSAGE="Some tests failed. Total tests: ${{ env.TOTAL_TESTS }}, Failed tests: ${{ env.FAILED_TESTS }}. Failed tests: ${{ env.FAILED_TEST_NAMES }}"
# 실패 시
MESSAGE="iOS Unit Test Failed.. (dev)\n- Total ${{ env.TOTAL_TESTS }} tests executed, ${{ env.FAILED_TESTS }} failed.\n\nFailed tests:\n${{ env.FAILED_TEST_NAMES }}"
COLOR=16711741
fi
curl -H "Content-Type: application/json" \
-d "{\"content\": \"$MESSAGE\"}" \
-X POST ${{ secrets.DISCORD_WEBHOOK_URL }}
-X POST \
-d "{\"content\": null, \"embeds\": [{\"title\": \"${MESSAGE}\", \"color\": ${COLOR}}]}" \
${{ secrets.DISCORD_WEBHOOK_URL }}

0 comments on commit ce5c8cc

Please sign in to comment.