Exempt first cibuildwheel build from ccache-hit enforcement#877
Exempt first cibuildwheel build from ccache-hit enforcement#877IvanaGyro wants to merge 1 commit into
Conversation
The first python-version wheel in a cibuildwheel run compiles the C++ sources from a cold cache, so zero ccache hits is expected there; only later versions reuse those objects and must hit the cache. Track the first build with a marker file in CCACHE_DIR (shared across the per-version build containers via the bind mount) and skip hit enforcement when it is absent. The release_pypi workflow removes the marker once per run, after the cache is restored and before cibuildwheel, so a marker carried over inside the cached CCACHE_DIR cannot mask a genuine failure. Co-authored-by: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to skip ccache hit enforcement during the first build of a cibuildwheel run, as it starts with a cold cache. It uses a marker file inside the CCACHE_DIR to identify the first build. Feedback on this change highlights a potential issue if CCACHE_DIR is configured as a relative path, which could lead to incorrect path resolution during cibuildwheel test execution. It is recommended to resolve CCACHE_DIR relative to the repository root to ensure robustness.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #877 +/- ##
=======================================
Coverage 29.49% 29.49%
=======================================
Files 241 241
Lines 35512 35512
Branches 14777 14777
=======================================
Hits 10475 10475
+ Misses 17784 17783 -1
- Partials 7253 7254 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Review: PR #877 — "Exempt first cibuildwheel build from ccache-hit enforcement"OverviewTargeted fix for the recurring CorrectnessMarker logic in ccache_dir = os.getenv('CCACHE_DIR')
first_build_marker = ... / '.cytnx_first_wheel_build_done' if ccache_dir else None
is_first_build = first_build_marker is not None and not first_build_marker.exists()
if first_build_marker is not None:
first_build_marker.parent.mkdir(parents=True, exist_ok=True)
first_build_marker.touch()
Workflow cleanup in mkdir -p "${HOME}/.ccache"
rm -f "${HOME}/.ccache/.cytnx_first_wheel_build_done"This runs in the "Set Ccache Directory" step — after The Behavior table is accurate:
No issuesThe fix is minimal, well-scoped, and correctly handles all the relevant cases (Linux container bind-mount, macOS, stale marker from cached ccache, missing Ready to merge. Posted by Claude Code on behalf of @pcchen |
Problem
tools/validate_ccache_stats.pyruns as theCIBW_TEST_COMMAND, i.e. once per Python-version build in a cibuildwheel run, and zeroes the ccache counters at the end so each build observes fresh per-build stats. The first Python version compiles the C++ sources from a cold cache, so it legitimately reports zero cache hits — but the script unconditionally raisesSystemExitwhenever no hits are detected, failing that first build. Only the later Python versions can reuse the object files the first build produced.Change
tools/validate_ccache_stats.py: Track the first build of a run with a marker file at$CCACHE_DIR/.cytnx_first_wheel_build_done.CCACHE_DIRis the only storage shared across the per-version build containers (via the bind mount), so it can carry this signal. When the marker is absent, the build is the first of the run: hit enforcement is skipped and the marker is created. When present, zero hits still fails as before..github/workflows/release_pypi.yml: Remove the marker once per run, after the cache is restored and before cibuildwheel is invoked. This guarantees a marker that was persisted inside the cachedCCACHE_DIRfrom a previous run cannot mask a genuine cache-miss failure on a later run.Behavior
The per-run reset means the exemption applies to exactly one build per cibuildwheel invocation. macOS is covered too, since
CCACHE_DIRthere points at$HOME/.ccache.Co-authored-by: Claude noreply@anthropic.com
Generated by Claude Code