Skip to content

Commit 0bce929

Browse files
(chore): derive CI matrix from hatch env (#1998)
* (chore): derive CI matrix from hatch env * (fix): addopts for parallel * (fix): remove internet-tests flag * (fix): scipy equality check * (chore): add comment * simplify --------- Co-authored-by: Philipp A. <flying-sheep@web.de>
1 parent 2e9cfca commit 0bce929

1 file changed

Lines changed: 46 additions & 45 deletions

File tree

.github/workflows/test-cpu.yml

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88
pull_request:
99

1010
env:
11-
PYTEST_ADDOPTS: "-v --color=yes"
1211
FORCE_COLOR: "1"
1312

1413
defaults:
@@ -22,31 +21,44 @@ concurrency:
2221
cancel-in-progress: true
2322

2423
jobs:
25-
pytest:
24+
get-environments:
25+
runs-on: ubuntu-latest
26+
outputs:
27+
envs: ${{ steps.get-envs.outputs.envs }}
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
filter: blob:none
32+
fetch-depth: 0
33+
- uses: astral-sh/setup-uv@v5
34+
with:
35+
enable-cache: false
36+
- id: get-envs
37+
run: |
38+
ENVS_JSON=$(NO_COLOR=1 uvx hatch env show --json | jq -c 'to_entries
39+
| map(
40+
select(.key | startswith("hatch-test"))
41+
| { name: .key, python: .value.python }
42+
)')
43+
echo "envs=${ENVS_JSON}" | tee $GITHUB_OUTPUT
44+
test:
45+
needs: get-environments
2646
runs-on: ubuntu-latest
2747
strategy:
2848
matrix:
29-
include:
30-
- python-version: '3.13'
31-
test-type: coverage
32-
- python-version: '3.11'
33-
test-type: standard
34-
- python-version: '3.13'
35-
dependencies-version: pre-release
36-
test-type: strict-warning
37-
- python-version: '3.11'
38-
dependencies-version: minimum
39-
test-type: coverage
49+
env: ${{ fromJSON(needs.get-environments.outputs.envs) }}
50+
env: # environment variable for use in codecov’s env_vars tagging
51+
ENV_NAME: ${{ matrix.env.name }}
4052
steps:
4153
- uses: actions/checkout@v4
4254
with:
4355
fetch-depth: 0
4456
filter: blob:none
4557

46-
- name: Set up Python ${{ matrix.python-version }}
58+
- name: Set up Python ${{ matrix.env.python }}
4759
uses: actions/setup-python@v5
4860
with:
49-
python-version: ${{ matrix.python-version }}
61+
python-version: ${{ matrix.env.python }}
5062

5163
- name: Install UV
5264
uses: astral-sh/setup-uv@v5
@@ -55,43 +67,20 @@ jobs:
5567
cache-dependency-glob: pyproject.toml
5668

5769
- name: Install dependencies
58-
if: matrix.dependencies-version == null
59-
run: uv pip install --system --compile -r pyproject.toml --extra=dev --extra=test -e 'anndata @ .' -c ci/constraints.txt
60-
61-
- name: Install minimum dependencies
62-
if: matrix.dependencies-version == 'minimum'
63-
run: |
64-
uv pip install --system --compile tomli packaging
65-
deps=$(python3 ci/scripts/min-deps.py pyproject.toml --extras dev test-min)
66-
uv pip install --system --compile $deps -e 'anndata @ .'
67-
68-
- name: Install dependencies release candidates
69-
if: matrix.dependencies-version == 'pre-release'
70-
run: uv pip install -v --system --compile --pre -r pyproject.toml --extra=dev --extra=test -e 'anndata @ .' -c ci/constraints.txt
71-
72-
- name: Display installed versions
73-
run: uv pip list
74-
75-
- name: Run Pytest
76-
if: matrix.test-type == 'standard'
77-
run: pytest -n auto
70+
run: uvx hatch -v env create ${{ matrix.env.name }}
7871

79-
- name: Run Pytest (coverage)
80-
if: matrix.test-type == 'coverage'
81-
run: coverage run -m pytest -n auto --cov --cov-report=xml
72+
- name: Run tests
73+
run: uvx hatch run ${{ matrix.env.name }}:run-cov -v --color=yes -n auto --cov --cov-report=xml --junitxml=test-data/test-results.xml
8274

83-
- name: Run Pytest (treat warnings as errors)
84-
if: matrix.test-type == 'strict-warning'
85-
run: pytest --strict-warnings -n auto
86-
87-
- uses: codecov/codecov-action@v4
88-
if: matrix.test-type == 'coverage'
75+
- name: Upload coverage data
76+
uses: codecov/codecov-action@v5
8977
with:
9078
token: ${{ secrets.CODECOV_TOKEN }}
79+
env_vars: ENV_NAME
9180
fail_ci_if_error: true
9281
files: test-data/coverage.xml
9382

94-
check-build:
83+
build:
9584
runs-on: ubuntu-22.04
9685
steps:
9786
- uses: actions/checkout@v4
@@ -121,3 +110,15 @@ jobs:
121110
run: |
122111
pip install dist/*.whl
123112
python -c 'import anndata; print(anndata.__version__)'
113+
114+
check:
115+
if: always()
116+
needs:
117+
- get-environments
118+
- test
119+
- build
120+
runs-on: ubuntu-latest
121+
steps:
122+
- uses: re-actors/alls-green@release/v1
123+
with:
124+
jobs: ${{ toJSON(needs) }}

0 commit comments

Comments
 (0)