-
-
Notifications
You must be signed in to change notification settings - Fork 209
205 lines (177 loc) · 6.18 KB
/
checks.yml
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: Run Checks
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
merge_group:
jobs:
test:
strategy:
matrix:
python: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/[email protected]
- name: Set up Python
uses: actions/[email protected]
with:
python-version: ${{ matrix.python }}
- name: Get Python Version
id: get_python_version
run: echo "python_version=$(python --version)" >> $GITHUB_OUTPUT
shell: bash
- name: Cache dependencies
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies-${{ hashFiles('**/pdm.lock') }}
restore-keys: |
${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies
- name: Install PDM
run: pip install pdm
- name: Install Dependencies
run: pdm install
- name: Check formatting
run: pdm run ruff format . --check
- name: Run mypy
run: pdm mypy --show-error-codes
- name: Lint
run: pdm run ruff check .
- name: Run pytest without coverage
if: matrix.os != 'ubuntu-latest'
run: pdm test
- name: Run pytest with coverage
if: matrix.os == 'ubuntu-latest'
run: pdm test_with_coverage
- run: mv .coverage .coverage.${{ matrix.python }}
if: matrix.os == 'ubuntu-latest'
- name: Store coverage report
uses: actions/[email protected]
if: matrix.os == 'ubuntu-latest'
with:
name: coverage-${{ matrix.python }}
path: .coverage.${{ matrix.python }}
if-no-files-found: error
include-hidden-files: true
test_min_deps:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/[email protected]
- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.9"
- name: Get Python Version
id: get_python_version
run: echo "python_version=$(python --version)" >> $GITHUB_OUTPUT
shell: bash
- name: Cache dependencies
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-min-dependencies-${{ hashFiles('**/pdm.lock') }}
restore-keys: |
${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-min-dependencies
- name: Install PDM
run: pip install pdm
- name: Install minimum dependencies
run: pdm install -L pdm.minimal.lock
- name: Run mypy
run: pdm mypy --show-error-codes
- name: Lint
run: pdm run ruff check .
- name: Run unit tests only # snapshots are expected to fail
run: pdm unit_test
coverage:
name: Combine & check coverage
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Download coverage reports
uses: actions/[email protected]
with:
merge-multiple: true
- name: Create Virtual Environment
run: python -m venv .venv
- name: Combine coverage & fail if it's <100%.
run: |
# Install coverage
.venv/bin/pip install --upgrade coverage[toml]
# Find all of the downloaded coverage reports and combine them
.venv/bin/python -m coverage combine
# Create html report
.venv/bin/python -m coverage html --skip-covered --skip-empty
# Report in Markdown and write to summary.
.venv/bin/python -m coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
# Report again and fail if under 100%.
.venv/bin/python -m coverage report --fail-under=100
- name: Upload HTML report if check failed.
uses: actions/[email protected]
with:
name: html-report
path: htmlcov
if: ${{ failure() }}
integration:
name: Integration Tests
runs-on: ubuntu-latest
strategy:
matrix:
httpx_version:
- "0.20.0"
- ""
services:
openapi-test-server:
image: ghcr.io/openapi-generators/openapi-test-server:0.0.1
ports:
- "3000:3000"
steps:
- uses: actions/[email protected]
- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.9"
- name: Get Python Version
id: get_python_version
run: echo "python_version=$(python --version)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v4
with:
path: .venv
key: ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies-${{ hashFiles('**/pdm.lock') }}
restore-keys: |
${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies
- name: Install dependencies
run: |
pip install pdm
python -m venv .venv
pdm install
- name: Cache Generated Client Dependencies
uses: actions/cache@v4
with:
path: integration-tests/.venv
key: ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-integration-dependencies-${{ hashFiles('**/pdm.lock') }}
restore-keys: |
${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-integration-dependencies
- name: Set httpx version
if: matrix.httpx_version != ''
run: |
cd integration-tests
pdm add httpx==${{ matrix.httpx_version }}
- name: Install Integration Dependencies
run: |
cd integration-tests
pdm install
- name: Run Tests
run: |
cd integration-tests
pdm run pytest
pdm run mypy . --strict