Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run relevant CI tests based on what's changed in the ChangeList #2396

Merged
merged 9 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 7 additions & 5 deletions ci/gpu/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,15 @@ else
fi

gpuci_logger "Running cuGraph test.sh..."
${WORKSPACE}/ci/test.sh ${TEST_MODE_FLAG} | tee testoutput.txt
source ${WORKSPACE}/ci/test.sh ${TEST_MODE_FLAG} | tee testoutput.txt
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 [[ $NB_CHANGED == "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
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the codecov step below will fail if python tests aren't run, since the python tests generate the output needed by codecov. You might try adding something to this if block to prevent codecov from running if python tests did not run.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, thanks Rick

Expand Down
55 changes: 41 additions & 14 deletions ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,31 @@ GTEST_ARGS="--gtest_output=xml:${CUGRAPH_ROOT}/test-results/"
DOWNLOAD_MODE=""
EXITCODE=0

PRHTTP=https://api.github.com/repos/rapidsai/cugraph/pulls/${PR_ID}/files
fnames=`curl -sb -X GET -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GHTK" $PRHTTP | python3 -c "import sys, json; print([labels['filename'] for labels in json.load(sys.stdin)])"`
cpp_changed="false" python_changed="false" nb_changed="false" doc_changed="false"
for fname in ${fnames[@]}
do
if [[ "$fname" == *"cpp/cmake/"* || "$fname" == *"cpp/CMakeLists.txt"* || "$fname" == *"cpp/src/"* || "$fname" == *"cpp/include/"* || "$fname" == *"cpp/tests/"* || "$fname" == *"cpp/libcugraph_etl/"* || "$fname" == *"cpp/scripts/"* ]]; then
cpp_changed="true" python_changed="true" nb_changed="true" doc_changed="true"
fi
if [[ "$fname" == *"python/"* ]]; then
python_changed="true" nb_changed="true" doc_changed="true"
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better to make the variable names a little more accurate, since python_changed implies python code changed when it could actually be set by way of a C++ code change. Perhaps the naming convention could be run_python_tests, run_nb_tests, etc.?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sense

fi
if [[ "$fname" == *"docs/"* ]]; then
doc_changed="true"
fi
if [[ "$fname" == *"notebooks/"* ]]; then
nb_changed="true"
fi
done

if [[ "$nb_changed" == "false" ]]; then
export NB_CHANGED="FALSE"
else
export NB_CHANGED="TRUE"
fi

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this code would be more appropriate in ci/gpu/build.sh and have the variables exported and then referenced in the lower-level scripts (like you're doing for the test-notebooks.sh script). The main reason being that test.sh is sometimes also used by devs outside of CI, and this code would prevent that due to how it's trying to access info about a PR. It would also mean you wouldn't have to source test.sh (which can sometimes have unintended side-effects) since the variables would be set in the top-level calling script.

Once this code is moved out, test.sh should be written to also handle cases where the various python_changed, nb_changed, etc. variables are not set, so devs can continue to run test.sh outside of CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, thanks Rick

Copy link
Contributor

Choose a reason for hiding this comment

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

Somewhere around here might be a good place to print a summary of what's going to be run, what's going to be skipped, and (most importantly) why, since it might be confusing to devs who are expecting certain tests to run which end up getting skipped.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair ask, will do

export RAPIDS_DATASET_ROOT_DIR=${RAPIDS_DATASET_ROOT_DIR:-${CUGRAPH_ROOT}/datasets}
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the CI failures, it looks like this isn't being set properly beause CUGRAPH_ROOT isn't being set properly, because (I think) this script is now being source'd . I think my other suggestion would eliminate the need to source this script and should fix that problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good


# FIXME: consider using getopts for option parsing
Expand Down Expand Up @@ -65,7 +90,7 @@ set +e

if (python ${CUGRAPH_ROOT}/ci/utils/is_pascal.py); then
echo "WARNING: skipping C++ tests on Pascal GPU arch."
else
elif [[ "$cpp_changed" == "true" ]]; then
echo "C++ gtests for cuGraph (single-GPU only)..."
for gt in "${CONDA_PREFIX}/bin/gtests/libcugraph/"*_TEST; do
test_name=$(basename $gt)
Expand All @@ -84,21 +109,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 [[ "$python_changed" == "true" ]]; 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}