-
Notifications
You must be signed in to change notification settings - Fork 2
134 lines (114 loc) · 4.36 KB
/
python-tests.yml
File metadata and controls
134 lines (114 loc) · 4.36 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: "python tests and coverage"
# Uses:
# https://github.com/actions/setup-python : v5.6.0 a26af69be951a213d495a4c3e4e4022e16d87065
# https://github.com/actions/checkout : v4.2.2 11bd71901bbe5b1630ceea73d27597364c9af683
# https://github.com/actions/download-artifact : v5.0.0 634f93cb2916e3fdff6788551b99b062d0335ce0
# https://github.com/actions/upload-artifact : v4.6.2 ea165f8d65b6e75b540449e92b4886f43607fa02
# https://github.com/astral-sh/setup-uv : v6.4.3 e92bafb6253dcd438e0484186d7669ea7a8ca1cc
on:
pull_request:
branches:
- "main"
push:
branches:
- "main"
env:
UV_PYTHON_PREFERENCE: "only-system"
jobs:
settings:
runs-on: "ubuntu-latest"
name: "Define workflow settings"
steps:
- name: "Repo checkout"
uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683"
- name: "Define settings"
run: |
echo "python_version=$(<.python-version)" >> $GITHUB_OUTPUT
run-tests-and-coverage:
name: "Run nox for tests and coverage"
needs: "settings"
runs-on: "${{ matrix.os }}"
strategy:
fail-fast: false
matrix:
os:
# - "macos-latest"
# - "windows-latest"
- "ubuntu-latest"
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
steps:
- name: "Repo checkout"
uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683"
- name: "Set up Python ${{ matrix.python-version }}"
uses: "actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065"
with:
python-version: "${{ matrix.python-version }}"
allow-prereleases: true
- name: "Install the latest version of uv"
uses: "astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc"
with:
version: "latest"
python-version: "${{ matrix.python-version }}"
enable-cache: true
- name: "Run tests and coverage via nox"
run: "uvx nox --session test -- partial-coverage no-config"
- name: "Save coverage artifact"
uses: "actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02"
with:
name: "coverage-artifact-${{ matrix.os}}-${{ matrix.python-version}}"
path: ".coverage.*"
retention-days: 1
include-hidden-files: true
coverage-compile:
name: "coverage compile"
needs: "run-tests-and-coverage"
runs-on: "ubuntu-latest"
steps:
- name: "Repo checkout"
uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683"
- name: "Set up Python"
uses: "actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065"
with:
python-version: ${{ steps.settings.outputs.python_version }}
- name: "Install the latest version of uv"
uses: "astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc"
with:
version: "latest"
python-version: ${{ steps.settings.outputs.python_version }}
enable-cache: true
- name: "Download coverage artifacts"
uses: "actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0"
with:
pattern: "coverage-artifact-*"
merge-multiple: true
- name: "Compile coverage data"
run: "uvx nox --session combine"
- name: "Post summary to step summary."
run: |
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "TOTAL=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
linters-and-formatters:
name: "linters and formattrs"
needs: "settings"
runs-on: "ubuntu-latest"
steps:
- name: "Repo checkout"
uses: "actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683"
- name: "Set up Python"
uses: "actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065"
with:
python-version: ${{ steps.settings.outputs.python_version }}
- name: "Install the latest version of uv"
uses: "astral-sh/setup-uv@e92bafb6253dcd438e0484186d7669ea7a8ca1cc"
with:
version: "latest"
python-version: ${{ steps.settings.outputs.python_version }}
enable-cache: true
- name: "Enforce strict type annotations with mypy"
run: "uvx nox --session lint"