Skip to content

Run routing tests selectively based on file changes#924

Open
rgsl888prabhu wants to merge 4 commits intoNVIDIA:mainfrom
rgsl888prabhu:disable_runting_tests_if_no_relevant_changes
Open

Run routing tests selectively based on file changes#924
rgsl888prabhu wants to merge 4 commits intoNVIDIA:mainfrom
rgsl888prabhu:disable_runting_tests_if_no_relevant_changes

Conversation

@rgsl888prabhu
Copy link
Collaborator

Description

Run routing tests selectively if routing files have changes, else disable the run to reduce overhead of CI.

Checklist

  • I am familiar with the Contributing Guidelines.
  • Testing
    • New or existing tests cover these changes
    • Added tests
    • Created an issue to follow-up
    • NA
  • Documentation
    • The documentation is up to date with these changes
    • Added new documentation
    • NA

@rgsl888prabhu rgsl888prabhu requested a review from a team as a code owner March 4, 2026 05:53
@rgsl888prabhu rgsl888prabhu requested a review from vyasr March 4, 2026 05:53
@rgsl888prabhu rgsl888prabhu self-assigned this Mar 4, 2026
@rgsl888prabhu rgsl888prabhu added non-breaking Introduces a non-breaking change improvement Improves an existing functionality labels Mar 4, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

Adds path-based routing rules to the PR workflow, a utility script that detects routing-related changes, and gates in CI test runners to skip routing tests for PRs that don't modify routing files.

Changes

Cohort / File(s) Summary
Workflow Configuration
\.github/workflows/pr.yaml
Adds a routing section with path-based routing rules enumerating directories and patterns that control when routing tests run.
PR Routing Detection (CI entrypoints)
ci/test_cpp.sh, ci/test_python.sh, ci/test_wheel_cuopt.sh
Add PR-only logic: if CUOPT_RUN_ROUTING_TESTS is unset and GITHUB_REF indicates a pull request, invoke ci/utils/routing_changed.sh to set/export CUOPT_RUN_ROUTING_TESTS. Also update copyright headers.
Test Execution Conditionals
ci/run_ctests.sh, ci/run_cuopt_pytests.sh
Respect CUOPT_RUN_ROUTING_TESTS: skip gtests named ROUTING_* in run_ctests.sh, and run pytest --ignore=tests/routing when the variable is false in run_cuopt_pytests.sh.
Utility Script
ci/utils/routing_changed.sh
New script that computes a merge-base with origin/main, diffs changed files, matches them against routing-related path patterns, honors an explicit CUOPT_RUN_ROUTING_TESTS override, and prints true/false (defaults to true in non-git or indeterminate cases).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main objective: running routing tests selectively based on file changes, which is the core functionality added across multiple CI scripts.
Description check ✅ Passed The description is directly related to the changeset, explaining the goal to run routing tests selectively when routing files change to reduce CI overhead.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ci/utils/routing_changed.sh`:
- Around line 12-18: ROUTING_PATTERNS is missing regression routing paths so
changes under regression/routing* are not detected; update the ROUTING_PATTERNS
array to include the regression locations (e.g., add patterns for
'python/cuopt/cuopt/regression/routing/' and 'cpp/.../regression/routing/' or
equivalent regression subpaths used in PR filters) so the routing_changed.sh
detection matches the PR routing filters; modify the ROUTING_PATTERNS variable
accordingly wherever it's defined to include those regression/routing patterns.
- Line 45: The current assignment CHANGED=$(git diff --name-only "${MB}...HEAD"
2>/dev/null) || true swallows git errors and leaves CHANGED empty; change it to
default to a non-empty sentinel when git diff fails so routing tests run (e.g.
CHANGED=$(git diff --name-only "${MB}...HEAD" 2>/dev/null || echo
"__UNKNOWN__")). Update the CHANGED assignment (the command substitution that
invokes git diff) so failures produce a non-empty string that downstream checks
treat as “changed.”

ℹ️ Review info
Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d5f29d26-6838-48f4-90fa-5c8bbdd11b12

📥 Commits

Reviewing files that changed from the base of the PR and between a92fd23 and 6fecaf7.

📒 Files selected for processing (7)
  • .github/workflows/pr.yaml
  • ci/run_ctests.sh
  • ci/run_cuopt_pytests.sh
  • ci/test_cpp.sh
  • ci/test_python.sh
  • ci/test_wheel_cuopt.sh
  • ci/utils/routing_changed.sh

Comment on lines +12 to +18
ROUTING_PATTERNS=(
'python/cuopt/cuopt/routing/'
'python/cuopt/cuopt/tests/routing/'
'cpp/src/routing/'
'cpp/include/cuopt/routing/'
'cpp/tests/routing/'
)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add regression routing paths to the detection set.

ROUTING_PATTERNS misses regression routing paths, while PR routing filters include regression/routing*. A PR changing only regression routing files can incorrectly output false and skip routing tests.

Suggested fix
 ROUTING_PATTERNS=(
     'python/cuopt/cuopt/routing/'
     'python/cuopt/cuopt/tests/routing/'
     'cpp/src/routing/'
     'cpp/include/cuopt/routing/'
     'cpp/tests/routing/'
+    'regression/routing'
 )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ROUTING_PATTERNS=(
'python/cuopt/cuopt/routing/'
'python/cuopt/cuopt/tests/routing/'
'cpp/src/routing/'
'cpp/include/cuopt/routing/'
'cpp/tests/routing/'
)
ROUTING_PATTERNS=(
'python/cuopt/cuopt/routing/'
'python/cuopt/cuopt/tests/routing/'
'cpp/src/routing/'
'cpp/include/cuopt/routing/'
'cpp/tests/routing/'
'regression/routing'
)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/utils/routing_changed.sh` around lines 12 - 18, ROUTING_PATTERNS is
missing regression routing paths so changes under regression/routing* are not
detected; update the ROUTING_PATTERNS array to include the regression locations
(e.g., add patterns for 'python/cuopt/cuopt/regression/routing/' and
'cpp/.../regression/routing/' or equivalent regression subpaths used in PR
filters) so the routing_changed.sh detection matches the PR routing filters;
modify the ROUTING_PATTERNS variable accordingly wherever it's defined to
include those regression/routing patterns.

exit 0
fi

CHANGED=$(git diff --name-only "${MB}...HEAD" 2>/dev/null) || true
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Fail safe when git diff cannot be computed.

Line 45 swallows git diff errors and leaves CHANGED empty, which falls through to false (skip tests). On diff failure, this should return true to avoid missing routing test coverage.

Suggested fix
-CHANGED=$(git diff --name-only "${MB}...HEAD" 2>/dev/null) || true
+if ! CHANGED=$(git diff --name-only "${MB}...HEAD" 2>/dev/null); then
+    echo "true"
+    exit 0
+fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/utils/routing_changed.sh` at line 45, The current assignment CHANGED=$(git
diff --name-only "${MB}...HEAD" 2>/dev/null) || true swallows git errors and
leaves CHANGED empty; change it to default to a non-empty sentinel when git diff
fails so routing tests run (e.g. CHANGED=$(git diff --name-only "${MB}...HEAD"
2>/dev/null || echo "__UNKNOWN__")). Update the CHANGED assignment (the command
substitution that invokes git diff) so failures produce a non-empty string that
downstream checks treat as “changed.”

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
ci/utils/routing_changed.sh (1)

12-18: ⚠️ Potential issue | 🟠 Major

Add regression routing paths to keep test gating aligned.

ROUTING_PATTERNS still misses regression routing paths, so a PR touching only regression/routing* can incorrectly print "false" and skip routing tests.

Suggested patch
 ROUTING_PATTERNS=(
     'python/cuopt/cuopt/routing/'
     'python/cuopt/cuopt/tests/routing/'
     'cpp/src/routing/'
     'cpp/include/cuopt/routing/'
     'cpp/tests/routing/'
+    'regression/routing'
 )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/utils/routing_changed.sh` around lines 12 - 18, ROUTING_PATTERNS is
missing regression routing entries so changes under regression/routing* are
ignored; update the ROUTING_PATTERNS array in routing_changed.sh to include
regression routing paths (e.g., add entries like 'regression/routing/' and/or
'regression/routing*') so the gating logic that checks ROUTING_PATTERNS will
detect PRs touching regression routing files.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@ci/utils/routing_changed.sh`:
- Around line 12-18: ROUTING_PATTERNS is missing regression routing entries so
changes under regression/routing* are ignored; update the ROUTING_PATTERNS array
in routing_changed.sh to include regression routing paths (e.g., add entries
like 'regression/routing/' and/or 'regression/routing*') so the gating logic
that checks ROUTING_PATTERNS will detect PRs touching regression routing files.

ℹ️ Review info
Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6a465db3-55c1-4be2-b888-a66dc5af3b48

📥 Commits

Reviewing files that changed from the base of the PR and between 6fecaf7 and 0d6b3f3.

📒 Files selected for processing (1)
  • ci/utils/routing_changed.sh

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
ci/utils/routing_changed.sh (1)

12-18: ⚠️ Potential issue | 🟠 Major

Include regression routing paths in ROUTING_PATTERNS.

Line 12-Line 18 still omits regression routing locations, so PRs that only touch regression routing files can incorrectly output false and skip routing tests.

Suggested fix
 ROUTING_PATTERNS=(
     'python/cuopt/cuopt/routing/'
     'python/cuopt/cuopt/tests/routing/'
     'cpp/src/routing/'
     'cpp/include/cuopt/routing/'
     'cpp/tests/routing/'
+    'regression/routing'
 )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/utils/routing_changed.sh` around lines 12 - 18, ROUTING_PATTERNS currently
omits regression routing directories which causes PRs touching only regression
routing files to be missed; update the ROUTING_PATTERNS array to include the
regression routing locations by adding appropriate pattern entries for the
regression subdirectories (i.e., add regression-specific patterns alongside the
existing 'python/cuopt/cuopt/routing/', 'python/cuopt/cuopt/tests/routing/',
'cpp/src/routing/', 'cpp/include/cuopt/routing/', and 'cpp/tests/routing/'),
ensuring tests that modify regression routing files are detected.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@ci/utils/routing_changed.sh`:
- Around line 12-18: ROUTING_PATTERNS currently omits regression routing
directories which causes PRs touching only regression routing files to be
missed; update the ROUTING_PATTERNS array to include the regression routing
locations by adding appropriate pattern entries for the regression
subdirectories (i.e., add regression-specific patterns alongside the existing
'python/cuopt/cuopt/routing/', 'python/cuopt/cuopt/tests/routing/',
'cpp/src/routing/', 'cpp/include/cuopt/routing/', and 'cpp/tests/routing/'),
ensuring tests that modify regression routing files are detected.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 09b55155-198e-470b-a344-fda09944202b

📥 Commits

Reviewing files that changed from the base of the PR and between 0d6b3f3 and ca1a0bb.

📒 Files selected for processing (1)
  • ci/utils/routing_changed.sh

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

Labels

improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant