@@ -17,43 +17,49 @@ defaults:
1717 shell : bash -e {0} # -e to fail on error
1818
1919jobs :
20- pytest :
20+ get-environments :
21+ runs-on : ubuntu-latest
22+ outputs :
23+ envs : ${{ steps.get-envs.outputs.envs }}
24+ steps :
25+ - uses : actions/checkout@v4
26+ with :
27+ filter : blob:none
28+ fetch-depth : 0
29+ - uses : astral-sh/setup-uv@v5
30+ with :
31+ enable-cache : false
32+ - id : get-envs
33+ run : |
34+ ENVS_JSON=$(NO_COLOR=1 uvx hatch env show --json | jq -c 'to_entries
35+ | map(
36+ select(.key | startswith("hatch-test"))
37+ | {
38+ name: .key,
39+ "test-type": (if (.key | test("pre|min")) then "coverage" else null end),
40+ python: .value.python,
41+ }
42+ )')
43+ echo "envs=${ENVS_JSON}" | tee $GITHUB_OUTPUT
44+
45+ test :
46+ needs : get-environments
2147 runs-on : ubuntu-latest
22-
2348 strategy :
2449 matrix :
25- include :
26- - python-version : ' 3.10'
27- - python-version : ' 3.12'
28- - python-version : ' 3.12'
29- dependencies-version : min-optional
30- - python-version : ' 3.12'
31- dependencies-version : pre-release
32- test-type : coverage
33- - python-version : ' 3.10'
34- dependencies-version : minimum
35- test-type : coverage
36-
37- env : # for use codecov’s env_vars tagging
38- PYTHON : ${{ matrix.python-version }}
39- DEPS : ${{ matrix.dependencies-version || 'default' }}
40- TESTS : ${{ matrix.test-type || 'default' }}
41-
50+ env : ${{ fromJSON(needs.get-environments.outputs.envs) }}
51+ env : # environment variable for use in codecov’s env_vars tagging
52+ ENV_NAME : ${{ matrix.env.name }}
4253 steps :
4354 - uses : actions/checkout@v4
4455 with :
4556 fetch-depth : 0
4657 filter : blob:none
4758
48- - name : Set up Python ${{ matrix.python-version }}
49- uses : actions/setup-python@v5
50- with :
51- python-version : ${{ matrix.python-version }}
52-
53- - name : Install UV
54- uses : astral-sh/setup-uv@v5
59+ - uses : astral-sh/setup-uv@v5
5560 with :
5661 enable-cache : true
62+ python-version : ${{ matrix.env.python }}
5763 cache-dependency-glob : pyproject.toml
5864
5965 - name : Cache downloaded data
@@ -63,55 +69,42 @@ jobs:
6369 key : pytest
6470
6571 - name : Install dependencies
66- if : matrix.dependencies-version == null
67- run : uv pip install --system --compile "scanpy[dev,test-full] @ ."
68- - name : Install dependencies (no optional features)
69- if : matrix.dependencies-version == 'min-optional'
70- run : uv pip install --system --compile "scanpy[dev,test-min] @ ."
71- - name : Install dependencies (minimum versions)
72- if : matrix.dependencies-version == 'minimum'
73- run : |
74- uv pip install --system --compile tomli packaging
75- deps=$(python3 ci/scripts/min-deps.py pyproject.toml --extra dev test)
76- uv pip install --system --compile $deps "scanpy @ ."
77- - name : Install dependencies (pre-release versions)
78- if : matrix.dependencies-version == 'pre-release'
79- run : uv pip install -v --system --compile --pre "scanpy[dev,test-full] @ ." "anndata[dev,test] @ git+https://github.com/scverse/anndata.git"
72+ run : uvx hatch -v env create ${{ matrix.env.name }}
8073
81- - name : Run pytest
82- if : matrix.test-type == null
83- run : pytest
84- - name : Run pytest (coverage)
85- if : matrix.test-type == 'coverage'
86- run : coverage run -m pytest --cov --cov-report=xml
74+ - name : Run tests
75+ if : matrix.env. test-type == null
76+ run : uvx hatch run ${{ matrix.env.name }}:run
77+ - name : Run tests (coverage)
78+ if : matrix.env. test-type == 'coverage'
79+ run : uvx hatch run ${{ matrix.env.name }}:run-cov --cov --cov-report=xml
8780
8881 - name : Upload coverage data
89- uses : codecov/codecov-action@v4
90- if : matrix.test-type == 'coverage'
82+ uses : codecov/codecov-action@v5
83+ if : matrix.env. test-type == 'coverage'
9184 with :
9285 token : ${{ secrets.CODECOV_TOKEN }}
93- env_vars : " PYTHON,DEPS,TESTS "
86+ env_vars : ENV_NAME
9487 fail_ci_if_error : true
95- file : test-data/coverage.xml
88+ files : test-data/coverage.xml
9689
9790 - name : Upload test results
9891 # yaml strings can’t start with “!”, so using explicit substitution
9992 if : ${{ !cancelled() }}
10093 uses : codecov/test-results-action@v1
10194 with :
10295 token : ${{ secrets.CODECOV_TOKEN }}
103- env_vars : " PYTHON,DEPS,TESTS "
96+ env_vars : ENV_NAME
10497 fail_ci_if_error : true
10598 file : test-data/test-results.xml
10699
107100 - name : Publish debug artifacts
108- if : matrix.test-type == 'coverage'
101+ if : matrix.env. test-type == 'coverage'
109102 uses : actions/upload-artifact@v4
110103 with :
111- name : debug-data-${{ matrix.python-version }}-${{ matrix.dependencies-version || 'default' }}-${{ matrix.test-type || 'default' }}
104+ name : debug-data-${{ matrix.env.name }}
112105 path : .pytest_cache/d/debug
113106
114- check- build :
107+ build :
115108 runs-on : ubuntu-latest
116109 steps :
117110 - uses : actions/checkout@v4
@@ -126,3 +119,15 @@ jobs:
126119 enable-cache : false
127120 - run : uvx --from build pyproject-build --sdist --wheel .
128121 - run : uvx twine check dist/*
122+
123+ check :
124+ if : always()
125+ needs :
126+ - get-environments
127+ - test
128+ - build
129+ runs-on : ubuntu-latest
130+ steps :
131+ - uses : re-actors/alls-green@release/v1
132+ with :
133+ jobs : ${{ toJSON(needs) }}
0 commit comments