Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ci/run_ctests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ else
exit 1
fi

# Skip ROUTING_* gtests when CUOPT_RUN_ROUTING_TESTS is false (e.g. PRs that don't touch routing)
RUN_ROUTING_TESTS="${CUOPT_RUN_ROUTING_TESTS:-true}"
for gt in "${GTEST_DIR}"/*_TEST; do
test_name=$(basename "${gt}")
if [[ "${RUN_ROUTING_TESTS}" == "false" ]] && [[ "${test_name}" == ROUTING_* ]]; then
echo "Skipping gtest ${test_name} (routing tests not requested)"
continue
fi
echo "Running gtest ${test_name}"
"${gt}" "$@"
done
Expand Down
7 changes: 6 additions & 1 deletion ci/run_cuopt_pytests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ set -euo pipefail
# Support invoking run_cuopt_pytests.sh outside the script directory
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"/../python/cuopt/cuopt/

pytest -s --cache-clear "$@" tests
# Skip routing tests when CUOPT_RUN_ROUTING_TESTS is false (e.g. PRs that don't touch routing)
if [[ "${CUOPT_RUN_ROUTING_TESTS:-true}" == "false" ]]; then
pytest -s --cache-clear "$@" --ignore=tests/routing tests
else
pytest -s --cache-clear "$@" tests
fi
9 changes: 8 additions & 1 deletion ci/test_cpp.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# SPDX-FileCopyrightText: Copyright (c) 2023-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail
Expand Down Expand Up @@ -48,6 +48,13 @@ EXITCODE=0
trap "EXITCODE=1" ERR
set +e

# Only in PR workflow: skip routing tests when PR doesn't touch routing code. Other runs (nightly, manual) run all tests.
if [[ -z "${CUOPT_RUN_ROUTING_TESTS:-}" ]] && [[ "${GITHUB_REF:-}" == refs/heads/pull-request/* ]]; then
CI_DIR="$(cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")" && pwd)"
CUOPT_RUN_ROUTING_TESTS=$(bash "${CI_DIR}/utils/routing_changed.sh")
export CUOPT_RUN_ROUTING_TESTS
fi

# Run gtests from libcuopt-tests package
export GTEST_OUTPUT=xml:${RAPIDS_TESTS_DIR}/

Expand Down
9 changes: 8 additions & 1 deletion ci/test_python.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# SPDX-FileCopyrightText: Copyright (c) 2023-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail
Expand Down Expand Up @@ -54,6 +54,13 @@ set +e
# Due to race condition in certain cases UCX might not be able to cleanup properly, so we set the number of threads to 1
export OMP_NUM_THREADS=1

# Only in PR workflow: skip routing tests when PR doesn't touch routing code. Other runs (nightly, manual) run all tests.
if [[ -z "${CUOPT_RUN_ROUTING_TESTS:-}" ]] && [[ "${GITHUB_REF:-}" == refs/heads/pull-request/* ]]; then
CI_DIR="$(cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")" && pwd)"
CUOPT_RUN_ROUTING_TESTS=$(bash "${CI_DIR}/utils/routing_changed.sh")
export CUOPT_RUN_ROUTING_TESTS
fi

rapids-logger "Test cuopt_cli"
timeout 10m bash ./python/libcuopt/libcuopt/tests/test_cli.sh

Expand Down
7 changes: 7 additions & 0 deletions ci/test_wheel_cuopt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ cd -
RAPIDS_DATASET_ROOT_DIR="$(realpath datasets)"
export RAPIDS_DATASET_ROOT_DIR

# Only in PR workflow: skip routing tests when PR doesn't touch routing code. Other runs (nightly, manual) run all tests.
if [[ -z "${CUOPT_RUN_ROUTING_TESTS:-}" ]] && [[ "${GITHUB_REF:-}" == refs/heads/pull-request/* ]]; then
CI_DIR="$(cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")" && pwd)"
CUOPT_RUN_ROUTING_TESTS=$(bash "${CI_DIR}/utils/routing_changed.sh")
export CUOPT_RUN_ROUTING_TESTS
fi

# Run CLI tests
timeout 10m bash ./python/libcuopt/libcuopt/tests/test_cli.sh

Expand Down
52 changes: 52 additions & 0 deletions ci/utils/routing_changed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Prints "true" if routing-related files changed vs origin/main, else "false".
# Only used when running under the PR workflow (refs/heads/pull-request/*); other
# workflows (nightly, manual test.yaml) run all tests and do not call this script.
# Must be run from the repository root.

set -euo pipefail

ROUTING_PATTERNS=(
'python/cuopt/cuopt/routing/'
'python/cuopt/cuopt/tests/routing/'
'cpp/src/routing/'
'cpp/include/cuopt/routing/'
'cpp/tests/routing/'
)
Comment on lines +12 to +18
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.


# If explicitly set by caller, respect it
if [[ -n "${CUOPT_RUN_ROUTING_TESTS:-}" ]]; then
if [[ "${CUOPT_RUN_ROUTING_TESTS}" == "false" ]]; then
echo "false"
exit 0
fi
echo "true"
exit 0
fi

# Not in a git repo or no merge base: run routing tests to be safe
if ! git rev-parse --is-inside-work-tree &>/dev/null; then
echo "true"
exit 0
fi

MB=""
if git fetch origin main --depth=500 2>/dev/null; then
MB=$(git merge-base HEAD origin/main 2>/dev/null) || true
fi
if [[ -z "${MB:-}" ]]; then
echo "true"
exit 0
fi

CHANGED=$(git diff --name-only "${MB}...HEAD" 2>/dev/null) || { echo "true"; exit 0; }
for pat in "${ROUTING_PATTERNS[@]}"; do
if echo "${CHANGED}" | grep -qE "^${pat}"; then
echo "true"
exit 0
fi
done
echo "false"
Loading