Skip to content

ci: sync pr bot from TheRock and add hip-tests path pattern#8782

Closed
amd-chrissosa wants to merge 6 commits into
developfrom
users/chrisosa/pr-bot-sync-and-hip-tests-pattern-v2
Closed

ci: sync pr bot from TheRock and add hip-tests path pattern#8782
amd-chrissosa wants to merge 6 commits into
developfrom
users/chrisosa/pr-bot-sync-and-hip-tests-pattern-v2

Conversation

@amd-chrissosa

@amd-chrissosa amd-chrissosa commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Three changes to fix the unit test check incorrectly flagging CLR PRs:

1. Sync policy_check.py from ROCm/TheRock (canonical source)

The previous version lacked _is_test_file(). The updated version supports two matching modes:

  • Basename patterns (no /): match the filename only
  • Path patterns (contain /): match the full repo-relative path, allowing test directories to be recognised by location regardless of filename

2. Add projects/hip-tests/** to test_file_patterns in policy.yml

CLR's tests live in projects/hip-tests/ and are named after the API they test (atomicAdd.cc, acquire_release.cc) with no test_* prefix. Also aligns basename patterns with TheRock (testing_*, *_tests.*, Test*).

3. Add test_policy_check_ut.py

Synced from TheRock with a rocm-systems-specific integration test: test_hip_tests_path_recognised_by_shipped_policy loads the real policy.yml and verifies a CLR PR touching projects/hip-tests/ correctly passes the unit test check.

Note on CI: The Linux build jobs running on this PR are a known issue — therock_configure_ci.py currently triggers full CI for any tools/ change that doesn't match a known subtree. This is fixed in #8781, which should ideally land first. The build failures shown are infrastructure errors on the runners, not related to this change.

Closes #8778

Tracks: ROCm/TheRock#6654
Depends on: #8781 (for CI to skip on future tools/ PRs)

Test plan

  • 33 tests pass: python -m pytest tools/systems_pr_bot/test_policy_check_ut.py
  • test_hip_tests_path_recognised_by_shipped_policy: CLR source + projects/hip-tests/catch/unit/memory/atomicAdd.cc → passes
  • test_path_based_pattern_code_only_still_fails: CLR source only → still fails correctly
  • pre-commit passes on all changed files

🤖 Generated with Claude Code

amd-chrissosa and others added 2 commits July 17, 2026 11:50
Three changes to fix the unit test check incorrectly flagging CLR PRs:

1. Sync policy_check.py from ROCm/TheRock (canonical source).
   Key addition: _is_test_file() supports two matching modes —
   basename patterns (no '/') match the filename only; path patterns
   (contain '/') match the full repo-relative path, enabling test
   directories to be recognised by location rather than filename.

2. Add projects/hip-tests/** to test_file_patterns in policy.yml.
   CLR's tests live in projects/hip-tests/ and are named after the API
   they test (atomicAdd.cc, acquire_release.cc) with no test_* prefix.
   Also aligns basename patterns with TheRock (testing_*, *_tests.*, Test*).

3. Add test_policy_check_ut.py synced from TheRock with rocm-systems
   additions: test_hip_tests_path_recognised_by_shipped_policy verifies
   the real policy.yml correctly passes a CLR + hip-tests PR.

Closes #8778

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@therock-pr-bot

Copy link
Copy Markdown

✅ All Policy Checks Passed

Check Status Details
🌿 Branch Name ✅ Pass
📝 PR Title/Description ✅ Pass
Forbidden Files ✅ Pass
🧪 Unit Test ✅ Pass
🚫 Draft PR 🔜 To Be Enabled
🚩 Feature Flag 🔜 To Be Enabled
📊 Code Coverage 🔜 To Be Enabled

🎉 All policy checks passed!

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Systems PR Bot policy checker to better recognize unit test changes (including path-based test locations like projects/hip-tests/**), synchronizes policy_check.py behavior with TheRock, and adds a local unit/integration test suite to prevent regressions in rocm-systems.

Changes:

  • Extend unit-test file recognition to support both basename-based and path-based glob patterns, and ship projects/hip-tests/** as a recognized test location.
  • Add/ship a comprehensive test_policy_check_ut.py suite, including an integration test that loads the real policy.yml.
  • Update bot comment/FAQ behavior and ignore Python bytecode caches in tools/systems_pr_bot/.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
tools/systems_pr_bot/test_policy_check_ut.py Adds unit + integration tests for policy checking (including shipped-policy integration coverage).
tools/systems_pr_bot/policy.yml Updates unit test file patterns to include hip-tests and documents basename vs path matching modes.
tools/systems_pr_bot/policy_check.py Syncs policy check logic (notably test-file detection) and modifies comment output/help link behavior.
tools/systems_pr_bot/.gitignore Ignores __pycache__/ for the bot’s Python code.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +9 to +12
Run locally:
python -m unittest .github/therock_pr_bot/test_policy_check_ut.py -v
# or
pytest .github/therock_pr_bot/test_policy_check_ut.py
Comment on lines 119 to 120
# A changed file is treated as a unit test if its basename matches one of
# these glob patterns (e.g. test_parser.py, parser_test.cpp).
Comment on lines 1005 to 1009
pr_number,
token, # type: ignore[arg-type]
marker,
build_policy_table_comment(
build_bump_pr_results(policy), marker, ready=True, note=note
),
note,
)
Comment on lines 319 to +323
def ensure_pr_title(policy: Policy, title: str, errors: List[str]) -> None:
"""Validate the PR title (length, Conventional Commits style, forbidden words).
"""Validate the PR title (length and forbidden words).

Appends a structured Error/Expected/Desired-format message to `errors` for
each rule that fails.
Appends a structured Error/Expected message to `errors` for each rule that
fails.
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"
amd-chrissosa and others added 3 commits July 17, 2026 13:00
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>
@amd-chrissosa
amd-chrissosa requested a review from a team as a code owner July 17, 2026 20:54
@github-actions github-actions Bot added the github actions Pull requests that update GitHub Actions code label Jul 17, 2026
…ch not develop)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
amd-chrissosa added a commit to ROCm/TheRock that referenced this pull request Jul 20, 2026
## Summary

The `test_file_patterns` config already supports full-path glob matching
(patterns containing `/` are matched against the full file path via
`_is_test_file`), but this was underdocumented and had no unit test
coverage.

This matters because some repos (notably rocm-systems) have test
directories whose files use no `test_*` naming convention (e.g.
`projects/hip-tests/catch/unit/memory/atomicAdd.cc`).

- **`policy.yml`**: expand the `test_file_patterns` comment to clearly
document both matching modes (basename vs full-path) with concrete
examples for how downstream repos configure path-based patterns for
their test directories
- **`test_policy_check_ut.py`**: add two new tests covering path-based
patterns (one pass, one fail), and fix the `make_policy()` fixture which
referenced `Policy` fields that no longer exist (`max_files_changed`,
`max_total_changes`, `max_single_file_changes`), causing 20 pre-existing
test failures on `main`

Closes #6654

## Test plan

- [x] `python -m pytest skills/therock_pr_bot/test_policy_check_ut.py` —
32 pass (up from 3), 2 pre-existing failures unrelated to this change
- [x] `test_path_based_pattern_satisfies_requirement`: file under
`projects/hip-tests/**` satisfies the unit test requirement alongside a
CLR source change
- [x] `test_path_based_pattern_code_only_still_fails`: source-only
change with no matching test path still fails correctly

## Follow-up

A separate PR to rocm-systems (ROCm/rocm-systems#8782) syncs
`policy_check.py` and adds `projects/hip-tests/**` to its
`test_file_patterns`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@amd-chrissosa

Copy link
Copy Markdown
Contributor Author

Superseded by #8899 — clean single-commit rebase on develop with all Copilot feedback addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github actions Pull requests that update GitHub Actions code organization: ROCm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants