From bf7f13fd80c25a6f025a4a2012b2263e8fe36871 Mon Sep 17 00:00:00 2001 From: Jisu Kim <108998071+jisu15-kim@users.noreply.github.com> Date: Sun, 15 Sep 2024 20:22:21 +0900 Subject: [PATCH] [Infra] Github Action Report --- .github/workflows/unitTest.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/unitTest.yml b/.github/workflows/unitTest.yml index 43d0036..332cedc 100644 --- a/.github/workflows/unitTest.yml +++ b/.github/workflows/unitTest.yml @@ -24,3 +24,24 @@ jobs: run: | xcodebuild test -scheme three-days-UnitTest -destination 'platform=iOS Simulator,name=iPhone 15,OS=latest' | tee result.log continue-on-error: true + - 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) + FAILED_TEST_NAMES=$(grep -oE '^[[:space:]]+[0-9]+\) (.*)' result.log | awk '{$1=""; print $0}') + + echo "TOTAL_TESTS=$TOTAL_TESTS" >> $GITHUB_ENV + echo "FAILED_TESTS=$FAILED_TESTS" >> $GITHUB_ENV + echo "FAILED_TEST_NAMES=$FAILED_TEST_NAMES" >> $GITHUB_ENV + - name: Notify Discord + uses: th0th/notify-discord@v0.4.1 + if: ${{ always() }} + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} + GITHUB_ACTOR: ${{ github.actor }} + GITHUB_JOB_NAME: "Unit Test Results" + GITHUB_JOB_STATUS: ${{ job.status }} + MESSAGE: | + Total tests: ${{ env.TOTAL_TESTS }}. Failed tests: ${{ env.FAILED_TESTS }}. + Failed test names: ${{ env.FAILED_TEST_NAMES }}