Skip to content

fix: prevent coverage data corruption from artifact name collisions - #1116

Merged
henryiii merged 2 commits into
wntrblm:mainfrom
henryiii:fix-coverage-artifact-collision
Jun 17, 2026
Merged

henryiii merged 2 commits into
wntrblm:mainfrom
henryiii:fix-coverage-artifact-collision

Conversation

@henryiii

@henryiii henryiii commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

I hope this fixes the failure we've seen occasionally in CI after multiprocessing in the test suite.

🤖 AI text below 🤖

Problem

The coverage (combine) job intermittently fails with:

nox > coverage combine
Couldn't use data file '/home/runner/work/nox/nox/.coverage': database disk image is malformed
nox > Command coverage combine failed with exit code 1

(e.g. this run).

Cause

macos-latest (arm64) and macos-15-intel (x86_64) both run Python 3.12, and the coverage filename is built only from sys.platform + version — so both jobs produce .coverage.pypi.darwin.3.12. The cover job then downloads artifacts with merge-multiple: true, which extracts them concurrently into one directory. Two jobs writing the same path can tear the SQLite data file (→ "database disk image is malformed"), or one silently clobbers the other's coverage. The timing dependence is why it only fails occasionally; the parallel/xdist tests just made the corruption more visible, they aren't the trigger.

Fix

  • Add platform.machine() to the tests/conda coverage filenames so arm64 and x86_64 no longer collide (also restores the mac coverage that was being silently dropped).
  • Drop merge-multiple: true so each artifact lands in its own coverage-* subdirectory; the cover session now globs those subdirs and passes them to coverage combine (with a ["."] fallback for local runs).

No change to the fast test setup — xdist, the sysmon core, and run.patch=["subprocess"] are untouched. The 100% --fail-under gate is unchanged.

Verified locally that coverage combine <dir> <dir> reads data files inside per-artifact subdirs and combines cleanly.

The macos-latest (arm64) and macos-15-intel (x86_64) jobs both run Python
3.12 and both produced `.coverage.pypi.darwin.3.12`. With
`merge-multiple: true`, download-artifact extracts artifacts concurrently
into one directory, so two jobs writing the same path could tear the
SQLite data file ("database disk image is malformed") in the cover job, or
silently clobber one job's data.

Add `platform.machine()` to the coverage filenames so the architectures no
longer collide, and drop `merge-multiple` so each artifact lands in its own
`coverage-*` subdirectory; the cover session now combines those subdirs.

Assisted-by: ClaudeCode:claude-opus-4.8
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
@henryiii
henryiii force-pushed the fix-coverage-artifact-collision branch from b3ac394 to d3fcd6f Compare June 17, 2026 03:02
Comment thread noxfile.py Outdated
@henryiii
henryiii marked this pull request as ready for review June 17, 2026 03:39
@henryiii
henryiii merged commit 801d2c2 into wntrblm:main Jun 17, 2026
18 checks passed
@henryiii
henryiii deleted the fix-coverage-artifact-collision branch June 17, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant