-
Notifications
You must be signed in to change notification settings - Fork 1
266 lines (229 loc) · 7.25 KB
/
ci.yml
File metadata and controls
266 lines (229 loc) · 7.25 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
258
259
260
261
262
263
264
265
266
# CI pipeline for the OpenDecree Python SDK.
#
# Jobs: lint, typecheck, test (matrix: 3.11-3.13), examples → check (alls-green gate)
# Integration job is optional — runs on workflow_dispatch or when
# DECREE_TEST_ADDR secret is set, starting a live server via docker-compose.
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_call:
workflow_dispatch:
inputs:
run-integration:
description: "Run integration tests against a live server"
type: boolean
default: false
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install ruff
run: pip install ruff
- name: Check lint
run: ruff check sdk/src/ sdk/tests/
- name: Check formatting
run: ruff format --check sdk/src/ sdk/tests/
typecheck:
name: Typecheck
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
cache-dependency-path: sdk/pyproject.toml
- name: Install SDK with dev dependencies
run: pip install -e "sdk[dev]"
- name: Run mypy
run: cd sdk && mypy src/
test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: sdk/pyproject.toml
- name: Install SDK with dev dependencies
run: pip install -e "sdk[dev]"
- name: Run tests with coverage
run: cd sdk && pytest --cov --cov-report=term-missing --cov-report=xml:coverage.xml
- name: Upload coverage to Codecov
if: matrix.python-version == '3.12'
# codecov/codecov-action@v6.0.0
uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354
with:
files: sdk/coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
examples:
name: Examples
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
cache-dependency-path: sdk/pyproject.toml
- name: Install SDK
run: pip install -e sdk/
- name: Compile-check all examples
run: |
python -m py_compile examples/quickstart/main.py
python -m py_compile examples/async-client/main.py
python -m py_compile examples/live-config/main.py
python -m py_compile examples/error-handling/main.py
python -m py_compile examples/setup.py
wheel-check:
name: Wheel contents
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Build wheel
run: |
pip install build
python -m build sdk/ --wheel --outdir /tmp/dist
- name: Assert py.typed present
run: |
pip install zipfile36
python - <<'EOF'
import zipfile, glob, sys
wheels = glob.glob("/tmp/dist/*.whl")
assert wheels, "no wheel found"
with zipfile.ZipFile(wheels[0]) as whl:
names = whl.namelist()
found = [n for n in names if n.endswith("py.typed")]
if not found:
print("FAIL: py.typed missing from wheel"); print("\n".join(names)); sys.exit(1)
print(f"OK: {found[0]}")
EOF
integration:
name: Integration tests
runs-on: ubuntu-latest
if: >-
github.event_name == 'workflow_dispatch' &&
inputs.run-integration == true
timeout-minutes: 20
permissions:
contents: read
packages: read
steps:
- name: Checkout decree-python
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Checkout decree (for docker-compose + server)
uses: actions/checkout@v6
with:
repository: opendecree/decree
path: decree
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
cache-dependency-path: sdk/pyproject.toml
- name: Install SDK with dev dependencies
run: pip install -e "sdk[dev]"
- name: Log in to ghcr.io
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
with:
driver: docker-container
driver-opts: network=host
- name: Build server image
uses: docker/build-push-action@v7
with:
context: decree
file: decree/build/Dockerfile
load: true
tags: decree-server
cache-from: |
type=registry,ref=ghcr.io/opendecree/decree:buildcache
type=gha,scope=py-integ-server
cache-to: type=gha,scope=py-integ-server,mode=max
- name: Build tools image (for migrations)
uses: docker/build-push-action@v7
with:
context: decree/build
file: decree/build/Dockerfile.tools
load: true
tags: decree-tools
cache-from: |
type=registry,ref=ghcr.io/opendecree/decree-tools:buildcache
type=gha,scope=py-integ-tools
cache-to: type=gha,scope=py-integ-tools,mode=max
- name: Start decree service
run: docker compose -f decree/docker-compose.yml up -d --wait service
env:
SERVICE_IMAGE: decree-server
TOOLS_IMAGE: decree-tools
- name: Run integration tests
run: cd sdk && pytest -m integration -v
env:
DECREE_TEST_ADDR: "localhost:9090"
- name: Tear down services
if: always()
run: docker compose -f decree/docker-compose.yml down -v
check:
name: CI check
if: always()
needs: [lint, typecheck, test, examples, wheel-check]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}