Skip to content

Commit 65be24f

Browse files
committed
Clean up python-tests workflow
Use a job to output global settings that can be reused in all other jobs. This will reduce the wear-and-tear of updating the imported action versions. Also adds python 3.14 to matrix.
1 parent aef7161 commit 65be24f

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

.github/workflows/python-tests.yml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
name: "python tests and coverage"
2-
# Uses:
3-
# https://github.com/actions/setup-python : 0b93645e9fea7318ecaed2b359559ac225c90a2b
4-
# https://github.com/actions/checkout : 11bd71901bbe5b1630ceea73d27597364c9af683
5-
# https://github.com/actions/download-artifact : fa0a91b85d4f404e444e00e005971372dc801d16
6-
# https://github.com/actions/upload-artifact : 6f51ac03b9356f520e9adb1b1b7802705f340c2b
72

83
on:
94
pull_request:
@@ -14,8 +9,19 @@ on:
149
- "main"
1510

1611
jobs:
12+
settings:
13+
runs-on: "ubuntu-latest"
14+
name: "Define workflow settings"
15+
outputs:
16+
default-python-version: "3.12"
17+
gha-setup-python: "actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b"
18+
gha-checkout: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683"
19+
gha-download-artifact: "actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16"
20+
gha-upload-artifact: "actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b"
21+
1722
run-tests-and-coverage:
1823
name: "Run pytest with coverage."
24+
needs: ["settings"]
1925
runs-on: "${{ matrix.os }}"
2026
strategy:
2127
fail-fast: false
@@ -30,13 +36,14 @@ jobs:
3036
- "3.11"
3137
- "3.12"
3238
- "3.13"
39+
- "3.14"
3340

3441
steps:
3542
- name: "Repo checkout"
36-
uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683"
43+
uses: "${{ needs.settings.outputs.gha-checkout }}"
3744

3845
- name: "Set up Python ${{ matrix.python-version }}"
39-
uses: "actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b"
46+
uses: "${{ needs.settings.outputs.gha-setup-python }}"
4047
with:
4148
python-version: "${{ matrix.python-version }}"
4249
allow-prereleases: true
@@ -50,7 +57,7 @@ jobs:
5057
nox --session test -- partial-coverage
5158
5259
- name: "Save coverage artifact"
53-
uses: "actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b"
60+
uses: "${{ needs.settings.outputs.gha-upload-artifact }}"
5461
with:
5562
name: "coverage-artifact-${{ matrix.os}}-${{ matrix.python-version}}"
5663
path: ".coverage.*"
@@ -59,23 +66,23 @@ jobs:
5966

6067
coverage-compile:
6168
name: "Compile coverage reports."
62-
needs: "run-tests-and-coverage"
69+
needs: ["settings", "run-tests-and-coverage"]
6370
runs-on: "ubuntu-latest"
6471
steps:
6572
- name: "Repo checkout"
66-
uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683"
73+
uses: "${{ needs.settings.outputs.gha-checkout }}"
6774

6875
- name: "Set up Python"
69-
uses: "actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b"
76+
uses: "${{ needs.settings.outputs.gha-setup-python }}"
7077
with:
71-
python-version: "3.12"
78+
python-version: "${{ needs.settings.outputs.default-python-version }}"
7279

7380
- name: "Install nox"
7481
run: |
7582
python -m pip install --upgrade nox
7683
7784
- name: "Download coverage artifacts"
78-
uses: "actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16"
85+
uses: "${{ needs.settings.outputs.gha-download-artifact }}"
7986
with:
8087
pattern: "coverage-artifact-*"
8188
merge-multiple: true
@@ -89,15 +96,16 @@ jobs:
8996
9097
linting:
9198
name: "Check linting and formatting requirements"
99+
needs: ["settings"]
92100
runs-on: "ubuntu-latest"
93101
steps:
94102
- name: "Repo checkout"
95-
uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683"
103+
uses: "${{ needs.settings.outputs.gha-checkout }}"
96104

97105
- name: "Set up Python"
98-
uses: "actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b"
106+
uses: "${{ needs.settings.outputs.gha-setup-python }}"
99107
with:
100-
python-version: "3.12"
108+
python-version: "${{ needs.settings.outputs.default-python-version }}"
101109

102110
- name: "Install nox"
103111
run: |

0 commit comments

Comments
 (0)