|
1 | | -name: Test |
| 1 | +name: Tests |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: [main] |
6 | 6 | pull_request: |
7 | 7 | branches: [main] |
8 | | - schedule: |
9 | | - - cron: "0 5 1,15 * *" |
10 | 8 |
|
11 | 9 | concurrency: |
12 | 10 | group: ${{ github.workflow }}-${{ github.ref }} |
13 | 11 | cancel-in-progress: true |
14 | 12 |
|
15 | | -defaults: |
16 | | - run: |
17 | | - # to fail on error in multiline statements (-e), in pipes (-o pipefail), and on unset variables (-u). |
18 | | - shell: bash -euo pipefail {0} |
19 | | - |
20 | 13 | 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. |
52 | 14 | test: |
53 | | - needs: get-environments |
54 | | - |
55 | | - strategy: |
56 | | - fail-fast: false |
57 | | - matrix: |
58 | | - os: [ubuntu-latest] |
59 | | - env: ${{ fromJSON(needs.get-environments.outputs.envs) }} |
60 | | - |
61 | | - name: ${{ matrix.env.label }} |
62 | | - runs-on: ${{ matrix.os }} |
63 | | - |
| 15 | + name: Run pytest |
| 16 | + runs-on: ubuntu-latest |
64 | 17 | steps: |
65 | 18 | - uses: actions/checkout@v4 |
66 | 19 | with: |
67 | 20 | filter: blob:none |
68 | 21 | fetch-depth: 0 |
69 | | - - name: Install uv |
70 | | - uses: astral-sh/setup-uv@v5 |
| 22 | + - uses: prefix-dev/setup-pixi@v0.8.0 |
71 | 23 | with: |
72 | | - python-version: ${{ matrix.env.python }} |
73 | | - cache-dependency-glob: pyproject.toml |
74 | | - - name: create hatch environment |
75 | | - run: uvx hatch env create ${{ matrix.env.name }} |
76 | | - - name: run tests using hatch |
77 | | - env: |
78 | | - MPLBACKEND: agg |
79 | | - PLATFORM: ${{ matrix.os }} |
80 | | - DISPLAY: :42 |
81 | | - run: | |
82 | | - uvx hatch run ${{ matrix.env.name }}:coverage run -m pytest -v --color=yes |
83 | | - - name: generate coverage report |
84 | | - run: uvx hatch run ${{ matrix.env.name }}:coverage xml |
85 | | - - name: Upload coverage |
86 | | - uses: codecov/codecov-action@v4 |
87 | | - with: |
88 | | - token: ${{ secrets.CODECOV_TOKEN }} |
89 | | - |
90 | | - # Check that all tests defined above pass. This makes it easy to set a single "required" test in branch |
91 | | - # protection instead of having to update it frequently. See https://github.com/re-actors/alls-green#why. |
92 | | - check: |
93 | | - name: Tests pass in all hatch environments |
94 | | - if: always() |
95 | | - needs: |
96 | | - - get-environments |
97 | | - - test |
98 | | - runs-on: ubuntu-latest |
99 | | - steps: |
100 | | - - uses: re-actors/alls-green@release/v1 |
101 | | - with: |
102 | | - jobs: ${{ toJSON(needs) }} |
| 24 | + pixi-version: v0.40.0 |
| 25 | + cache: true |
| 26 | + - name: Run tests |
| 27 | + run: pixi run test |
0 commit comments