Skip to content

Commit 8f6d02e

Browse files
committed
ci: add race detection job to build workflow
Add dedicated race detection job that runs Go tests with -race flag on Linux (requires cgo). This validates thread-safety of concurrent code like the sync.Once pattern used in DefaultPaths(). - Runs on ubuntu-latest where cgo is available - Generates GitHub Actions summary with race detection results - Build jobs now depend on race detection passing - Extracts and displays race details if any are found 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent fc7a270 commit 8f6d02e

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,57 @@ jobs:
9696
fi
9797
echo "✅ go.mod and go.sum are tidy"
9898
99+
race-detection:
100+
name: Race Detection
101+
runs-on: ubuntu-latest
102+
steps:
103+
- name: Checkout code
104+
uses: actions/checkout@v4
105+
106+
- name: Set up Go
107+
uses: actions/setup-go@v5
108+
with:
109+
go-version: '1.23'
110+
111+
- name: Get dependencies
112+
run: go mod download
113+
114+
- name: Run tests with race detector
115+
run: |
116+
echo "Running tests with Go race detector enabled..."
117+
echo "This detects data races in concurrent code (requires cgo)"
118+
go test -race -v ./src/... 2>&1 | tee race-test-output.log
119+
TEST_EXIT_CODE=${PIPESTATUS[0]}
120+
exit $TEST_EXIT_CODE
121+
122+
- name: Generate race detection summary
123+
if: always()
124+
run: |
125+
echo "## Race Detection Results" >> $GITHUB_STEP_SUMMARY
126+
echo "" >> $GITHUB_STEP_SUMMARY
127+
128+
if grep -q "WARNING: DATA RACE" race-test-output.log 2>/dev/null; then
129+
echo "❌ **Data races detected!**" >> $GITHUB_STEP_SUMMARY
130+
echo "" >> $GITHUB_STEP_SUMMARY
131+
echo "### Race Details" >> $GITHUB_STEP_SUMMARY
132+
echo '```' >> $GITHUB_STEP_SUMMARY
133+
grep -A 50 "WARNING: DATA RACE" race-test-output.log >> $GITHUB_STEP_SUMMARY
134+
echo '```' >> $GITHUB_STEP_SUMMARY
135+
else
136+
echo "✅ **No data races detected**" >> $GITHUB_STEP_SUMMARY
137+
fi
138+
139+
echo "" >> $GITHUB_STEP_SUMMARY
140+
echo "<details>" >> $GITHUB_STEP_SUMMARY
141+
echo "<summary>Full Test Output</summary>" >> $GITHUB_STEP_SUMMARY
142+
echo "" >> $GITHUB_STEP_SUMMARY
143+
echo '```' >> $GITHUB_STEP_SUMMARY
144+
cat race-test-output.log >> $GITHUB_STEP_SUMMARY
145+
echo '```' >> $GITHUB_STEP_SUMMARY
146+
echo "</details>" >> $GITHUB_STEP_SUMMARY
147+
99148
build:
100-
needs: [golangci-lint, go-mod]
149+
needs: [golangci-lint, go-mod, race-detection]
101150
name: Build ${{ matrix.platform }} on ${{ matrix.os }}
102151
runs-on: ${{ matrix.os }}
103152
strategy:

0 commit comments

Comments
 (0)