Skip to content

Commit 0e5a4a3

Browse files
Update instance repo from cookiecutter template
1 parent b746229 commit 0e5a4a3

3 files changed

Lines changed: 60 additions & 20 deletions

File tree

.cruft.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "/home/runner/work/cookiecutter-scverse/cookiecutter-scverse",
3-
"commit": "e37e90c6c7755e9fcecdfebe0d1b1a8e9e9dd6a4",
3+
"commit": "5ee89c53f7674b205e05af6ac4c554c96f1d305a",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -36,7 +36,7 @@
3636
"trim_blocks": true
3737
},
3838
"_template": "/home/runner/work/cookiecutter-scverse/cookiecutter-scverse",
39-
"_commit": "e37e90c6c7755e9fcecdfebe0d1b1a8e9e9dd6a4"
39+
"_commit": "5ee89c53f7674b205e05af6ac4c554c96f1d305a"
4040
}
4141
},
4242
"directory": null

.github/workflows/test.yaml

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,48 @@ defaults:
1818
shell: bash -euo pipefail {0}
1919

2020
jobs:
21+
# Get the test environment from hatch as defined in pyproject.toml.
22+
# This ensures that the pyproject.toml is the single point of truth for test definitions and the same tests are
23+
# run locally and on continuous integration.
24+
# Check [[tool.hatch.envs.hatch-test.matrix]] in pyproject.toml and https://hatch.pypa.io/latest/environment/ for
25+
# more details.
26+
get-environments:
27+
runs-on: ubuntu-latest
28+
outputs:
29+
envs: ${{ steps.get-envs.outputs.envs }}
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
filter: blob:none
34+
fetch-depth: 0
35+
- name: Install uv
36+
uses: astral-sh/setup-uv@v5
37+
- name: Get test environments
38+
id: get-envs
39+
run: |
40+
ENVS_JSON=$(uvx hatch env show --json | jq -c 'to_entries
41+
| map(
42+
select(.key | startswith("hatch-test"))
43+
| {
44+
name: .key,
45+
label: (if (.key | contains("pre")) then .key + " (PRE-RELEASE DEPENDENCIES)" else .key end),
46+
python: .value.python
47+
}
48+
)')
49+
echo "envs=${ENVS_JSON}" | tee $GITHUB_OUTPUT
50+
51+
# Run tests through hatch. Spawns a separate runner for each environment defined in the hatch matrix obtained above.
2152
test:
22-
runs-on: ${{ matrix.os }}
53+
needs: get-environments
2354

2455
strategy:
2556
fail-fast: false
2657
matrix:
27-
include:
28-
- os: ubuntu-latest
29-
python: "3.10"
30-
- os: ubuntu-latest
31-
python: "3.12"
32-
- os: ubuntu-latest
33-
python: "3.12"
34-
pip-flags: "--pre"
35-
name: PRE-RELEASE DEPENDENCIES
36-
37-
name: ${{ matrix.name }} Python ${{ matrix.python }}
38-
39-
env:
40-
OS: ${{ matrix.os }}
41-
PYTHON: ${{ matrix.python }}
58+
os: [ubuntu-latest]
59+
env: ${{ fromJSON(needs.get-environments.outputs.envs) }}
60+
61+
name: ${{ matrix.env.label }}
62+
runs-on: ${{ matrix.os }}
4263

4364
steps:
4465
- uses: actions/checkout@v4
@@ -48,14 +69,31 @@ jobs:
4869
- name: Install uv
4970
uses: astral-sh/setup-uv@v5
5071
with:
72+
python-version: ${{ matrix.env.python }}
5173
cache-dependency-glob: pyproject.toml
74+
- name: create hatch environment
75+
run: uvx hatch env create ${{ matrix.env.name }}
5276
- name: run tests using hatch
5377
env:
5478
MPLBACKEND: agg
5579
PLATFORM: ${{ matrix.os }}
5680
DISPLAY: :42
57-
run: uvx hatch test --cover --python ${{ matrix.python }}
81+
run: uvx hatch run ${{ matrix.env.name }}:run-cov
5882
- name: generate coverage report
59-
run: uvx hatch run hatch-test.py${{ matrix.python }}:coverage xml
83+
run: uvx hatch run ${{ matrix.env.name }}:coverage xml
6084
- name: Upload coverage
6185
uses: codecov/codecov-action@v4
86+
87+
# Check that all tests defined above pass. This makes it easy to set a single "required" test in branch
88+
# protection instead of having to update it frequently. See https://github.com/re-actors/alls-green#why.
89+
check:
90+
name: Tests pass in all hatch environments
91+
if: always()
92+
needs:
93+
- get-environments
94+
- test
95+
runs-on: ubuntu-latest
96+
steps:
97+
- uses: re-actors/alls-green@release/v1
98+
with:
99+
jobs: ${{ toJSON(needs) }}

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ scripts.build = "sphinx-build -M html docs docs/_build {args}"
6666
scripts.open = "python -m webbrowser -t docs/_build/html/index.html"
6767
scripts.clean = "git clean -fdX -- {args:docs}"
6868

69+
[[tool.hatch.envs.hatch-test.matrix]]
70+
python = [ "3.10", "3.13" ]
6971
[tool.hatch.envs.hatch-test]
7072
features = [ "test" ]
7173

0 commit comments

Comments
 (0)