ci: sync pr bot policy_check.py from TheRock and add hip-tests path pattern#8778
ci: sync pr bot policy_check.py from TheRock and add hip-tests path pattern#8778amd-chrissosa wants to merge 7 commits into
Conversation
…attern Two related changes: 1. Sync policy_check.py from ROCm/TheRock (canonical source). The key addition is _is_test_file(), which supports two matching modes: - Basename patterns (no '/'): matched against filename only - Path patterns (contain '/'): matched against full repo-relative path The previous version lacked path-based matching entirely. 2. Add projects/hip-tests/** to test_file_patterns in policy.yml. CLR's tests live in the separate projects/hip-tests/ subproject and are named after the API they test (atomicAdd.cc, acquire_release.cc, etc.) with no test_* prefix or _test suffix. Without this path pattern, any CLR PR that touched hip-tests alongside source changes would be incorrectly flagged as missing a unit test. Also adds testing_*, *_tests.*, and Test* basename patterns from TheRock. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
✅ All Policy Checks Passed
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🚫 Please fix the failed policies before requesting reviews. The following policy checks failed:
The |
Adds test_policy_check_ut.py, synced from ROCm/TheRock (canonical source) with rocm-systems-specific additions: - test_hip_tests_path_recognised_by_shipped_policy: integration test that loads the real policy.yml and verifies a CLR PR touching projects/hip-tests/catch/unit/memory/atomicAdd.cc alongside source changes correctly passes the unit test check - test_unit_test_patterns_exclude_unit_glob: updated to assert projects/hip-tests/** is present in the loaded policy Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the Systems PR Bot’s unit-test detection logic to support path-based test file recognition (needed for projects/hip-tests/**), and aligns the policy’s test file patterns to avoid falsely flagging CLR PRs that do include tests.
Changes:
- Extend unit-test detection to support full-path glob patterns (in addition to basename-only patterns).
- Add
projects/hip-tests/**(and align several basename patterns) totest_file_patternsinpolicy.yml. - Sync additional behavior from TheRock’s
policy_check.py(including some refactors/removals).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| tools/systems_pr_bot/policy.yml | Updates test file patterns and documents basename-vs-path matching behavior; adds projects/hip-tests/** to recognize hip-tests as tests. |
| tools/systems_pr_bot/policy_check.py | Implements _is_test_file() for path-aware matching and updates unit-test detection logic accordingly; includes other synced changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| build_policy_table_comment( | ||
| build_bump_pr_results(policy), marker, ready=True, note=note | ||
| ), | ||
| note, |
| base = Path(filename).name | ||
| ext = Path(filename).suffix.lower() |
| base = Path(filename).name | ||
| ext = Path(filename).suffix.lower() |
| "Unit Test", | ||
| "pre-commit", | ||
| "Draft PR", | ||
| "PR Size", | ||
| "Feature Flag", | ||
| "Code Coverage", | ||
| "therock-pr-bot", |
| footer = "\n\n> 🎉 All policy checks passed!" | ||
|
|
||
| faq_url = "https://github.com/ROCm/rocm-systems/tree/develop/docs/SYSTEMS_PR_BOT_FAQ.md" | ||
| faq_url = "https://github.com/ROCm/TheRock/blob/main/skills/therock_pr_bot/FAQ.md" |
| # PR title rules now live under the nested `title:` mapping. | ||
| title_cfg = pr.get("title", {}) or {} | ||
| title_patterns_raw = title_cfg.get("pattern", []) or [] | ||
| title_patterns = [re.compile(str(p)) for p in title_patterns_raw] | ||
| title_min_length = int(title_cfg.get("title_min_length", 0) or 0) | ||
| title_max_length = int(title_cfg.get("title_max_length", 0) or 0) | ||
|
|
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Changes to tools/systems_pr_bot/ don't touch any build subtree, but therock_configure_ci.py falls back to running all projects when modified files don't match a known subtree. Add paths-ignore to the pull_request trigger so the full Linux/Windows build matrix doesn't fire for bot, script, or tooling-only PRs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This reverts commit 8dd1eb6.
therock_configure_ci.py fell back to evaluating all build subtrees when modified files didn't match any known subtree. For PRs that only touch tools/ (bot scripts, utilities) this triggered a full Linux+Windows build matrix with no benefit. Add CI_SKIP_PATH_PREFIXES (initially ['tools/']) and check_only_ci_skip_paths() so that PRs whose every changed file is under a skip prefix produce an empty subtree list and skip the build CI entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This reverts commit 9bb66d6.
|
Superseded by #8782 (clean branch without the CI investigation commits). |
Summary
Three changes to fix the unit test check incorrectly flagging CLR PRs:
1. Sync
policy_check.pyfrom ROCm/TheRock (canonical source)The version in rocm-systems was behind and lacked
_is_test_file(), which supports path-based test file recognition. Patterns containing/are now matched against the full repo-relative file path; patterns without/match the basename only.2. Add
projects/hip-tests/**totest_file_patternsinpolicy.ymlCLR's tests live in the separate
projects/hip-tests/subproject and are named after the API they test (atomicAdd.cc,acquire_release.cc, etc.) with notest_*prefix or_testsuffix. Without this path pattern, any CLR PR touchinghip-tests/alongside source changes would be incorrectly flagged as missing a unit test.Also aligns the basename patterns with TheRock (
testing_*,*_tests.*,Test*).3. Add
test_policy_check_ut.pySynced from TheRock with rocm-systems-specific additions covering the hip-tests path pattern.
Tracks: ROCm/TheRock#6654
Closes #8778
Test plan
python -m pytest tools/systems_pr_bot/test_policy_check_ut.pytest_hip_tests_path_recognised_by_shipped_policy: CLR source +projects/hip-tests/catch/unit/memory/atomicAdd.cc→ passes unit test checktest_path_based_pattern_code_only_still_fails: CLR source with no hip-tests changes → still fails correctlytest_*/*_test.*patterns continue to work as before🤖 Generated with Claude Code