Skip to content

Derive test configs from hatch #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 53 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,61 @@ env:
FORCE_COLOR: "1"

jobs:
get-environments:
runs-on: ubuntu-latest
outputs:
envs: ${{ steps.get-envs.outputs.envs }}
pythons: ${{ steps.get-pythons.outputs.pythons }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
filter: blob:none
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Get test environments
id: get-envs
run: |
ENVS_JSON=$(
FORCE_COLOR= uvx hatch env show --json |
jq -c 'to_entries | map(select(.key | startswith("hatch-test")) | { name: .key, python: .value.python })'
)
echo "envs=$ENVS_JSON" | tee $GITHUB_OUTPUT
- name: Get python versions
id: get-pythons
env:
ENVS_JSON: ${{ steps.get-envs.outputs.envs }}
run: |
PYTHONS_JSON=$(echo "$ENVS_JSON" | jq -c 'map(.python) | unique')
echo "pythons=$PYTHONS_JSON" | tee $GITHUB_OUTPUT
test:
name: Tests
needs: get-environments
runs-on: ubuntu-latest
strategy:
matrix:
include:
- python-version: "3.13"
test-extra: test-min
- python-version: "3.11"
- python-version: "3.13"
env: ${{ fromJSON(needs.get-environments.outputs.envs) }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
filter: blob:none
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: pyproject.toml
- run: uv pip install --system -e .[${{ matrix.test-extra || 'test' }}]
- run: |
coverage run -m pytest -m "not benchmark"
coverage report
python-version: ${{ matrix.env.python }}
- name: create environment
run: uvx hatch env create ${{ matrix.env.name }}
- name: run tests with coverage
run: |
uvx hatch run ${{ matrix.env.name }}:run-cov
# https://github.com/codecov/codecov-cli/issues/648
coverage xml
uvx hatch run ${{ matrix.env.name }}:coverage xml
rm test-data/.coverage
- uses: codecov/codecov-action@v5
with:
name: Min Tests
name: ${{ matrix.env.name }}
fail_ci_if_error: true
files: test-data/coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down Expand Up @@ -84,10 +107,11 @@ jobs:
- run: python -c 'import testing.fast_array_utils as tfau; print(tfau.ArrayType("numpy", "ndarray"))'
check:
name: Static Checks
needs: get-environments
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.13"]
python-version: ${{ fromJSON(needs.get-environments.outputs.pythons) }}
env:
SKIP: no-commit-to-branch # this CI runs on the main branch
steps:
Expand All @@ -99,3 +123,17 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- uses: pre-commit/[email protected]
pass:
name: All Checks
if: always()
needs:
- get-environments
- test
- bench
- import
- check
runs-on: ubuntu-latest
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ extra-dependencies = [ "ipykernel", "ipycytoscape" ]
env-vars.CODSPEED_PROFILE_FOLDER = "test-data/codspeed"
overrides.matrix.extras.features = [
{ if = [ "full" ], value = "full" },
{ if = [ "default", "full" ], value = "test" },
{ if = [ "full" ], value = "test" },
]
overrides.matrix.extras.dependencies = [
{ if = [ "full" ], value = "scipy-stubs" },
{ if = [ "full" ], value = "scikit-learn" },
]

[[tool.hatch.envs.hatch-test.matrix]]
python = [ "3.13", "3.12", "3.11" ]
extras = [ "full", "default", "min" ]
python = [ "3.13", "3.11" ]
extras = [ "full", "min" ]

[tool.ruff]
line-length = 160
Expand Down
Loading