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

Use pytest-split to distribute CI tests over multiple runners #369

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 21 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ concurrency:

jobs:
test-windows:
strategy:
fail-fast: false
matrix:
pytest-split-group: [1, 2, 3, 4, 5]
pytest-split-groups: [5]
env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
Expand All @@ -34,7 +39,7 @@ jobs:
- name: Install dev deps
run: |
conda activate test
mamba install pip pytest-cov pytest-xdist
mamba install pip pytest-cov pytest-xdist pytest-split
python -m pip install -r requirements-dev.txt

- name: install conda-lock
Expand All @@ -50,7 +55,7 @@ jobs:
pushd "${RUNNER_TEMP}"
set TMPDIR="%RUNNER_TEMP%"
dir
pytest --cov=conda_lock --cov-branch --cov-report=xml --cov-report=term tests
pytest --cov=conda_lock --cov-branch --cov-report=xml --cov-report=term --splits ${{ matrix.pytest-split-groups }} --group ${{ matrix.pytest-split-group }} tests
copy coverage.xml %GITHUB_WORKSPACE%
- uses: codecov/codecov-action@v3

Expand All @@ -61,6 +66,18 @@ jobs:
matrix:
os: [ ubuntu-latest, macos-latest ]
python-version: [ "3.8", "3.11" ]
pytest-split-group: [1, 2, 3]
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we can use non integer identifiers for these groups that would be better, since I have no idea what group 4 means

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can add comments. Pytest-split tries to divide the tests into n groups labeled 1, ..., n which have approximately the same total runtime. So they have to be integers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The runs are labeled like "test / ... (3, 5)" which is run number 3 out of 5.

pytest-split-groups: [2, 3]
exclude:
- os: ubuntu-latest
# Force pytest-split-groups to 2 by excluding 3
pytest-split-groups: 3
- os: macos-latest
# Force pytest-split-groups to 3 by excluding 2
pytest-split-groups: 2
- os: ubuntu-latest
# Don't run the third group on ubuntu
pytest-split-group: 3
defaults:
run:
shell: bash -l {0}
Expand All @@ -81,7 +98,7 @@ jobs:
- name: Install dev deps
run: |
conda activate test
mamba install pip pytest-cov pytest-xdist
mamba install pip pytest-cov pytest-xdist pytest-split
set -x
echo "${PATH}"
which pip
Expand All @@ -106,7 +123,7 @@ jobs:
ls -lah
set -x
which pytest
pytest --cov=conda_lock --cov-branch --cov-report=xml --cov-report=term tests
pytest --cov=conda_lock --cov-branch --cov-report=xml --cov-report=term --splits ${{ matrix.pytest-split-group }} --group ${{ matrix.pytest-split-group }} tests
cp coverage.xml "${GITHUB_WORKSPACE}"
- uses: codecov/codecov-action@v3

Expand Down
120 changes: 120 additions & 0 deletions .test_durations
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Guess this needs a gitignore

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, it's required, but it could probably live under tests/

"conda_lock/models/test_channel.py::test__detect_used_env_var": 0.0044590262696146965,
"conda_lock/models/test_channel.py::test_url_auth_info": 0.01338486629538238,
"tests/test_conda_lock.py::test__add_auth_to_line[# pip mypackage @ https://pypi.mychannel.cloud/simple-auth4-# pip mypackage @ https://username1:[email protected]/simple]": 0.0027642359491437674,
"tests/test_conda_lock.py::test__add_auth_to_line[# pip mypackage @ https://pypi.otherchannel.cloud/simple-auth5-# pip mypackage @ https://pypi.otherchannel.cloud/simple]": 0.0021687184926122427,
"tests/test_conda_lock.py::test__add_auth_to_line[https://conda.mychannel.cloud/channel1/mypackage-auth2-https://username:[email protected]/channel1/mypackage]": 0.0022148219868540764,
"tests/test_conda_lock.py::test__add_auth_to_line[https://conda.mychannel.cloud/channel1/mypackage-auth3-https://username1:[email protected]/channel1/mypackage]": 0.0020119459368288517,
"tests/test_conda_lock.py::test__add_auth_to_line[https://conda.mychannel.cloud/mypackage-auth0-https://username:[email protected]/mypackage]": 0.0020599619019776583,
"tests/test_conda_lock.py::test__add_auth_to_line[https://conda.mychannel.cloud/mypackage-auth1-https://conda.mychannel.cloud/mypackage]": 0.0018740820232778788,
"tests/test_conda_lock.py::test__add_auth_to_lockfile[# The following domains require authentication:\\n# - a.mychannel.cloud\\n# - c.mychannel.cloud\\n# - d.mychannel.cloud\\nhttp://a.mychannel.cloud/mypackage\\nhttp://b.mychannel.cloud/mypackage\\nhttp://c.mychannel.cloud/mypackage\\n# pip mypackage @ http://d.mychannel.cloud/mypackage\\n-# The following domains require authentication:\\n# - a.mychannel.cloud\\n# - c.mychannel.cloud\\n# - d.mychannel.cloud\\nhttp://username_a:[email protected]/mypackage\\nhttp://b.mychannel.cloud/mypackage\\nhttp://username_c:[email protected]/mypackage\\n# pip mypackage @ http://username_d:[email protected]/mypackage\\n]": 0.0021428640466183424,
"tests/test_conda_lock.py::test__extract_domain[# pip mypackage @ https://pypi.mychannel.cloud/simple-pypi.mychannel.cloud]": 0.004476058064028621,
"tests/test_conda_lock.py::test__extract_domain[http://conda.mychannel.cloud/mypackage-conda.mychannel.cloud]": 0.00953778624534607,
"tests/test_conda_lock.py::test__extract_domain[https://conda.mychannel.cloud/mypackage-conda.mychannel.cloud]": 0.01166083524003625,
"tests/test_conda_lock.py::test__strip_auth_from_line[# pip mypackage @ https://pypi.mychannel.cloud/simple-# pip mypackage @ https://pypi.mychannel.cloud/simple]": 0.004538550041615963,
"tests/test_conda_lock.py::test__strip_auth_from_line[# pip mypackage @ https://username1:[email protected]/simple-# pip mypackage @ https://pypi.mychannel.cloud/simple]": 0.004323852248489857,
"tests/test_conda_lock.py::test__strip_auth_from_line[http://conda.mychannel.cloud/mypackage-http://conda.mychannel.cloud/mypackage]": 0.0055056612472981215,
"tests/test_conda_lock.py::test__strip_auth_from_line[http://user:[email protected]/mypackage-http://conda.mychannel.cloud/mypackage]": 0.005796841811388731,
"tests/test_conda_lock.py::test__strip_auth_from_line[https://conda.mychannel.cloud/mypackage-https://conda.mychannel.cloud/mypackage]": 0.015453723957762122,
"tests/test_conda_lock.py::test__strip_auth_from_line[https://user:[email protected]/mypackage-https://conda.mychannel.cloud/mypackage]": 0.013227654155343771,
"tests/test_conda_lock.py::test__strip_auth_from_lockfile[http://a.mychannel.cloud/mypackage\\nhttp://b.mychannel.cloud/mypackage\\nhttp://c.mychannel.cloud/mypackage\\n# pip mypackage @ http://d.mychannel.cloud/mypackage\\n-http://a.mychannel.cloud/mypackage\\nhttp://b.mychannel.cloud/mypackage\\nhttp://c.mychannel.cloud/mypackage\\n# pip mypackage @ http://d.mychannel.cloud/mypackage\\n]": 0.0017164601013064384,
"tests/test_conda_lock.py::test__strip_auth_from_lockfile[http://user:[email protected]/mypackage\\nhttp://b.mychannel.cloud/mypackage\\nhttp://user:[email protected]/mypackage\\n# pip mypackage @ http://user:[email protected]/mypackage\\n-# The following domains require authentication:\\n# - a.mychannel.cloud\\n# - c.mychannel.cloud\\n# - d.mychannel.cloud\\nhttp://a.mychannel.cloud/mypackage\\nhttp://b.mychannel.cloud/mypackage\\nhttp://c.mychannel.cloud/mypackage\\n# pip mypackage @ http://d.mychannel.cloud/mypackage\\n]": 0.0019474257715046406,
"tests/test_conda_lock.py::test_aggregate_lock_specs": 1.2763855010271072,
"tests/test_conda_lock.py::test_aggregate_lock_specs_invalid_channels": 0.03590670810081065,
"tests/test_conda_lock.py::test_aggregate_lock_specs_multiple_platforms": 0.006713381968438625,
"tests/test_conda_lock.py::test_aggregate_lock_specs_override_version": 1.6720386389642954,
"tests/test_conda_lock.py::test_choose_wheel": 7.891909349011257,
"tests/test_conda_lock.py::test_cli_version": 1.0643445942550898,
"tests/test_conda_lock.py::test_default_virtual_package_input_hash_stability": 0.005248077679425478,
"tests/test_conda_lock.py::test_extract_json_object": 0.0016865991055965424,
"tests/test_conda_lock.py::test_fake_conda_env[conda]": 2.4932802789844573,
"tests/test_conda_lock.py::test_fake_conda_env[mamba]": 3.1682756498921663,
"tests/test_conda_lock.py::test_fake_conda_env[micromamba]": 1.2988834620919079,
"tests/test_conda_lock.py::test_install[conda-env]": 140.27129216119647,
"tests/test_conda_lock.py::test_install[conda-explicit]": 19.50872055394575,
"tests/test_conda_lock.py::test_install[mamba-env]": 19.579558146651834,
"tests/test_conda_lock.py::test_install[mamba-explicit]": 9.53389447904192,
"tests/test_conda_lock.py::test_install[micromamba-env]": 6.250606240937486,
"tests/test_conda_lock.py::test_install[micromamba-explicit]": 9.245201598852873,
"tests/test_conda_lock.py::test_lock_poetry_ibis": 42.33643715083599,
"tests/test_conda_lock.py::test_parse_env_file_with_filters_defaults": 0.017547639086842537,
"tests/test_conda_lock.py::test_parse_env_file_with_filters_no_args": 0.013967463746666908,
"tests/test_conda_lock.py::test_parse_environment_file": 0.017137509072199464,
"tests/test_conda_lock.py::test_parse_environment_file_with_pip": 0.014858064008876681,
"tests/test_conda_lock.py::test_parse_flit": 0.006220192881301045,
"tests/test_conda_lock.py::test_parse_meta_yaml_file": 0.06765178288333118,
"tests/test_conda_lock.py::test_parse_pdm": 7.360471409978345,
"tests/test_conda_lock.py::test_parse_pip_requirement[package-thingie1[foo]-parsed0]": 0.002158720977604389,
"tests/test_conda_lock.py::test_parse_pip_requirement[package[extra] = 2.1-parsed2]": 0.0019457850139588118,
"tests/test_conda_lock.py::test_parse_pip_requirement[package[extra] == 2.1-parsed3]": 0.0023466390557587147,
"tests/test_conda_lock.py::test_parse_pip_requirement[package[extra] >=0.8.0-alpha.2,<1.0.0.0-parsed6]": 0.005290928995236754,
"tests/test_conda_lock.py::test_parse_pip_requirement[package[extra] >=2.1.*, <4.0-parsed5]": 0.0069599400740116835,
"tests/test_conda_lock.py::test_parse_pip_requirement[package[extra] @ https://foo.bar/package.whl#sha1=blerp-parsed1]": 0.0019281471613794565,
"tests/test_conda_lock.py::test_parse_pip_requirement[package[extra]===2.1-parsed4]": 0.0021447089966386557,
"tests/test_conda_lock.py::test_parse_poetry": 6.9989939029328525,
"tests/test_conda_lock.py::test_parse_poetry_no_pypi": 0.0075933379121124744,
"tests/test_conda_lock.py::test_poetry_version_parsing_constraints[python->=3.6,<3.7-/python-3.6]": 8.781420079059899,
"tests/test_conda_lock.py::test_poetry_version_parsing_constraints[python-^2.7-/python-2.7]": 32.686923403060064,
"tests/test_conda_lock.py::test_poetry_version_parsing_constraints[python-~3.6-/python-3.6]": 7.1190555829089135,
"tests/test_conda_lock.py::test_prepare_repositories_pool": 0.01316592376679182,
"tests/test_conda_lock.py::test_private_lock[conda-$QUETZ_API_KEY]": 167.53543734387495,
"tests/test_conda_lock.py::test_private_lock[conda-${QUETZ_API_KEY}]": 14.05618537706323,
"tests/test_conda_lock.py::test_private_lock[mamba-$QUETZ_API_KEY]": 29.20311124715954,
"tests/test_conda_lock.py::test_private_lock[mamba-${QUETZ_API_KEY}]": 10.083066730760038,
"tests/test_conda_lock.py::test_private_lock[micromamba-$QUETZ_API_KEY]": 7.757304751081392,
"tests/test_conda_lock.py::test_private_lock[micromamba-${QUETZ_API_KEY}]": 0.04886101931333542,
"tests/test_conda_lock.py::test_run_lock[conda]": 83.847992134979,
"tests/test_conda_lock.py::test_run_lock[mamba]": 43.905100357951596,
"tests/test_conda_lock.py::test_run_lock[micromamba]": 44.00821655779146,
"tests/test_conda_lock.py::test_run_lock_blas_mkl[conda]": 27.50570274796337,
"tests/test_conda_lock.py::test_run_lock_blas_mkl[mamba]": 7.7282587920781225,
"tests/test_conda_lock.py::test_run_lock_blas_mkl[micromamba]": 6.085412611020729,
"tests/test_conda_lock.py::test_run_lock_regression_gh155[conda]": 12.19158754707314,
"tests/test_conda_lock.py::test_run_lock_regression_gh155[mamba]": 9.053441614843905,
"tests/test_conda_lock.py::test_run_lock_regression_gh155[micromamba]": 4.326663556043059,
"tests/test_conda_lock.py::test_run_lock_relative_source_path[conda]": 2.4107686991337687,
"tests/test_conda_lock.py::test_run_lock_relative_source_path[mamba]": 2.4218363990075886,
"tests/test_conda_lock.py::test_run_lock_relative_source_path[micromamba]": 2.246905382955447,
"tests/test_conda_lock.py::test_run_lock_uppercase_pip[conda]": 12.315469726920128,
"tests/test_conda_lock.py::test_run_lock_uppercase_pip[mamba]": 7.507358531001955,
"tests/test_conda_lock.py::test_run_lock_uppercase_pip[micromamba]": 3.7060587687883526,
"tests/test_conda_lock.py::test_run_lock_with_custom_metadata[conda]": 16.25292714405805,
"tests/test_conda_lock.py::test_run_lock_with_custom_metadata[mamba]": 76.81640638317913,
"tests/test_conda_lock.py::test_run_lock_with_custom_metadata[micromamba]": 3.5591639990452677,
"tests/test_conda_lock.py::test_run_lock_with_git_metadata[conda]": 16.833537717116997,
"tests/test_conda_lock.py::test_run_lock_with_git_metadata[mamba]": 7.034437482943758,
"tests/test_conda_lock.py::test_run_lock_with_git_metadata[micromamba]": 3.538599671330303,
"tests/test_conda_lock.py::test_run_lock_with_input_hash_check[conda]": 34.062637554015964,
"tests/test_conda_lock.py::test_run_lock_with_input_hash_check[mamba]": 2.547731716185808,
"tests/test_conda_lock.py::test_run_lock_with_input_hash_check[micromamba]": 2.074163547018543,
"tests/test_conda_lock.py::test_run_lock_with_input_metadata[conda]": 19.766404184978455,
"tests/test_conda_lock.py::test_run_lock_with_input_metadata[mamba]": 6.900205792160705,
"tests/test_conda_lock.py::test_run_lock_with_input_metadata[micromamba]": 51.49917463120073,
"tests/test_conda_lock.py::test_run_lock_with_local_package[conda]": 0.011794581077992916,
"tests/test_conda_lock.py::test_run_lock_with_local_package[mamba]": 0.02334260498173535,
"tests/test_conda_lock.py::test_run_lock_with_local_package[micromamba]": 0.012574640102684498,
"tests/test_conda_lock.py::test_run_lock_with_locked_environment_files[conda]": 2.585544525878504,
"tests/test_conda_lock.py::test_run_lock_with_locked_environment_files[mamba]": 2.785396486055106,
"tests/test_conda_lock.py::test_run_lock_with_locked_environment_files[micromamba]": 15.509860154706985,
"tests/test_conda_lock.py::test_run_lock_with_pip[conda]": 352.00825743796304,
"tests/test_conda_lock.py::test_run_lock_with_pip[mamba]": 7.3949902430176735,
"tests/test_conda_lock.py::test_run_lock_with_pip[micromamba]": 21.479689084924757,
"tests/test_conda_lock.py::test_run_lock_with_pip_environment_different_names_same_deps[conda]": 14.562333019217476,
"tests/test_conda_lock.py::test_run_lock_with_pip_environment_different_names_same_deps[mamba]": 15.594794017029926,
"tests/test_conda_lock.py::test_run_lock_with_pip_environment_different_names_same_deps[micromamba]": 54.5677305161953,
"tests/test_conda_lock.py::test_run_lock_with_time_metadata[conda]": 16.39776355284266,
"tests/test_conda_lock.py::test_run_lock_with_time_metadata[mamba]": 5.529624433722347,
"tests/test_conda_lock.py::test_run_lock_with_time_metadata[micromamba]": 2.918327509891242,
"tests/test_conda_lock.py::test_run_lock_with_update[conda]": 155.17123162886128,
"tests/test_conda_lock.py::test_run_lock_with_update[mamba]": 9.115055882139131,
"tests/test_conda_lock.py::test_run_lock_with_update[micromamba]": 43.55620776605792,
"tests/test_conda_lock.py::test_run_with_channel_inversion": 114.43516132631339,
"tests/test_conda_lock.py::test_spec_poetry": 0.00874163187108934,
"tests/test_conda_lock.py::test_virtual_package_input_hash_stability": 0.004808719968423247,
"tests/test_conda_lock.py::test_virtual_packages[conda-env]": 40.06911605782807,
"tests/test_conda_lock.py::test_virtual_packages[conda-explicit]": 166.67617870983668,
"tests/test_conda_lock.py::test_virtual_packages[mamba-env]": 9.238974520936608,
"tests/test_conda_lock.py::test_virtual_packages[mamba-explicit]": 3.896394713083282,
"tests/test_conda_lock.py::test_virtual_packages[micromamba-env]": 8.28422360913828,
"tests/test_conda_lock.py::test_virtual_packages[micromamba-explicit]": 8.922804991714656
}