Skip to content

Commit 6e8b8ef

Browse files
authored
Build covdata once before parallel coverage test runs (#4427)
Race Detection shard 3 failed with `go tool covdata: fork/exec .../covdata: text file busy` and exit code 123, with no test failure. With `-coverprofile`, the go command runs `go tool covdata` as a separate process for each package, several at a time. The toolchain builds covdata on demand into the build cache, and the runners start with a cold cache (`cache: false`). So one process can try to exec the binary while another is still writing it. The race shards and the sei-db race job now run `go tool -n covdata` once before testing. That builds covdata into the cache and prints its path, so every later `go tool covdata` reuses the finished binary. Flaked in: https://github.com/sei-protocol/sei-chain/actions/runs/36898544519/job/110491601182
1 parent 906f2a5 commit 6e8b8ef

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎.github/workflows/go-test.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ jobs:
6666
| awk -v n="${{ strategy.job-total }}" -v s="${{ matrix.shard }}" '(NR - 1) % n == s' > packages.txt
6767
[[ -s packages.txt ]] || { echo "shard ${{ matrix.shard }} received no packages"; exit 1; }
6868
echo "Shard ${{ matrix.shard }}/${{ strategy.job-total }}: $(wc -l < packages.txt) packages"
69+
# Build covdata into the cache once. Packages without tests run it in
70+
# parallel, and on a cold cache one run can exec it while another is
71+
# still writing it ("text file busy").
72+
go tool -n covdata > /dev/null
6973
xargs -r go test -timeout=${{ env.GO_TEST_TIMEOUT }} -coverprofile=coverage.out < packages.txt
7074
7175
- name: Upload coverage to Codecov

‎.github/workflows/sei-db-tests.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ jobs:
4949

5050
- name: Go test
5151
run: |
52+
# Build covdata into the cache once. Packages without tests run it in
53+
# parallel, and on a cold cache one run can exec it while another is
54+
# still writing it ("text file busy").
55+
go tool -n covdata > /dev/null
5256
go test \
5357
-timeout=${{ env.GO_TEST_TIMEOUT }} \
5458
-coverprofile=coverage.out \

0 commit comments

Comments
 (0)