From f55b0f9988978e3d45f83f548204d666e95092d9 Mon Sep 17 00:00:00 2001 From: Olivier Grisel Date: Sun, 2 Apr 2023 12:02:53 +0200 Subject: [PATCH 1/4] CI disable coverage on Windows to keep CI times reasonable --- azure-pipelines.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index af9044665a912..639cc85d2b989 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -277,6 +277,11 @@ jobs: DISTRIB: 'conda' LOCK_FILE: ./build_tools/azure/py38_conda_forge_mkl_win-64_conda.lock CHECK_WARNINGS: 'true' - COVERAGE: 'true' + # The Azure Windows runner is typically much slower than other CI + # runners due to the lack of compiler cache. Running the tests with + # coverage enabled make them run extra slower. Since very few parts of + # code should have windows-specific code branches, it should be enable + # to restrict the code coverage collection to the non-windows runners. + COVERAGE: 'false' SKLEARN_ENABLE_DEBUG_CYTHON_DIRECTIVES: '1' SKLEARN_TESTS_GLOBAL_RANDOM_SEED: '7' # non-default seed From d5bd14280fd4733ba2fb01a76af16104a655e249 Mon Sep 17 00:00:00 2001 From: Olivier Grisel Date: Sun, 2 Apr 2023 14:00:08 +0200 Subject: [PATCH 2/4] Display a snippet of the content of the coverage file to upload [azure parallel] --- build_tools/azure/upload_codecov.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build_tools/azure/upload_codecov.sh b/build_tools/azure/upload_codecov.sh index 622d2e7fedeff..b60bd3b972b99 100755 --- a/build_tools/azure/upload_codecov.sh +++ b/build_tools/azure/upload_codecov.sh @@ -29,6 +29,13 @@ if [[ ! -f "$BUILD_REPOSITORY_LOCALPATH/.coverage" ]]; then echo "Could not find the combined coverage file at $BUILD_REPOSITORY_LOCALPATH/.coverage" exit 1 fi + +# Check the content of the .coverage file: +echo "Content of $BUILD_REPOSITORY_LOCALPATH/.coverage:" +head -n 10 $BUILD_REPOSITORY_LOCALPATH/.coverage +echo "..." +tail -n 10 $BUILD_REPOSITORY_LOCALPATH/.coverage + if [[ $OSTYPE == *"linux"* ]]; then curl -Os "$CODECOV_BASE_URL/linux/codecov" SHA256SUM="32cb14b5f3aaacd67f4c1ff55d82f037d3cd10c8e7b69c051f27391d2e66e15c codecov" From 517303465aeaa8f5f2106c0f3dd6c5529bd03446 Mon Sep 17 00:00:00 2001 From: Olivier Grisel Date: Sun, 2 Apr 2023 15:10:39 +0200 Subject: [PATCH 3/4] Export coverage data to xml prior to uploading to codecov [azure parallel] --- build_tools/azure/combine_coverage_reports.sh | 3 ++- build_tools/azure/upload_codecov.sh | 20 ++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/build_tools/azure/combine_coverage_reports.sh b/build_tools/azure/combine_coverage_reports.sh index e1f28c8f0e24a..c3b90fdd4fcdb 100755 --- a/build_tools/azure/combine_coverage_reports.sh +++ b/build_tools/azure/combine_coverage_reports.sh @@ -11,7 +11,8 @@ activate_environment # such as pytest-xdist and joblib/loky: pushd $TEST_DIR coverage combine --append +coverage xml popd # Copy the combined coverage file to the root of the repository: -cp $TEST_DIR/.coverage $BUILD_REPOSITORY_LOCALPATH +cp $TEST_DIR/coverage.xml $BUILD_REPOSITORY_LOCALPATH diff --git a/build_tools/azure/upload_codecov.sh b/build_tools/azure/upload_codecov.sh index b60bd3b972b99..30a754896b21f 100755 --- a/build_tools/azure/upload_codecov.sh +++ b/build_tools/azure/upload_codecov.sh @@ -24,33 +24,35 @@ if [[ ! -d "$BUILD_REPOSITORY_LOCALPATH/.git" ]]; then echo "Could not find the git checkout at $BUILD_REPOSITORY_LOCALPATH" exit 1 fi + # Check that the combined coverage file exists at the expected location: -if [[ ! -f "$BUILD_REPOSITORY_LOCALPATH/.coverage" ]]; then - echo "Could not find the combined coverage file at $BUILD_REPOSITORY_LOCALPATH/.coverage" +export COVERAGE_XML="$BUILD_REPOSITORY_LOCALPATH/coverage.xml" +if [[ ! -f "$COVERAGE_XML" ]]; then + echo "Could not find the combined coverage file at $COVERAGE_XML" exit 1 fi -# Check the content of the .coverage file: -echo "Content of $BUILD_REPOSITORY_LOCALPATH/.coverage:" -head -n 10 $BUILD_REPOSITORY_LOCALPATH/.coverage +# Check the content of the coverage.xml file: +echo "Content of $COVERAGE_XML:" +head -n 10 $COVERAGE_XML echo "..." -tail -n 10 $BUILD_REPOSITORY_LOCALPATH/.coverage +tail -n 10 $COVERAGE_XML if [[ $OSTYPE == *"linux"* ]]; then curl -Os "$CODECOV_BASE_URL/linux/codecov" SHA256SUM="32cb14b5f3aaacd67f4c1ff55d82f037d3cd10c8e7b69c051f27391d2e66e15c codecov" echo "$SHA256SUM" | shasum -a256 -c chmod +x codecov - ./codecov -t ${CODECOV_TOKEN} -R $BUILD_REPOSITORY_LOCALPATH -f .coverage -Z + ./codecov -t ${CODECOV_TOKEN} -R $BUILD_REPOSITORY_LOCALPATH -f coverage.xml -Z elif [[ $OSTYPE == *"darwin"* ]]; then curl -Os "$CODECOV_BASE_URL/macos/codecov" SHA256SUM="4ab0f06f06e9c4d25464f155b0aff36bfc1e8dbcdb19bfffd586beed1269f3af codecov" echo "$SHA256SUM" | shasum -a256 -c chmod +x codecov - ./codecov -t ${CODECOV_TOKEN} -R $BUILD_REPOSITORY_LOCALPATH -f .coverage -Z + ./codecov -t ${CODECOV_TOKEN} -R $BUILD_REPOSITORY_LOCALPATH -f coverage.xml -Z else curl -Os "$CODECOV_BASE_URL/windows/codecov.exe" SHA256SUM="e0cda212aeaebe695509ce8fa2d608760ff70bc932003f544f1ad368ac5450a8 codecov.exe" echo "$SHA256SUM" | sha256sum -c - ./codecov.exe -t ${CODECOV_TOKEN} -R $BUILD_REPOSITORY_LOCALPATH -f .coverage -Z + ./codecov.exe -t ${CODECOV_TOKEN} -R $BUILD_REPOSITORY_LOCALPATH -f coverage.xml -Z fi From e72289d419945e26bf4562f2dd210af52596435b Mon Sep 17 00:00:00 2001 From: Olivier Grisel Date: Sun, 2 Apr 2023 16:05:07 +0200 Subject: [PATCH 4/4] Remove debug prints [azure parallel] --- build_tools/azure/upload_codecov.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/build_tools/azure/upload_codecov.sh b/build_tools/azure/upload_codecov.sh index 30a754896b21f..f4ef9d3fe4c1f 100755 --- a/build_tools/azure/upload_codecov.sh +++ b/build_tools/azure/upload_codecov.sh @@ -32,12 +32,6 @@ if [[ ! -f "$COVERAGE_XML" ]]; then exit 1 fi -# Check the content of the coverage.xml file: -echo "Content of $COVERAGE_XML:" -head -n 10 $COVERAGE_XML -echo "..." -tail -n 10 $COVERAGE_XML - if [[ $OSTYPE == *"linux"* ]]; then curl -Os "$CODECOV_BASE_URL/linux/codecov" SHA256SUM="32cb14b5f3aaacd67f4c1ff55d82f037d3cd10c8e7b69c051f27391d2e66e15c codecov"