-
Notifications
You must be signed in to change notification settings - Fork 97
111 lines (101 loc) · 3.49 KB
/
Copy pathtest.yaml
File metadata and controls
111 lines (101 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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
permissions:
contents: read
jobs:
# [tool.hatch.envs.hatch-test.matrix] in pyproject.toml is the single source of truth: the same environments run here and locally.
get-environments:
runs-on: ubuntu-slim
outputs:
envs: ${{ steps.get-envs.outputs.envs }}
steps:
- &clone
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
filter: blob:none
fetch-depth: 0
persist-credentials: false
- &setup-uv
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
- name: Get test environments
id: get-envs
run: |
ENVS_JSON=$(uvx hatch env show --json | jq -c 'to_entries
| map(
select(.key | startswith("hatch-test"))
| {
name: .key,
label: (if (.key | contains("pre")) then .key + " (PRE-RELEASE DEPENDENCIES)" else .key end),
python: .value.python
}
)')
echo "envs=${ENVS_JSON}" | tee $GITHUB_OUTPUT
test:
needs: get-environments
permissions:
id-token: write # for codecov OIDC
contents: read
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
env: ${{ fromJSON(needs.get-environments.outputs.envs) }}
name: ${{ matrix.env.label }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
continue-on-error: ${{ contains(matrix.env.name, 'pre') }} # make "all-green" pass even if pre-release job fails
env:
UV_PYTHON: ${{ matrix.env.python }}
steps:
- *clone
- *setup-uv
- name: create hatch environment
run: uvx hatch env create ${{ matrix.env.name }}
- name: list all all installed package versions
run: uvx hatch run ${{ matrix.env.name }}:uv pip list
- name: run tests using hatch
env:
MPLBACKEND: agg
PLATFORM: ${{ matrix.os }}
DISPLAY: :42
run: uvx hatch run ${{ matrix.env.name }}:run-cov -v --color=yes -n auto --dist worksteal --run-network
- name: generate coverage report
run: |
# See https://coverage.readthedocs.io/page/config.html#run-patch
test -f .coverage || uvx hatch run ${{ matrix.env.name }}:cov-combine
uvx hatch run ${{ matrix.env.name }}:cov-report # report visibly
uvx hatch run ${{ matrix.env.name }}:coverage xml # create report for upload
- name: Upload coverage
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
fail_ci_if_error: true
use_oidc: true
lint:
name: Pre-commit checks
runs-on: ubuntu-latest
steps:
- *clone
- *setup-uv
- run: uv tool install hatch
- run: uvx prek run --all-files --show-diff-on-failure --color=always
# One required check for branch protection, so it does not need updating whenever the matrix changes.
check:
name: Tests pass in all hatch environments
if: always()
needs:
- get-environments
- test
- lint
runs-on: ubuntu-latest
steps:
- uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
with:
jobs: ${{ toJSON(needs) }}