-
Notifications
You must be signed in to change notification settings - Fork 2
59 lines (49 loc) · 1.6 KB
/
test-status.yml
File metadata and controls
59 lines (49 loc) · 1.6 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
57
58
59
name: Test Status
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test-summary:
name: Test Summary
runs-on: ubuntu-latest
if: always()
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Run tests and generate summary
run: |
echo "# Test Results Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Run tests and capture output
if go test -v ./... > test_output.log 2>&1; then
echo "All tests passed." >> $GITHUB_STEP_SUMMARY
else
echo "Some tests failed." >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Test Coverage" >> $GITHUB_STEP_SUMMARY
# Generate coverage
go test -coverprofile=coverage.out ./... > /dev/null 2>&1
if [ -f coverage.out ]; then
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}')
echo "Total Coverage: **$COVERAGE**" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Test Output" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
tail -20 test_output.log >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
- name: Set test status
run: |
if go test ./... > /dev/null 2>&1; then
echo "TEST_STATUS=PASSING" >> $GITHUB_ENV
else
echo "TEST_STATUS=FAILING" >> $GITHUB_ENV
exit 1
fi