Skip to content

ci: run tests under the race detector - #135

Merged
katbyte merged 1 commit into
mainfrom
ci/race-detector
Sep 5, 2026
Merged

katbyte merged 1 commit into
mainfrom
ci/race-detector

Conversation

@katbyte

@katbyte katbyte commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • make test now passes -race to both go test invocations. CI runs make test on every push and PR, so the race detector runs on every change.
  • The integration harness builds its tctest binary with -race, so a data race in the CLI itself surfaces as an integration test failure (the race runtime prints a report and exits non-zero, which the existing exit-code and output assertions catch).
  • Fix the one race the detector found, which was in the test harness rather than the CLI: the azurerm tests set gh.conflicted / gh.openPRs on the mock GitHub after httptest.NewServer had already spawned the handler goroutines that read them. The binary under test had not connected yet so it never misbehaved, but there is no happens-before edge through exec + TCP that the detector can see. Replaced with withConflicted / withOpenPRs constructor options applied before the server starts.

This is for the OpenSSF Best Practices badge dynamic_analysis criterion, which explicitly accepts race detectors.

Test plan

  • make test passes locally under -race (unit + integration, -count=1)
  • make lint reports 0 issues
  • Tests workflow green on this PR

Add -race to both go test invocations in `make test`, which CI runs on every push and PR, and build
the integration harness's tctest binary with -race so a data race in the CLI itself surfaces as a test
failure via the exit-code and output assertions.

The race-instrumented run immediately flagged a race in the harness: the azurerm tests set
`gh.conflicted` / `gh.openPRs` on the mock GitHub after httptest.NewServer had already spawned the
handler goroutines that read those fields. The subprocess had not connected yet, so it never misbehaved,
but there is no happens-before edge through exec + TCP that the detector can see. Replace the
post-construction writes with `withConflicted` / `withOpenPRs` options applied before the server starts.
@katbyte
katbyte merged commit a2e92c2 into main Sep 5, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant