-
-
Notifications
You must be signed in to change notification settings - Fork 9
56 lines (45 loc) · 1.99 KB
/
coreUnitTests.yml
File metadata and controls
56 lines (45 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Core Unit Tests
on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Install Gradle
uses: gradle/gradle-build-action@v3
- name: Run unit tests
run: gradle clean :core:test
- name: Show test summary
if: always()
run: |
echo "### Unit Test Summary" >> $GITHUB_STEP_SUMMARY
TEST_RESULTS=$(find core/build/test-results/test -name "*.xml")
# Count total tests, failures, skipped
PASSED=$(grep -o 'testsuite.*tests="[^"]*"' $TEST_RESULTS | sed -n 's/.*tests="\([0-9]*\)".*/\1/p' | awk '{s+=$1} END {print s}')
FAILURES=$(grep -o 'testsuite.*failures="[^"]*"' $TEST_RESULTS | sed -n 's/.*failures="\([0-9]*\)".*/\1/p' | awk '{s+=$1} END {print s}')
SKIPPED=$(grep -o 'testsuite.*skipped="[^"]*"' $TEST_RESULTS | sed -n 's/.*skipped="\([0-9]*\)".*/\1/p' | awk '{s+=$1} END {print s}')
echo "- ✅ Passed: $((PASSED - FAILURES - SKIPPED))" >> $GITHUB_STEP_SUMMARY
echo "- ❌ Failed: $FAILURES" >> $GITHUB_STEP_SUMMARY
echo "- ⏭️ Skipped: $SKIPPED" >> $GITHUB_STEP_SUMMARY
# Show detailed failure messages
if [ "$FAILURES" -gt 0 ]; then
echo "### ❌ Test Failures" >> $GITHUB_STEP_SUMMARY
for file in $TEST_RESULTS; do
# Extract <testcase> elements with <failure> inside
grep -Poz '<testcase[^>]*>\K.*?(?=</testcase>)' "$file" | grep -Poz '<failure[^>]*>.*?</failure>' | while read -r line; do
MSG=$(echo "$line" | sed -E 's/<failure[^>]*>(.*)<\/failure>/\1/' | tr -d '\n')
TESTNAME=$(echo "$file" | sed 's#.*/##')
echo "- $TESTNAME: $MSG" >> $GITHUB_STEP_SUMMARY
done
done
fi