Skip to content

Update instance repo (PR 390 -- Get test matrix from hatch) #717

Update instance repo (PR 390 -- Get test matrix from hatch)

Update instance repo (PR 390 -- Get test matrix from hatch) #717

Workflow file for this run

name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "0 5 1,15 * *"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
# to fail on error in multiline statements (-e), in pipes (-o pipefail), and on unset variables (-u).
shell: bash -euo pipefail {0}
jobs:
get-environments:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.get-envs.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
filter: blob:none
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Get test environments
id: get-envs
run: |
MATRIX_JSON=$(uvx hatch env show --json | jq -c 'to_entries
| map(
select(.key | startswith("hatch-test"))
| {
env_name: .key,
name: (if (.key | contains("pre")) then .key + " (PRE-RELEASE DEPENDENCIES)" else .key end),
python: .value.python
}
)')
echo "matrix=${MATRIX_JSON}" | tee $GITHUB_OUTPUT
test:
needs: get-environments
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.get-environments.outputs.matrix) }}
name: ${{ matrix.name }}
steps:
- uses: actions/checkout@v4
with:
filter: blob:none
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python }}
cache-dependency-glob: pyproject.toml
- name: create hatch environment
run: uvx hatch env create ${{ matrix.env_name }}
- name: run tests using hatch
env:
MPLBACKEND: agg
PLATFORM: ubuntu-latest
DISPLAY: :42
run: uvx hatch run ${{ matrix.env_name }}:run-cov
- name: generate coverage report
run: uvx hatch run ${{ matrix.env_name }}:coverage xml
- name: Upload coverage
uses: codecov/codecov-action@v4