From 920340d4fae48e175af951d9e9fbd83afdfc0431 Mon Sep 17 00:00:00 2001 From: anandhkb <102690644+anandhkb@users.noreply.github.com> Date: Tue, 12 Jul 2022 12:31:29 -0700 Subject: [PATCH] Run relevant CI tests based on what's changed in the ChangeList (#2396) cpp_changed==cpp+python+notebooks, python_changed==python+notebooks, notebooks_changed==notebooks Authors: - https://github.com/anandhkb Approvers: - Rick Ratzel (https://github.com/rlratzel) - AJ Schmidt (https://github.com/ajschmidt8) URL: https://github.com/rapidsai/cugraph/pull/2396 --- ci/gpu/build.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++----- ci/test.sh | 30 ++++++++++++----------- 2 files changed, 73 insertions(+), 20 deletions(-) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index a7c7d090d0f..6ffba734f79 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -117,6 +117,49 @@ else gpuci_mamba_retry install cugraph pylibcugraph -c ${CONDA_BLD_DIR} -c ${CONDA_ARTIFACT_PATH} fi +################################################################################ +# Identify relevant testsets to run in CI based on the ChangeList +################################################################################ + +fnames=() +# Initialize all the run variables to true, as we want to run all the tests if the build_mode is NOT a pull-request +run_cpp_tests="true" run_python_tests="true" run_nb_tests="true" +if [ "$BUILD_MODE" == "pull-request" ]; then + PR_ENDPOINT="https://api.github.com/repos/rapidsai/cugraph/pulls/${PR_ID}/files" + fnames=( + $( + curl -s \ + -X GET \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Authorization: token $GHTK" \ + "$PR_ENDPOINT" | \ + jq -r '.[].filename' + ) + ) + # Initialize all the run variables to false, for pull-requests only, later, based on what's changed, these variables will be set to true + run_cpp_tests="false" run_python_tests="false" run_nb_tests="false" +fi +# this will not do anything if the 'fnames' array is empty +for fname in "${fnames[@]}" +do + if [[ "$fname" == *"cpp/"* && "$fname" != *"cpp/docs/"* && "$fname" != *"cpp/doxygen/"* ]]; then + run_cpp_tests="true" run_python_tests="true" run_nb_tests="true" + fi + if [[ "$fname" == *"python/"* ]]; then + run_python_tests="true" run_nb_tests="true" + fi + if [[ "$fname" == *"notebooks/"* ]]; then + run_nb_tests="true" + fi +done +################################################################################ +# PRINT SUMMARY OF TESTS to BE EXECUTED +################################################################################ +gpuci_logger "Summary of CI tests to be executed" +gpuci_logger "Run cpp tests=$run_cpp_tests" +gpuci_logger "Run python tests=$run_python_tests" +gpuci_logger "Run notebook tests=$run_nb_tests" + ################################################################################ # TEST ################################################################################ @@ -146,16 +189,24 @@ else fi gpuci_logger "Running cuGraph test.sh..." - ${WORKSPACE}/ci/test.sh ${TEST_MODE_FLAG} | tee testoutput.txt + if [[ $run_cpp_tests == "true" ]]; then + ${WORKSPACE}/ci/test.sh ${TEST_MODE_FLAG} --run-cpp-tests --run-python-tests | tee testoutput.txt + elif [[ $run_python_tests == "true" ]]; then + ${WORKSPACE}/ci/test.sh ${TEST_MODE_FLAG} --run-python-tests | tee testoutput.txt + else + ${WORKSPACE}/ci/test.sh ${TEST_MODE_FLAG} | tee testoutput.txt + fi gpuci_logger "Ran cuGraph test.sh : return code was: $?, gpu/build.sh exit code is now: $EXITCODE" - gpuci_logger "Running cuGraph notebook test script..." - ${WORKSPACE}/ci/gpu/test-notebooks.sh 2>&1 | tee nbtest.log - gpuci_logger "Ran cuGraph notebook test script : return code was: $?, gpu/build.sh exit code is now: $EXITCODE" - python ${WORKSPACE}/ci/utils/nbtestlog2junitxml.py nbtest.log + if [[ $run_nb_tests == "true" ]]; then + gpuci_logger "Running cuGraph notebook test script..." + ${WORKSPACE}/ci/gpu/test-notebooks.sh 2>&1 | tee nbtest.log + gpuci_logger "Ran cuGraph notebook test script : return code was: $?, gpu/build.sh exit code is now: $EXITCODE" + python ${WORKSPACE}/ci/utils/nbtestlog2junitxml.py nbtest.log + fi fi -if [ -n "${CODECOV_TOKEN}" ]; then +if [[ -n "${CODECOV_TOKEN}" && $run_python_tests == "true" ]]; then codecov -t $CODECOV_TOKEN fi diff --git a/ci/test.sh b/ci/test.sh index 1eae158122d..0245340dca7 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -65,7 +65,7 @@ set +e if (python ${CUGRAPH_ROOT}/ci/utils/is_pascal.py); then echo "WARNING: skipping C++ tests on Pascal GPU arch." -else +elif hasArg "--run-cpp-tests"; then echo "C++ gtests for cuGraph (single-GPU only)..." for gt in "${CONDA_PREFIX}/bin/gtests/libcugraph/"*_TEST; do test_name=$(basename $gt) @@ -84,21 +84,23 @@ else done fi -echo "Python pytest for pylibcugraph..." -cd ${CUGRAPH_ROOT}/python/pylibcugraph/pylibcugraph -pytest --cache-clear --junitxml=${CUGRAPH_ROOT}/junit-pylibcugraph-pytests.xml -v --cov-config=.coveragerc --cov=pylibcugraph --cov-report=xml:${WORKSPACE}/python/pylibcugraph/pylibcugraph-coverage.xml --cov-report term --ignore=raft --benchmark-disable -echo "Ran Python pytest for pylibcugraph : return code was: $?, test script exit code is now: $EXITCODE" +if hasArg "--run-python-tests"; then + echo "Python pytest for pylibcugraph..." + cd ${CUGRAPH_ROOT}/python/pylibcugraph/pylibcugraph + pytest --cache-clear --junitxml=${CUGRAPH_ROOT}/junit-pylibcugraph-pytests.xml -v --cov-config=.coveragerc --cov=pylibcugraph --cov-report=xml:${WORKSPACE}/python/pylibcugraph/pylibcugraph-coverage.xml --cov-report term --ignore=raft --benchmark-disable + echo "Ran Python pytest for pylibcugraph : return code was: $?, test script exit code is now: $EXITCODE" -echo "Python pytest for cuGraph (single-GPU only)..." -cd ${CUGRAPH_ROOT}/python/cugraph/cugraph -# rmat is not tested because of MG testing -pytest --cache-clear --junitxml=${CUGRAPH_ROOT}/junit-cugraph-pytests.xml -v --cov-config=.coveragerc --cov=cugraph --cov-report=xml:${WORKSPACE}/python/cugraph/cugraph-coverage.xml --cov-report term --ignore=raft --ignore=tests/mg --ignore=tests/generators --benchmark-disable -echo "Ran Python pytest for cugraph : return code was: $?, test script exit code is now: $EXITCODE" + echo "Python pytest for cuGraph (single-GPU only)..." + cd ${CUGRAPH_ROOT}/python/cugraph/cugraph + # rmat is not tested because of MG testing + pytest --cache-clear --junitxml=${CUGRAPH_ROOT}/junit-cugraph-pytests.xml -v --cov-config=.coveragerc --cov=cugraph --cov-report=xml:${WORKSPACE}/python/cugraph/cugraph-coverage.xml --cov-report term --ignore=raft --ignore=tests/mg --ignore=tests/generators --benchmark-disable + echo "Ran Python pytest for cugraph : return code was: $?, test script exit code is now: $EXITCODE" -echo "Python benchmarks for cuGraph (running as tests)..." -cd ${CUGRAPH_ROOT}/benchmarks -pytest -v -m "managedmem_on and poolallocator_on and tiny" --benchmark-disable -echo "Ran Python benchmarks for cuGraph (running as tests) : return code was: $?, test script exit code is now: $EXITCODE" + echo "Python benchmarks for cuGraph (running as tests)..." + cd ${CUGRAPH_ROOT}/benchmarks + pytest -v -m "managedmem_on and poolallocator_on and tiny" --benchmark-disable + echo "Ran Python benchmarks for cuGraph (running as tests) : return code was: $?, test script exit code is now: $EXITCODE" +fi echo "Test script exiting with value: $EXITCODE" exit ${EXITCODE}