Skip to content

Commit 5736956

Browse files
CI add codecov to GitHub Action workflow (scikit-learn#31941)
Co-authored-by: Loïc Estève <loic.esteve@ymail.com>
1 parent 56da56f commit 5736956

File tree

7 files changed

+33
-14
lines changed

7 files changed

+33
-14
lines changed

.codecov.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@ coverage:
1919

2020
codecov:
2121
notify:
22-
# Prevent coverage status to upload multiple times for parallel and long
23-
# running CI pipelines. This configuration is particularly useful on PRs
24-
# to avoid confusion. Note that this value is set to the number of Azure
25-
# Pipeline jobs uploading coverage reports.
26-
after_n_builds: 6
22+
# Prevent codecov from calculating the coverage results before all expected uploads
23+
# are in. This value is set to the total number of jobs uploading coverage reports.
24+
after_n_builds: 7
2725

2826
ignore:
2927
- "sklearn/externals"

.github/workflows/unit-tests.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ env:
1414
VIRTUALENV: testvenv
1515
TEST_DIR: ${{ github.workspace }}/tmp_folder
1616
CCACHE_DIR: ${{ github.workspace }}/ccache
17+
COVERAGE: 'true'
1718

1819
jobs:
1920
lint:
@@ -80,3 +81,19 @@ jobs:
8081

8182
- name: Run tests
8283
run: bash -l build_tools/azure/test_script.sh
84+
85+
- name: Combine coverage reports from parallel test runners
86+
run: bash -l build_tools/azure/combine_coverage_reports.sh
87+
if: ${{ env.COVERAGE == 'true' }}
88+
89+
- name: Upload coverage report to Codecov
90+
uses: codecov/codecov-action@v5
91+
# TODO: should depend on whether we run the whole test suite (could be by adding
92+
# && env.SELECTED_TESTS == '' as in build_tools/azure/posix.yml, or setting
93+
# env.COVERAGE == 'false' before the "Run tests" step, so reports are not
94+
# generated at all)
95+
if: ${{ env.COVERAGE == 'true' }}
96+
with:
97+
files: ./coverage.xml
98+
token: ${{ secrets.CODECOV_TOKEN }}
99+
disable_search: true

build_tools/azure/combine_coverage_reports.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ source build_tools/shared.sh
88
activate_environment
99

1010
# Combine all coverage files generated by subprocesses workers such
11-
# such as pytest-xdist and joblib/loky:
11+
# as pytest-xdist and joblib/loky:
1212
pushd $TEST_DIR
1313
coverage combine --append
1414
coverage xml
1515
popd
1616

1717
# Copy the combined coverage file to the root of the repository:
18-
cp $TEST_DIR/coverage.xml $BUILD_REPOSITORY_LOCALPATH
18+
cp $TEST_DIR/coverage.xml .

build_tools/azure/test_script.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ if [[ "$COMMIT_MESSAGE" =~ \[float32\] ]]; then
2929
export SKLEARN_RUN_FLOAT32_TESTS=1
3030
fi
3131

32+
CHECKOUT_FOLDER=$PWD
3233
mkdir -p $TEST_DIR
3334
cp pyproject.toml $TEST_DIR
3435
cd $TEST_DIR
@@ -42,19 +43,19 @@ show_installed_libraries
4243
TEST_CMD="python -m pytest --showlocals --durations=20 --junitxml=$JUNITXML -o junit_family=legacy"
4344

4445
if [[ "$COVERAGE" == "true" ]]; then
45-
# Note: --cov-report= is used to disable to long text output report in the
46+
# Note: --cov-report= is used to disable too long text output report in the
4647
# CI logs. The coverage data is consolidated by codecov to get an online
4748
# web report across all the platforms so there is no need for this text
4849
# report that otherwise hides the test failures and forces long scrolls in
4950
# the CI logs.
50-
export COVERAGE_PROCESS_START="$BUILD_SOURCESDIRECTORY/.coveragerc"
51+
export COVERAGE_PROCESS_START="$CHECKOUT_FOLDER/.coveragerc"
5152

5253
# Use sys.monitoring to make coverage faster for Python >= 3.12
5354
HAS_SYSMON=$(python -c 'import sys; print(sys.version_info >= (3, 12))')
5455
if [[ "$HAS_SYSMON" == "True" ]]; then
5556
export COVERAGE_CORE=sysmon
5657
fi
57-
TEST_CMD="$TEST_CMD --cov-config='$COVERAGE_PROCESS_START' --cov sklearn --cov-report="
58+
TEST_CMD="$TEST_CMD --cov-config='$COVERAGE_PROCESS_START' --cov=sklearn --cov-report="
5859
fi
5960

6061
if [[ "$PYTEST_XDIST_VERSION" != "none" ]]; then

build_tools/github/pymin_conda_forge_arm_environment.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,7 @@ dependencies:
1818
- pip
1919
- ninja
2020
- meson-python
21+
- pytest-cov
22+
- coverage
2123
- pip
2224
- ccache

build_tools/github/pymin_conda_forge_arm_linux-aarch64_conda.lock

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Generated by conda-lock.
22
# platform: linux-aarch64
3-
# input_hash: f12646c755adbf5f02f95c5d07e868bf1570777923e737bc27273eb1a5e40cd7
3+
# input_hash: 8eb842b860f2b03822d6d35414070c39f2efbb0f464d44310dc4696eec777227
44
@EXPLICIT
55
https://conda.anaconda.org/conda-forge/noarch/font-ttf-dejavu-sans-mono-2.37-hab24e00_0.tar.bz2#0c96522c6bdaed4b1566d11387caaf45
66
https://conda.anaconda.org/conda-forge/noarch/font-ttf-inconsolata-3.000-h77eed37_0.tar.bz2#34893075a5c9e55cdafac56607368fc6
@@ -105,6 +105,7 @@ https://conda.anaconda.org/conda-forge/noarch/pyparsing-3.2.3-pyhe01879c_2.conda
105105
https://conda.anaconda.org/conda-forge/noarch/setuptools-80.9.0-pyhff2d567_0.conda#4de79c071274a53dcaf2a8c749d1499e
106106
https://conda.anaconda.org/conda-forge/noarch/six-1.17.0-pyhe01879c_1.conda#3339e3b65d58accf4ca4fb8748ab16b3
107107
https://conda.anaconda.org/conda-forge/noarch/threadpoolctl-3.6.0-pyhecae5ae_0.conda#9d64911b31d57ca443e9f1e36b04385f
108+
https://conda.anaconda.org/conda-forge/noarch/toml-0.10.2-pyhd8ed1ab_1.conda#b0dd904de08b7db706167240bf37b164
108109
https://conda.anaconda.org/conda-forge/noarch/tomli-2.2.1-pyhe01879c_2.conda#30a0a26c8abccf4b7991d590fe17c699
109110
https://conda.anaconda.org/conda-forge/linux-aarch64/tornado-6.5.2-py310ha7967c6_0.conda#443b9fabfa1a26f93551ba75797b658a
110111
https://conda.anaconda.org/conda-forge/noarch/typing_extensions-4.14.1-pyhe01879c_0.conda#e523f4f1e980ed7a4240d7e27e9ec81f
@@ -116,6 +117,7 @@ https://conda.anaconda.org/conda-forge/linux-aarch64/xorg-libxext-1.3.6-h57736b2
116117
https://conda.anaconda.org/conda-forge/linux-aarch64/xorg-libxfixes-6.0.1-h57736b2_0.conda#78f8715c002cc66991d7c11e3cf66039
117118
https://conda.anaconda.org/conda-forge/linux-aarch64/xorg-libxrender-0.9.12-h86ecc28_0.conda#ae2c2dd0e2d38d249887727db2af960e
118119
https://conda.anaconda.org/conda-forge/linux-aarch64/ccache-4.11.3-h4889ad1_0.conda#e0b9e519da2bf0fb8c48381daf87a194
120+
https://conda.anaconda.org/conda-forge/linux-aarch64/coverage-7.10.5-py310h3b5aacf_0.conda#8b34a4c575c644ea70a55aee4cd532bf
119121
https://conda.anaconda.org/conda-forge/linux-aarch64/dbus-1.16.2-heda779d_0.conda#9203b74bb1f3fa0d6f308094b3b44c1e
120122
https://conda.anaconda.org/conda-forge/noarch/exceptiongroup-1.3.0-pyhd8ed1ab_0.conda#72e42d28960d875c7654614f8b50939a
121123
https://conda.anaconda.org/conda-forge/linux-aarch64/fonttools-4.59.1-py310h2d8da20_0.conda#13f1971056891c4746589e08c84d62b3
@@ -151,6 +153,7 @@ https://conda.anaconda.org/conda-forge/linux-aarch64/xorg-libxtst-1.2.5-h57736b2
151153
https://conda.anaconda.org/conda-forge/linux-aarch64/blas-devel-3.9.0-34_h9678261_openblas.conda#ca55bf55f4dd0b3eb5965a0646d038ce
152154
https://conda.anaconda.org/conda-forge/linux-aarch64/cairo-1.18.4-h83712da_0.conda#cd55953a67ec727db5dc32b167201aa6
153155
https://conda.anaconda.org/conda-forge/linux-aarch64/contourpy-1.3.2-py310hf54e67a_0.conda#779694434d1f0a67c5260db76b7b7907
156+
https://conda.anaconda.org/conda-forge/noarch/pytest-cov-6.2.1-pyhd8ed1ab_0.conda#ce978e1b9ed8b8d49164e90a5cdc94cd
154157
https://conda.anaconda.org/conda-forge/noarch/pytest-xdist-3.8.0-pyhd8ed1ab_0.conda#8375cfbda7c57fbceeda18229be10417
155158
https://conda.anaconda.org/conda-forge/linux-aarch64/scipy-1.15.2-py310hf37559f_0.conda#5c9b72f10d2118d943a5eaaf2f396891
156159
https://conda.anaconda.org/conda-forge/linux-aarch64/blas-2.134-openblas.conda#20a3b428eeca10be2baee7b1a27a80ee

build_tools/update_environments_and_lock_files.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,7 @@ def remove_from(alist, to_remove):
393393
"folder": "build_tools/github",
394394
"platform": "linux-aarch64",
395395
"channels": ["conda-forge"],
396-
"conda_dependencies": remove_from(
397-
common_dependencies_without_coverage, ["pandas", "pyamg"]
398-
)
396+
"conda_dependencies": remove_from(common_dependencies, ["pandas", "pyamg"])
399397
+ ["pip", "ccache"],
400398
"package_constraints": {
401399
"python": "3.10",

0 commit comments

Comments
 (0)