-
Notifications
You must be signed in to change notification settings - Fork 2
181 lines (154 loc) · 6.35 KB
/
nightly.yml
File metadata and controls
181 lines (154 loc) · 6.35 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: Nightly
on:
schedule:
# Run daily at 2 AM UTC (same as security scans)
- cron: '0 2 * * *'
workflow_dispatch: # Allow manual triggering
permissions:
contents: read
jobs:
# =============================================================================
# Benchmark Comparison (detailed analysis against develop branch)
# =============================================================================
# This runs full benchmarks with statistical comparison against develop.
# PRs run basic benchmarks; nightly runs the full comparison.
benchmark-comparison:
name: Benchmark Comparison
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Need full history for branch comparison
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25.5'
cache: true
- name: Set up buf
uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate protobuf files
run: buf generate
- name: Download dependencies
run: go mod download
- name: Install benchstat
run: go install golang.org/x/perf/cmd/benchstat@latest
- name: Run current benchmarks
run: |
echo "Running benchmarks on current HEAD..."
go test -bench=. -benchmem -count=5 ./shared/domain/models/ ./shared/platform/audit/ > new.txt 2>&1 || true
- name: Run develop branch benchmarks
run: |
echo "Checking out develop branch for comparison..."
git stash --include-untracked || true
git checkout origin/develop -- shared/domain/models/ shared/platform/audit/ 2>/dev/null || true
echo "Running benchmarks on develop..."
go test -bench=. -benchmem -count=5 ./shared/domain/models/ ./shared/platform/audit/ > old.txt 2>&1 || true
# Restore current branch
git checkout - -- . 2>/dev/null || true
git stash pop || true
- name: Generate comparison report
run: |
echo "## Nightly Benchmark Comparison" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Comparing HEAD against develop branch" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -f old.txt ] && [ -f new.txt ]; then
echo '```' >> $GITHUB_STEP_SUMMARY
benchstat old.txt new.txt >> $GITHUB_STEP_SUMMARY 2>&1 || echo "Comparison failed" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
else
echo "Benchmark files not available for comparison" >> $GITHUB_STEP_SUMMARY
fi
# =============================================================================
# Full Integration Tests (including slow/timing-sensitive tests)
# =============================================================================
# These tests are timing-sensitive (network timeouts, exponential backoff)
# and are skipped in regular CI (via -short flag) to avoid flakiness from
# CPU scheduler variance. Running them nightly ensures they're validated.
slow-integration-tests:
name: Slow Integration Tests
runs-on: ubuntu-latest
# Note: No postgres service container needed - tests use testcontainers
# which manage their own ephemeral containers with proper isolation.
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25.5'
cache: true
- name: Set up buf
uses: bufbuild/buf-setup-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate protobuf files
run: buf generate
- name: Download dependencies
run: go mod download
- name: Run full test suite (including slow tests)
env:
SKIP_KAFKA_TESTS: "1"
# Note: No DATABASE_URL needed - tests that require a database
# use testcontainers or mock their own configuration
run: |
# Run WITHOUT -short flag to include all timing-sensitive tests
# Regular CI runs with -short, but nightly runs the full suite
echo "Running full test suite including timing-sensitive tests..."
go test -v -race -timeout 15m ./... 2>&1 | tee test-output.txt
TEST_EXIT_CODE=${PIPESTATUS[0]}
# Parse test counts
PASS_COUNT=$(grep -c "^--- PASS" test-output.txt || echo "0")
FAIL_COUNT=$(grep -c "^--- FAIL" test-output.txt || echo "0")
SKIP_COUNT=$(grep -c "^--- SKIP" test-output.txt || echo "0")
# Console output
echo ""
echo "=== Test Summary ==="
echo "Passed: $PASS_COUNT"
echo "Failed: $FAIL_COUNT"
echo "Skipped: $SKIP_COUNT"
# Write GitHub Step Summary (markdown)
{
echo "## Nightly Integration Test Results"
echo ""
if [ "$FAIL_COUNT" -gt 0 ]; then
echo "| Status | Count |"
echo "|--------|-------|"
echo "| :white_check_mark: Passed | $PASS_COUNT |"
echo "| :x: **Failed** | **$FAIL_COUNT** |"
echo "| :fast_forward: Skipped | $SKIP_COUNT |"
echo ""
echo "### Failed Tests"
echo ""
echo "| Test | Package |"
echo "|------|---------|"
# Extract failed test names and their packages
grep "^--- FAIL:" test-output.txt | while read line; do
TEST_NAME=$(echo "$line" | sed 's/^--- FAIL: //' | awk '{print $1}')
echo "| \`$TEST_NAME\` | _(see logs)_ |"
done
echo ""
echo "<details>"
echo "<summary>Error Details (click to expand)</summary>"
echo ""
echo '```'
# Show context around failures
grep -B10 "^--- FAIL" test-output.txt | grep -v "^--$" | tail -100
echo '```'
echo "</details>"
else
echo ":white_check_mark: **All tests passed!**"
echo ""
echo "| Status | Count |"
echo "|--------|-------|"
echo "| Passed | $PASS_COUNT |"
echo "| Skipped | $SKIP_COUNT |"
fi
} >> $GITHUB_STEP_SUMMARY
# Exit with original test exit code
if [ "$FAIL_COUNT" -gt 0 ]; then
exit 1
fi