Skip to content

ci: enforce zccache strict path validation (closes #2378) - #2504

Merged
zackees merged 1 commit into
masterfrom
ci/zccache-strict-paths-2378
May 24, 2026
Merged

zackees merged 1 commit into
masterfrom
ci/zccache-strict-paths-2378

Conversation

@zackees

@zackees zackees commented May 24, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Generalize the Meson compile-flag normalizer beyond -I*.p to every strict-path-bearing flag (-I, -isystem, -iquote, -iframework, -idirafter, -imsvc, -include, -include-pch, -imacros, -F, /I), and strip /. / /.. components.
  • Add a pre-compile gate (find_strict_path_violations / _enforce_strict_path_violations) called from setup_meson_build() and the WASM _normalize_meson_private_paths shim — raises before any compile work is scheduled if compile_commands.json still has offenders.
  • Fix a regex-backtracking bug that would mis-rewrite the bare "-include-pch" token to "-includeC:/.../-pch" by falling back from the -include-pch alternative to -include and consuming -pch as the path.

Context

  • Issue Build: enable zccache strict path validation #2378 closes out the work to enable ZCCACHE_STRICT_PATHS=absolute end-to-end.
  • ZCCACHE_STRICT_PATHS env var is already set in both ci/meson/runner.py and ci/meson/build_config.py (left in place).
  • zccache>=1.9.0 is already pinned in pyproject.toml (well above the 1.3.7 baseline that introduced --strict-paths).
  • The Meson include-path validator at ci/tests/test_meson_include_paths.py continues to gate CI via the existing pytest run.

Test plan

  • uv run pytest ci/tests/test_meson_include_paths.py ci/tests/test_meson_private_include_normalization.py -v — 8 passed
  • uv run pytest ci/tests/ (excluding pre-existing unrelated failures) — 313 passed, 39 skipped
  • bash lint ci/meson/build_config.py ci/tests/test_meson_private_include_normalization.py ci/wasm_build.py — no new violations
  • Confirmed pre-compile gate fires on synthetic offenders (added regression tests)

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced build path validation to detect and prevent invalid path formats during compilation.
    • Added stricter compliance checks for generated build commands with fail-fast validation to catch path issues earlier and provide detailed error messages.

Review Change Stack

Extend the Meson compile-flag normalizer beyond ``-I*.p`` to cover every
path-bearing flag enforced by ``ZCCACHE_STRICT_PATHS=absolute`` (``-I``,
``-isystem``, ``-iquote``, ``-iframework``, ``-idirafter``, ``-imsvc``,
``-include``, ``-include-pch``, ``-imacros``, ``-F``, ``/I``), strip
``/.`` and ``/..`` components, and add a pre-compile gate in
``setup_meson_build`` / ``_normalize_meson_private_paths`` that raises
before the build scheduler picks up work when ``compile_commands.json``
still has strict-path offenders.

Path char class excludes a leading ``-`` so the longer-prefix-first
alternation doesn't fall back from ``-include-pch`` to ``-include`` +
``-pch`` on bare two-token PCH flag pairs.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 24, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR strengthens Meson compile-command validation by expanding path normalization from private includes to all path-bearing compiler flags, adding runtime violation detection, and integrating fail-fast enforcement into both normal and alternative build workflows, with comprehensive test coverage.

Changes

Meson Strict Path Validation and Enforcement

Layer / File(s) Summary
Strict Path Regex and Normalization Foundation
ci/meson/build_config.py
New _STRICT_PATH_FLAG_PREFIXES and _STRICT_PATH_FLAG_RE regex match multiple compiler flag types (-I, -isystem, -iquote, -include, -include-pch, -F, /I, etc.); _has_dot_components() helper added; normalize_meson_private_include_paths() updated to rewrite all matched paths into canonical forward-slash absolute form without dot or .. components.
Violation Detection and Enforcement Functions
ci/meson/build_config.py
New find_strict_path_violations() parses compile_commands.json and collects paths with backslashes, non-absolute form, or dot components; new _enforce_strict_path_violations() prints violation summaries (up to 10 samples plus count) and raises RuntimeError to fail the build.
Build Workflow Enforcement Checkpoints
ci/meson/build_config.py
Both the "skip meson setup" flow and the normal post-setup flow now call _enforce_strict_path_violations() after normalization to catch and fail on any remaining violations before compilation.
Regression Tests for Path Normalization and Violation Detection
ci/tests/test_meson_private_include_normalization.py
Imports find_strict_path_violations; adds tests for rewriting dot/backslash-containing flags into canonical form, tests for correct -include-pch tokenization, and new TestFindStrictPathViolations suite validating empty results for missing/canonical paths and correct violation counts for non-canonical paths.
WASM Build Strict Path Validation
ci/wasm_build.py
Imports and calls find_strict_path_violations() after normalization in _normalize_meson_private_paths(); prints violation summaries and raises RuntimeError on violations (previously only normalized without enforcement).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • FastLED/FastLED#2389: Both PRs modify the same private include path rewriting in normalize_meson_private_include_paths() and adjust associated test coverage for that normalization behavior.
  • FastLED/FastLED#2385: Both PRs directly modify ci/meson/build_config.py strict-path and private .p include normalization at identical code paths; this PR extends #2385 with fail-fast violation enforcement.
  • FastLED/FastLED#2327: PR #2327 removes /./-style include path spellings in tests/meson.build which would otherwise be flagged as dot-containing violations by this PR's new strict-path enforcement.

Poem

🐰 Paths once wild with backslashes and dots,
Now march through the regex with canonical thoughts,
Compile commands gleam in their forward-slash dress,
The build fails fast when they stray from finesse! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 47.06% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: enforcement of zccache strict path validation, which is the primary focus of the changeset across multiple files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/zccache-strict-paths-2378

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees merged commit 05dbb63 into master May 24, 2026
5 of 7 checks passed
@zackees
zackees deleted the ci/zccache-strict-paths-2378 branch August 21, 2026 19:15
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