CI: Pin linter versions in CONTRIBUTE.md and update pre-commit hook#2448
CI: Pin linter versions in CONTRIBUTE.md and update pre-commit hook#2448gyohuangxin merged 1 commit intomainfrom
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
There was a problem hiding this comment.
Pull request overview
Updates contributor tooling guidance and the repo’s git pre-commit hook to reduce formatting mismatches between local development environments and CI, especially around clang-format selection.
Changes:
- Update
CONTRIBUTE.mdrecommendedblack/ruffversions and specifyclang-formatv18 (noting 18/19/20 support). - Enhance
.githooks/pre-committo preferclang-format-{20,19,18}and fall back to unversionedclang-format.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
CONTRIBUTE.md |
Updates documented linter versions/commands to align local formatting with expected CI behavior. |
.githooks/pre-commit |
Adds version-aware clang-format discovery with a fallback to the unversioned binary. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ```bash | ||
| pip install black==25.1.0 ruff==0.11.11 | ||
| apt install clang-format # For C++/HIP code formatting | ||
| pip install black==26.3.0 ruff==0.15.7 |
There was a problem hiding this comment.
CONTRIBUTE.md now pins black/ruff versions as “match current CI”, but CI currently runs psf/black@stable (not a specific version) and installs ruff without a version pin in .github/workflows/pre-checks.yaml. This can still lead to local/CI mismatches when CI updates. Consider either pinning CI to the same versions or rewording this section as “recommended versions” and documenting how to check the versions used in CI.
| done | ||
| else | ||
| echo "clang-format command not found, skipping file formatting." | ||
| echo "clang-format (18/19/20) not found, skipping file formatting. Install with: apt install clang-format-18" |
There was a problem hiding this comment.
The skip message is slightly inaccurate: the script also checks for unversioned clang-format, but the message only mentions (18/19/20). Consider updating it to something like “clang-format not found (tried clang-format-20/19/18 and clang-format)” so it matches the actual detection logic and gives clearer guidance.
| echo "clang-format (18/19/20) not found, skipping file formatting. Install with: apt install clang-format-18" | |
| echo "clang-format not found (tried clang-format-20/19/18 and clang-format), skipping file formatting. Install with: apt install clang-format-18" |
b7a6d16 to
5af95c2
Compare
Update recommended tool versions to match current CI: - black: 25.1.0 -> 26.3.0 - ruff: 0.11.11 -> 0.15.7 - clang-format: require version 18/19/20 Update pre-commit hook to prefer versioned clang-format (20 > 19 > 18) with fallback to unversioned clang-format. Signed-off-by: Xin Huang <Xin.Huang@amd.com>
5af95c2 to
8fdc829
Compare
Summary
CONTRIBUTE.mdto match current CI:black: 25.1.0 → 26.3.0ruff: 0.11.11 → 0.15.7clang-format: specify version 18 (18/19/20 are all supported).githooks/pre-committo prefer versionedclang-format-{20,19,18}with fallback to unversionedclang-formatThis ensures local dev environments stay consistent with CI, avoiding format mismatches that cause CI failures.
Test plan
clang-format-18on dev machinesblack==26.3.0andruff==0.15.7produce same results as CI