8000 CI Adds coverage to docker jobs on Azure by thomasjpfan · Pull Request #26027 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

CI Adds coverage to docker jobs on Azure #26027

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

Merged
merged 22 commits into from
Apr 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c19c8da
CI Adds coverage to docker jobs on Azure
thomasjpfan Mar 30, 2023
0694535
CI Use new script to combine coverage
thomasjpfan Mar 31, 2023
adf8e40
REV Revert
thomasjpfan Mar 31, 2023
608ecc0
CI Fixes repo local path
thomasjpfan Mar 31, 2023
7bb26ae
CI Combine coverage in windows
thomasjpfan Mar 31, 2023
e5c3010
Apply suggestions from code review
thomasjpfan Mar 31, 2023
82a628b
Apply suggestions from code review
thomasjpfan Mar 31, 2023
a0dace1
Trigger
ogrisel Apr 1, 2023
0f2acd4
upgrade codecov uploader and search coverage files directly from TEST…
ogrisel Apr 1, 2023
3c86cc4
Restrict upload to TEST_DIR/.coverage
ogrisel Apr 1, 2023
831afed
Fix ordering of the combine / codecov upload steps for windows
ogrisel Apr 1, 2023
c45956c
More explicit assertions on expected files and folders for the codeco…
ogrisel Apr 1, 2023
fdff0ee
Move the combined .coverage file back under BUILD_REPOSITORY_LOCALPATH
ogrisel Apr 1, 2023
d01e948
Fix typo in codecov cli flags [azure parallel]
ogrisel Apr 1, 2023
25ad492
Debug with ls -la [azure parallel]
ogrisel Apr 1, 2023
af82a42
Try again with codecov 0.4.0 instead [azure parallel]
ogrisel Apr 1, 2023
94500af
Revert "Try again with codecov 0.4.0 instead [azure parallel]"
ogrisel 8000 Apr 2, 2023
6491a26
Pass .coverage as a relative path [azure parallel]
ogrisel Apr 2, 2023
5b4e13b
Forward CODECOV_TOKEN in posix-docker.yml [azure parallel]
ogrisel Apr 2, 2023
7902b79
Fix typo in codecov cli flags [azure parallel]
ogrisel Apr 2, 2023
a971d83
Consistent step ordering on Windows [azure parallel]
ogrisel Apr 2, 2023
2fee8ac
Merge branch 'main' into coverage_docker_pr
ogrisel Apr 2, 2023
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
1 change: 1 addition & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ jobs:
debian_atlas_32bit:
DOCKER_CONTAINER: 'i386/debian:11.2'
DISTRIB: 'debian-32'
COVERAGE: "true"
LOCK_FILE: './build_tools/azure/debian_atlas_32bit_lock.txt'
# disable pytest xdist due to unknown bug with 32-bit container
PYTEST_XDIST_VERSION: 'none'
Expand Down
17 changes: 17 additions & 0 deletions build_tools/azure/combine_coverage_reports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e

# Defines the show_installed_libraries and activate_environment functions.
source build_tools/shared.sh

activate_environment

# Combine all coverage files generated by subprocesses workers such
# such as pytest-xdist and joblib/loky:
pushd $TEST_DIR
coverage combine --append
popd

# Copy the combined coverage file to the root of the repository:
cp $TEST_DIR/.coverage $BUILD_REPOSITORY_LOCALPATH
6 changes: 6 additions & 0 deletions build_tools/azure/debian_atlas_32bit_lock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#
attrs==22.2.0
# via pytest
coverage==7.2.2
# via pytest-cov
cython==0.29.33
# via -r build_tools/azure/debian_atlas_32bit_requirements.txt
joblib==1.1.1
Expand All @@ -19,6 +21,10 @@ pluggy==0.13.1
py==1.11.0
# via pytest
pytest==5.3.1
# via
# -r build_tools/azure/debian_atlas_32bit_requirements.txt
# pytest-cov
pytest-cov==2.9.0
# via -r build_tools/azure/debian_atlas_32bit_requirements.txt
threadpoolctl==2.2.0
# via -r build_tools/azure/debian_atlas_32bit_requirements.txt
Expand Down
1 change: 1 addition & 0 deletions build_tools/azure/debian_atlas_32bit_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ cython
joblib==1.1.1 # min
threadpoolctl==2.2.0
pytest==5.3.1 # min
pytest-cov==2.9.0 # min
15 changes: 15 additions & 0 deletions build_tools/azure/posix-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ jobs:
- script: >
docker container run --rm
--volume $TEST_DIR:/temp_dir
--volume $BUILD_REPOSITORY_LOCALPATH:/repo_localpath
--volume $PWD:/io
--volume $CCACHE_DIR:/ccache
-w /io
--detach
--name skcontainer
-e BUILD_SOURCESDIRECTORY=/io
-e TEST_DIR=/temp_dir
-e CCACHE_DIR=/ccache
-e BUILD_REPOSITORY_LOCALPATH=/repo_localpath
-e COVERAGE
-e DISTRIB
-e LOCK_FILE
-e JUNITXML
Expand All @@ -82,6 +86,11 @@ jobs:
- script: >
docker exec skcontainer ./build_tools/azure/test_script.sh
displayName: 'Test Library'
- script: >
docker exec skcontainer ./build_tools/azure/combine_coverage_reports.sh
condition: and(succeeded(), eq(variables['COVERAGE'], 'true'),
eq(variables['SELECTED_TESTS'], ''))
displayName: 'Combine coverage'
- task: PublishTestResults@2
inputs:
testResultsFiles: '$(TEST_DIR)/$(JUNITXML)'
Expand Down Expand Up @@ -116,3 +125,9 @@ jobs:
JUNIT_FILE: $(TEST_DIR)/$(JUNITXML)
condition: and(succeededOrFailed(), eq(variables['CREATE_ISSUE_ON_TRACKER'], 'true'),
eq(variables['Build.Reason'], 'Schedule'))
- bash: bash build_tools/azure/upload_codecov.sh
condition: and(succeeded(), eq(variables['COVERAGE'], 'true'),
eq(variables['SELECTED_TESTS'], ''))
displayName: 'Upload To Codecov'
env:
CODECOV_TOKEN: $(CODECOV_TOKEN)
5 changes: 5 additions & 0 deletions build_tools/azure/posix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ jobs:
condition: and(succeeded(),
eq(variables['CHECK_PYTEST_SOFT_DEPENDENCY'], 'true'),
eq(variables['SELECTED_TESTS'], ''))
- script: |
build_tools/azure/combine_coverage_reports.sh
condition: and(succeeded(), eq(variables['COVERAGE'], 'true'),
eq(variables['SELECTED_TESTS'], ''))
displayName: 'Combine coverage'
- task: PublishTestResults@2
inputs:
testResultsFiles: '$(TEST_DIR)/$(JUNITXML)'
Expand Down
8 changes: 2 additions & 6 deletions build_tools/azure/test_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@

set -e

# defines the show_installed_libraries function
# Defines the show_installed_libraries and activate_environment functions.
source build_tools/shared.sh

if [[ "$DISTRIB" =~ ^conda.* ]]; then
source activate $VIRTUALENV
elif [[ "$DISTRIB" == "ubuntu" || "$DISTRIB" == "debian-32" || "$DISTRIB" == "pip-nogil" ]]; then
source $VIRTUALENV/bin/activate
fi
activate_environment

if [[ "$BUILD_REASON" == "Schedule" ]]; then
# Enable global random seed randomization to discover seed-sensitive tests
Expand Down
49 changes: 28 additions & 21 deletions build_tools/azure/upload_codecov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,48 @@

set -e

# called when COVERAGE=="true" and DISTRIB=="conda"
export PATH=$HOME/miniconda3/bin:$PATH
source activate $VIRTUALENV

# Need to run codecov from a git checkout, so we copy .coverage
# from TEST_DIR where pytest has been run
pushd $TEST_DIR
coverage combine --append
popd
cp $TEST_DIR/.coverage $BUILD_REPOSITORY_LOCALPATH

# When we update the codecov uploader version, we need to update the checksums.
# The checksum for each codecov binary is available at
# https://uploader.codecov.io e.g. for linux
# https://uploader.codecov.io/v0.4.0/linux/codecov.SHA256SUM. In principle we
# need to check the signatures with the codecov gpg key as well, see
# https://uploader.codecov.io/v0.4.1/linux/codecov.SHA256SUM.

# Instead of hardcoding a specific version and signature in this script, it
# would be possible to use the "latest" symlink URL but then we need to
# download both the codecov.SHA256SUM files each time and check the signatures
# with the codecov gpg key as well, see:
# https://docs.codecov.com/docs/codecov-uploader#integrity-checking-the-uploader
# for more details
CODECOV_UPLOADER_VERSION=0.4.0
# However this approach would yield a larger number of downloads from
# codecov.io and keybase.io, therefore increasing the risk of running into
# network failures.
CODECOV_UPLOADER_VERSION=0.4.1
CODECOV_BASE_URL="https://uploader.codecov.io/v$CODECOV_UPLOADER_VERSION"


# Check that the git repo is located at the expected location:
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"
exit 1
fi
if [[ $OSTYPE == *"linux"* ]]; then
curl -Os "$CODECOV_BASE_URL/linux/codecov"
SHA256SUM="671cf0d89d1c149f57e1a9a31f3fb567ab4209e4d5829f13ff7b8c104db7131f codecov"
SHA256SUM="32cb14b5f3aaacd67f4c1ff55d82f037d3cd10c8e7b69c051f27391d2e66e15c codecov"
echo "$SHA256SUM" | shasum -a256 -c
chmod +x codecov
./codecov -t ${CODECOV_TOKEN} --rootDir $BUILD_REPOSITORY_LOCALPATH
./codecov -t ${CODECOV_TOKEN} -R $BUILD_REPOSITORY_LOCALPATH -f .coverage -Z
elif [[ $OSTYPE == *"darwin"* ]]; then
curl -Os "$CODECOV_BASE_URL/macos/codecov"
SHA256SUM="7549819f0fe115e113ec3538e259d748e87d84f68afa5deadc798967ec716b8d codecov"
SHA256SUM="4ab0f06f06e9c4d25464f155b0aff36bfc1e8dbcdb19bfffd586beed1269f3af codecov"
echo "$SHA256SUM" | shasum -a256 -c
chmod +x codecov
./codecov -t ${CODECOV_TOKEN} --rootDir $BUILD_REPOSITORY_LOCALPATH
./codecov -t ${CODECOV_TOKEN} -R $BUILD_REPOSITORY_LOCALPATH -f .coverage -Z
else
curl -Os "$CODECOV_BASE_URL/windows/codecov.exe"
SHA256SUM="15fb34be4eb9949ad4e964a0e21c4efc79657de05b2c799e041d7293dccf60eb codecov.exe"
SHA256SUM="e0cda212aeaebe695509ce8fa2d608760ff70bc932003f544f1ad368ac5450a8 codecov.exe"
echo "$SHA256SUM" | sha256sum -c
./codecov.exe -t ${CODECOV_TOKEN} --rootDir $BUILD_REPOSITORY_LOCALPATH
./codecov.exe -t ${CODECOV_TOKEN} -R $BUILD_REPOSITORY_LOCALPATH -f .coverage -Z
fi
16 changes: 10 additions & 6 deletions build_tools/azure/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,10 @@ jobs:
displayName: 'Install'
- bash: ./build_tools/azure/test_script.sh
displayName: 'Test Library'
- bash: ./build_tools/azure/upload_codecov.sh
condition: and(succeeded(),
eq(variables['COVERAGE'], 'true'),
- bash: ./build_tools/azure/combine_coverage_reports.sh
condition: and(succeeded(), eq(variables['COVERAGE'], 'true'),
eq(variables['SELECTED_TESTS'], ''))
displayName: 'Upload To Codecov'
env:
CODECOV_TOKEN: $(CODECOV_TOKEN)
displayName: 'Combine coverage'
- task: PublishTestResults@2
inputs:
testResultsFiles: '$(TEST_DIR)/$(JUNITXML)'
Expand Down Expand Up @@ -78,3 +75,10 @@ jobs:
JUNIT_FILE: $(TEST_DIR)/$(JUNITXML)
condition: and(succeededOrFailed(), eq(variables['CREATE_ISSUE_ON_TRACKER'], 'true'),
eq(variables['Build.Reason'], 'Schedule'))
- bash: ./build_tools/azure/upload_codecov.sh
condition: and(succeeded(),
eq(variables['COVERAGE'], 'true'),
eq(variables['SELECTED_TESTS'], ''))
displayName: 'Upload To Codecov'
env:
CODECOV_TOKEN: $(CODECOV_TOKEN)
8 changes: 8 additions & 0 deletions build_tools/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ show_installed_libraries(){
python -m pip list
fi
}

activate_environment() {
if [[ "$DISTRIB" =~ ^conda.* ]]; then
source activate $VIRTUALENV
elif [[ "$DISTRIB" == "ubuntu" || "$DISTRIB" == "debian-32" || "$DISTRIB" == "pip-nogil" ]]; then
source $VIRTUALENV/bin/activate
fi
}
9 changes: 8 additions & 1 deletion build_tools/update_environments_and_lock_files.py
7817
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,18 @@ def remove_from(alist, to_remove):
{
"build_name": "debian_atlas_32bit",
"folder": "build_tools/azure",
"pip_dependencies": ["cython", "joblib", "threadpoolctl", "pytest"],
"pip_dependencies": [
"cython",
"joblib",
"threadpoolctl",
"pytest",
"pytest-cov",
],
"package_constraints": {
"joblib": "min",
"threadpoolctl": "2.2.0",
"pytest": "min",
"pytest-cov": "min",
# no pytest-xdist because it causes issue on 32bit
},
# same Python version as in debian-32 build
Expand Down
0