-
Notifications
You must be signed in to change notification settings - Fork 3
257 lines (214 loc) · 6.42 KB
/
ci.yml
File metadata and controls
257 lines (214 loc) · 6.42 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
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: "Run tests via nox"
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: testdb
ports:
- 5432/tcp # host‑port is picked automatically
options: >-
--health-cmd="pg_isready -U postgres -d testdb"
--health-interval=10s
--health-timeout=5s
--health-retries=5
strategy:
fail-fast: false
matrix:
python-version: [ "3.10", "3.11", "3.12", "3.13" ]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.6.9"
python-version: ${{ matrix.python-version }}
prune-cache: true
- name: Run tests via nox
env:
# GitHub tells you which host‑port was assigned via the `job.services` context
POSTGRES_URI: postgres://postgres:postgres@localhost:${{ job.services.postgres.ports['5432'] }}/testdb
run: |
uv run nox -s pytest -- --coverage
- name: Upload coverage
uses: actions/upload-artifact@v7
with:
name: .coverage.${{ matrix.python-version }}
path: .coverage
retention-days: 1
if-no-files-found: error
include-hidden-files: true
# upload-coverage taken from: https://github.com/hikari-py/hikari/blob/master/.github/workflows/ci.yml#L66
#
# Copyright (c) 2020 Nekokatt
# Copyright (c) 2021-present davfsa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
upload-coverage:
needs: [ test ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.6.9"
python-version: "3.13"
activate-environment: true
- name: Download coverage
uses: actions/download-artifact@v7
with:
path: coverages/
- name: Extract individual coverage files
run: |
cd coverages
for coverage_dir in ./.coverage.*; do
mv "$coverage_dir/.coverage" "../$coverage_dir"
rmdir "$coverage_dir"
done
cd ..
- name: Combine coverage
run: |
uv sync --frozen --only-group coverage
coverage combine
coverage xml
coverage report
- name: Upload coverage to codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
ruff:
runs-on: ubuntu-latest
name: "Run ruff via nox"
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.6.9"
python-version: "3.13"
- name: Run ruff via nox
run: |
uv run nox -s ruff_check -- --output-format=github
pyright:
runs-on: ubuntu-latest
name: "Run pyright via nox"
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.6.9"
python-version: "3.13"
- name: Run pyright via nox
run: |
uv run nox -s pyright
asyncpg:
runs-on: ubuntu-latest
name: "Run asyncpg check via nox"
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.6.9"
python-version: "3.13"
- name: Install sqlc
uses: sqlc-dev/setup-sqlc@v4
with:
sqlc-version: '1.30.0'
- name: Run sqlc verify via nox
run: |
uv run nox -s asyncpg_check
aiosqlite:
runs-on: ubuntu-latest
name: "Run aiosqlite check via nox"
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.6.9"
python-version: "3.13"
- name: Install sqlc
uses: sqlc-dev/setup-sqlc@v4
with:
sqlc-version: '1.30.0'
- name: Run sqlc verify via nox
run: |
uv run nox -s aiosqlite_check
sqlite3:
runs-on: ubuntu-latest
name: "Run sqlite3 check via nox"
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.6.9"
python-version: "3.13"
- name: Install sqlc
uses: sqlc-dev/setup-sqlc@v4
with:
sqlc-version: '1.30.0'
- name: Run sqlc verify via nox
run: |
uv run nox -s sqlite3_check
test-build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.24.1'
- name: Make build script executable
run: chmod +x scripts/build/build.sh
- name: Run build.sh
run: ./scripts/build/build.sh
- name: Upload wasm artifact
uses: actions/upload-artifact@v7
with:
name: wasm-artifact
path: sqlc-gen-better-python.wasm
if-no-files-found: error
retention-days: 30
ci-done:
needs: [ test, upload-coverage, asyncpg, aiosqlite, sqlite3, pyright, ruff, test-build ]
if: always() && !cancelled()
runs-on: ubuntu-latest
steps:
- name: Set status based on required jobs
env:
RESULTS: ${{ join(needs.*.result, ' ') }}
run: |
for result in $RESULTS; do
if [ "$result" != "success" ]; then
exit 1
fi
done