Skip to content

Commit

Permalink
split unit tests, parcel smoke tests and multi-process/condensation e…
Browse files Browse the repository at this point in the history
…xamples into multiple jobs to reduce CI time; introduce pip cache for examples jobs (#1315)
  • Loading branch information
slayoo authored Apr 14, 2024
1 parent ec7af2e commit c38c81f
Show file tree
Hide file tree
Showing 48 changed files with 84 additions and 41 deletions.
86 changes: 63 additions & 23 deletions .github/workflows/tests+artifacts+pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ jobs:
matrix:
platform: [ubuntu-latest, macos-12, windows-latest]
python-version: ["3.8", "3.11"]
test-suite: ["unit_tests", "smoke_tests/no_env", "smoke_tests/box", "smoke_tests/parcel", "smoke_tests/kinematic_1d", "smoke_tests/kinematic_2d", "tutorials_tests"]
test-suite: ["unit_tests/!(dynamics)", "unit_tests/dynamics/!(condensation)", "unit_tests/dynamics/condensation", "smoke_tests/no_env", "smoke_tests/box", "smoke_tests/parcel_a", "smoke_tests/parcel_b", "smoke_tests/parcel_c", "smoke_tests/kinematic_1d", "smoke_tests/kinematic_2d", "tutorials_tests"]
exclude:
- test-suite: "devops_tests"
python-version: "3.8"
fail-fast: false
runs-on: ${{ matrix.platform }}
timeout-minutes: 100
timeout-minutes: 40
steps:
- uses: actions/[email protected]
with:
Expand All @@ -142,47 +142,80 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- run: |
pip install -e .
- run: pip install -e .

# sanity check if we do not depend on something from tests extras
- run: |
python -We -c "import PySDM"
- run: |
pip install -e ./examples
pip install -e .[tests]
- run: python -We -c "import PySDM"

# ensure previous pip did not overwrite the package
- run: |
pip install -e .
- if: startsWith(matrix.test-suite, 'smoke_tests') || matrix.test-suite == 'tutorials_tests'
run: pip install -e ./examples

# https://github.com/numba/numba/issues/6350#issuecomment-728174860
- if: startsWith(matrix.platform, 'ubuntu-')
run: echo NUMBA_THREADING_LAYER=omp >> $GITHUB_ENV
- run: pip install -e .[tests] # incl. ensuring that the previous pip did not overwrite the package

# install devops_tests for tutorials_tests
- if: matrix.test-suite == 'tutorials_tests'
run: pip install -r tests/devops_tests/requirements.txt

- env:
# https://github.com/numba/numba/issues/6350#issuecomment-728174860
- if: startsWith(matrix.platform, 'ubuntu-')
run: echo NUMBA_THREADING_LAYER=omp >> $GITHUB_ENV

- name: Run pytest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pytest --durations=10 --timeout=900 --timeout_method=thread -p no:unraisableexception -We tests/${{ matrix.test-suite }}
NUMBA_OPT: 1
run: |
shopt -s extglob
pytest --durations=10 --timeout=900 --timeout_method=thread -p no:unraisableexception -We tests/${{ matrix.test-suite }}
# - if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
# with:
# limit-access-to-actor: true

examples-setup:
strategy:
matrix:
platform: [ubuntu-22.04, macos-12, windows-latest]
python-version: ["3.8", "3.11"]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- run: |
echo pip_user_site=$(python -c "import sysconfig; print(sysconfig.get_path('purelib'))") >> $GITHUB_ENV
echo toml_ci_md5=$(cat pyproject.toml setup.py examples/pyproject.toml examples/setup.py tests/devops_tests/requirements.txt .github/workflows/tests+artifacts+pypi.yml \
| python -c "import hashlib;print(hashlib.md5(open(0,'rb').read()).hexdigest())") >> $GITHUB_ENV
- uses: actions/cache@v4
with:
path: ${{ env.pip_user_site }}
key: examples_pip_cache-${{ matrix.platform }}-${{ matrix.python-version }}-${{ env.toml_ci_md5 }}
- if: steps.cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade --user pip
python -m pip install -e . ./examples
python -m pip install -r tests/devops_tests/requirements.txt
- if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ env.pip_user_site }}
key: examples_pip_cache-${{ matrix.platform }}-${{ matrix.python-version }}-${{ env.toml_ci_md5 }}

examples:
needs: [pylint, precommit]
needs: [pylint, precommit, examples-setup]
strategy:
matrix:
platform: [ubuntu-22.04, macos-12, windows-latest]
python-version: ["3.8", "3.11"]
test-suite: [ "aqueous_chemistry", "freezing", "condensation", "coagulation", "breakup", "multi-process", "isotopes"]
test-suite: [ "chemistry_freezing_isotopes", "condensation_a", "condensation_b", "coagulation", "breakup", "multi-process_a", "multi-process_b"]
fail-fast: false
runs-on: ${{ matrix.platform }}
timeout-minutes: 45
steps:
- uses: actions/[email protected]
with:
Expand All @@ -192,10 +225,17 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- run: |
python -m pip install --upgrade --user pip
echo pip_user_site=$(python -c "import sysconfig; print(sysconfig.get_path('purelib'))") >> $GITHUB_ENV
echo toml_ci_md5=$(cat pyproject.toml setup.py examples/pyproject.toml examples/setup.py tests/devops_tests/requirements.txt .github/workflows/tests+artifacts+pypi.yml \
| python -c "import hashlib;print(hashlib.md5(open(0,'rb').read()).hexdigest())") >> $GITHUB_ENV
- run: |
python -m pip install -e . ./examples
python -m pip install -r tests/devops_tests/requirements.txt
rm -rf $pip_user_site
- id: cache
uses: actions/cache/restore@v4
with:
fail-on-cache-miss: true
path: ${{ env.pip_user_site }}
key: examples_pip_cache-${{ matrix.platform }}-${{ matrix.python-version }}-${{ env.toml_ci_md5 }}

# https://github.com/numba/numba/issues/6350#issuecomment-728174860
- if: startsWith(matrix.platform, 'ubuntu-')
Expand Down
39 changes: 21 additions & 18 deletions tests/examples_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,26 @@ def findfiles(path, regex):


TEST_SUITES = {
"aqueous_chemistry": ["Jaruga_and_Pawlowska_2018", "Kreidenweis_et_al_2003"],
"freezing": [
"chemistry_freezing_isotopes": [
"Jaruga_and_Pawlowska_2018",
"Kreidenweis_et_al_2003",
"Alpert_and_Knopf_2016",
"Ervens_and_Feingold_2012",
"Niedermeier_et_al_2014",
"Bolot_et_al_2013",
"Merlivat_and_Nief_1967",
"Van_Hook_1968",
"Pierchala_et_al_2022",
"Graf_et_al_2019",
"Lamb_et_al_2017",
# "Rozanski_and_Sonntag_1982", # TODO #1207
],
"condensation": [
"condensation_a": [
"Lowe_et_al_2019",
"Abdul_Razzak_Ghan_2000",
],
"condensation_b": [
"Arabas_and_Shima_2017",
"Lowe_et_al_2019",
"Pyrcel",
"Yang_et_al_2018",
"Singer_Ward",
Expand All @@ -34,27 +44,20 @@ def findfiles(path, regex):
],
"coagulation": ["Berry_1967", "Shima_et_al_2009"],
"breakup": ["Bieli_et_al_2022", "deJong_Mackay_et_al_2023", "Srivastava_1982"],
"multi-process": [
"Bartman_et_al_2021",
"Morrison_and_Grabowski_2007",
"multi-process_a": [
"deJong_Azimi",
"Arabas_et_al_2015",
"Bartman_2020_MasterThesis",
"Bulenok_2023_MasterThesis",
"deJong_Azimi",
],
"multi-process_b": [
"Arabas_et_al_2023",
"Szumowski_et_al_1998",
"Bartman_et_al_2021",
"Morrison_and_Grabowski_2007",
"Shipway_and_Hill_2012",
"Szumowski_et_al_1998",
"utils",
],
"isotopes": [
"Bolot_et_al_2013",
"Merlivat_and_Nief_1967",
"Van_Hook_1968",
"Pierchala_et_al_2022",
"Graf_et_al_2019",
"Lamb_et_al_2017",
# "Rozanski_and_Sonntag_1982", # TODO #1207
],
}


Expand Down
Empty file.
File renamed without changes.
File renamed without changes.

0 comments on commit c38c81f

Please sign in to comment.