1- name : Test
1+ name : CI
22
33on :
4- schedule :
5- - cron : 00 00 * * 1 # every Monday at 00:00
64 push :
7- branches : [main]
5+ branches :
6+ - main
7+ - " [0-9]+.[0-9]+.x"
88 pull_request :
9- branches : [main]
10- workflow_dispatch :
11- inputs :
12- reason :
13- description : Reason for the workflow dispatch. Only "release" is valid.
14- required : true
15- default : release
9+
10+ env :
11+ PYTEST_ADDOPTS : " -v --color=yes -n auto --internet-tests --junitxml=test-data/test-results.xml"
12+ FORCE_COLOR : " 1"
13+ MPLBACKEND : agg
14+ # It's impossible to ignore SyntaxWarnings for a single module,
15+ # so because leidenalg 0.10.0 has them, we pre-compile things: https://github.com/vtraag/leidenalg/issues/173
16+ UV_COMPILE_BYTECODE : " 1"
17+
18+ defaults :
19+ run :
20+ shell : bash -e {0} # -e to fail on error
1621
1722jobs :
23+ get-environments :
24+ runs-on : ubuntu-latest
25+ outputs :
26+ envs : ${{ steps.get-envs.outputs.envs }}
27+ steps :
28+ - uses : actions/checkout@v4
29+ with :
30+ filter : blob:none
31+ fetch-depth : 0
32+ - uses : astral-sh/setup-uv@v5
33+ with :
34+ enable-cache : false
35+ - id : get-envs
36+ run : |
37+ ENVS_JSON=$(NO_COLOR=1 uvx hatch env show --json | jq -c 'to_entries
38+ | map(
39+ select(.key | startswith("hatch-test"))
40+ | {
41+ name: .key,
42+ "test-type": (if (.key | test("pre|min")) then "coverage" else null end),
43+ python: .value.python | sub("3[.]13"; "3.13.3"), # https://github.com/numba/numba/issues/10101
44+ }
45+ )')
46+ echo "envs=${ENVS_JSON}" | tee $GITHUB_OUTPUT
47+
1848 test :
19- runs-on : ${{ matrix.os }}
49+ needs : get-environments
50+ runs-on : ubuntu-latest
2051 strategy :
21- fail-fast : false
2252 matrix :
23- python : ["3.10", "3.11", "3.12"]
24- os : [ubuntu-latest]
25- include :
26- - python : " 3.12"
27- os : macos-latest
28-
29- env :
30- OS : ${{ matrix.os }}
31- PYTHON : ${{ matrix.python }}
32-
53+ env : ${{ fromJSON(needs.get-environments.outputs.envs) }}
54+ env : # environment variable for use in codecov's env_vars tagging
55+ ENV_NAME : ${{ matrix.env.name }}
3356 steps :
3457 - uses : actions/checkout@v4
3558 with :
3659 fetch-depth : 0
60+ filter : blob:none
3761
38- - name : Set up Python ${{ matrix.python }}
39- uses : astral-sh/setup-uv@v6
62+ - uses : astral-sh/setup-uv@v5
4063 with :
41- python-version : ${{ matrix.python }}
4264 enable-cache : true
65+ python-version : ${{ matrix.env.python }}
66+ cache-dependency-glob : pyproject.toml
4367
44- - name : Install dependencies
45- run : |
46- ./.scripts/ci/install_dependencies.sh
47-
48- - name : Restore data cache
49- id : data-cache
68+ - name : Cache downloaded data
5069 uses : actions/cache@v4
5170 with :
52- path : |
53- ~/.cache/squidpy/*.h5ad
54- key : data-${{ hashFiles('**/download_data.py') }}
71+ path : .pytest_cache/d/squidpy-data
72+ key : pytest
5573
56- - name : Download datasets
57- if : steps.data-cache.outputs.cache-hit != 'true'
58- run : |
59- uvx hatch run data:download
74+ - name : Install dependencies
75+ run : uvx hatch -v env create ${{ matrix.env.name }}
6076
61- - name : Test
62- timeout-minutes : 60
63- env :
64- MPLBACKEND : agg
65- PLATFORM : ${{ matrix.os }}
66- DISPLAY : :42
67- PYTEST_ADDOPTS : " -n auto"
68- run : |
69- uvx hatch test --python ${{ matrix.python }} --randomize --parallel --cover --all
77+ - name : Run tests
78+ if : matrix.env.test-type == null
79+ run : uvx hatch run ${{ matrix.env.name }}:run
80+ - name : Run tests (coverage)
81+ if : matrix.env.test-type == 'coverage'
82+ run : uvx hatch run ${{ matrix.env.name }}:run-cov --cov --cov-report=xml
7083
71- - name : Archive figures generated during testing
72- if : always()
73- uses : actions/upload-artifact@v4
84+ - name : Upload coverage data
85+ uses : codecov/codecov-action@v5
86+ if : matrix.env.test-type == 'coverage'
7487 with :
75- name : visual_test_results_${{ matrix.os }}-python${{ matrix.python }}
76- path : tests/figures/*
88+ token : ${{ secrets.CODECOV_TOKEN }}
89+ env_vars : ENV_NAME
90+ fail_ci_if_error : true
91+ files : test-data/coverage.xml
7792
78- - name : Upload coverage to Codecov
79- uses : codecov/codecov-action@v5
93+ - name : Upload test results
94+ # yaml strings can't start with "!", so using explicit substitution
95+ if : ${{ !cancelled() }}
96+ uses : codecov/test-results-action@v1
8097 with :
81- name : coverage
82- verbose : true
8398 token : ${{ secrets.CODECOV_TOKEN }}
99+ env_vars : ENV_NAME
100+ fail_ci_if_error : true
101+ file : test-data/test-results.xml
102+
103+ - name : Publish debug artifacts
104+ if : ${{ !cancelled() }}
105+ uses : actions/upload-artifact@v4
106+ with :
107+ name : debug-data-${{ matrix.env.name }}
108+ path : .pytest_cache/d/debug
109+
110+ build :
111+ runs-on : ubuntu-latest
112+ steps :
113+ - uses : actions/checkout@v4
114+ with :
115+ fetch-depth : 0
116+ filter : blob:none
117+ - uses : actions/setup-python@v5
118+ with :
119+ python-version : " 3.12" # Changed from 3.13 to match squidpy's Python support
120+ - uses : astral-sh/setup-uv@v5
121+ with :
122+ enable-cache : false
123+ - run : uvx --from build pyproject-build --sdist --wheel .
124+ - run : uvx twine check dist/*
84125
85126 check :
86127 if : always()
87- needs : [test]
128+ needs :
129+ - get-environments
130+ - test
131+ - build
88132 runs-on : ubuntu-latest
89133 steps :
90- - uses : re-actors/alls-green@release/v1
91- with :
92- jobs : ${{ toJSON(needs) }}
134+ - uses : re-actors/alls-green@release/v1
135+ with :
136+ jobs : ${{ toJSON(needs) }}
0 commit comments