-
Notifications
You must be signed in to change notification settings - Fork 14
480 lines (398 loc) · 13.8 KB
/
test.yml
File metadata and controls
480 lines (398 loc) · 13.8 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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
# Based on - https://github.com/samuelcolvin/rtoml/blob/main/.github/workflows/ci.yml
# The MIT License (MIT)
#
# Copyright (c) 2020 Samuel Colvin
#
# 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.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
name: CI
on:
push:
branches:
- main
tags:
- "**"
pull_request: {}
pull_request_target:
types: [labeled]
jobs:
test:
runs-on: ubuntu-latest
name: test py${{ matrix.python-version }}
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
services:
docker:
image: docker:24.0.2
options: --privileged
env:
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-python-rust
with:
python-version: ${{ matrix.python-version }}
cache-prefix: 'test'
- name: Install main dependencies
run: |
export PATH="/Users/runner/.local/bin:/Users/runner/.cargo/bin:$PATH"
make install-deps-lib
- name: Tests
run: make test-lib
lint:
name: lint py${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-python-rust
with:
python-version: ${{ matrix.python-version }}
cache-prefix: 'lint'
- name: Install dependencies
run: make install-deps
- name: Run typehinting
run: make lint-validation
- name: Lint Clippy
run: cargo clippy -- -D warnings
# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
check:
if: always()
needs: [test, lint]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
rust-tests:
# Test the OS specific rust hooks
name: rust-tests os=${{ matrix.os }} release=${{ matrix.release || 'latest' }}
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Full Build')
strategy:
fail-fast: false
matrix:
include:
- os: linux
- os: macos
- os: windows
runs-on: ${{ (matrix.os == 'linux' && 'ubuntu') || matrix.os }}-${{ matrix.release || 'latest' }}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10 (min supported version)
uses: actions/setup-python@v5
with:
python-version: "3.10"
# Before we start building, validate that the Rust code compiles
# This helps to detect errors on different underlying architectures, since
# these wheel builds are representative of our deployment platforms
- name: Rust tests
run: cargo test --all
# Run basic benchmarks to make sure these still compile
- name: Rust benchmarks
run: cargo check --benches
build:
name: build os=${{ matrix.os }} target=${{ matrix.target }} int=${{ matrix.interpreter || 'all' }} ml=${{ matrix.manylinux || 'auto' }} release=${{ matrix.release || 'latest' }}
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Full Build')
strategy:
fail-fast: false
matrix:
include:
- os: linux
target: x86_64
- os: linux
target: aarch64
- os: macos
target: x86_64
- os: macos
target: aarch64
- os: windows
target: x86_64
runs-on: ${{ (matrix.os == 'linux' && 'ubuntu') || matrix.os }}-${{ matrix.release || 'latest' }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-python-rust
with:
python-version: "3.11"
cache-prefix: 'build'
os: ${{ matrix.os }}
target: ${{ matrix.target }}
python-architecture: ${{ matrix.python-architecture || 'x64' }}
- name: Update version
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
run: |
cd .github
uv venv
uv sync
if [ "${{ runner.os }}" = "Windows" ]; then
source .venv/Scripts/activate
else
source .venv/bin/activate
fi
cd ..
python .github/scripts/update_version.py ${{ github.ref_name }}
- run: pip install -U twine
#
# Build pipeline
#
- name: build sdist
if: ${{ matrix.os == 'linux' && matrix.target == 'x86_64' }}
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- name: build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux || 'auto' }}
args: -vv --release --out dist --interpreter ${{ matrix.interpreter || '3.10 3.11 3.12 3.13' }}
rust-toolchain: stable
docker-options: -e CI -e CI_TARGET=${{ matrix.target }}
# Already defaults to build, but we make explicit here. Any arguments should
# be added to args above and not here - otherwise we will affect the switch()
# condition handling of maturin-action.
command: build
- run: ${{ (matrix.os == 'windows' && 'dir') || 'ls -lh' }} dist/
- run: twine check --strict dist/*
# Unzip wheel files to directories
- name: Unzip Wheels
shell: bash
run: |
mkdir unpacked_wheels
for wheel in dist/*.whl; do
unzip -d unpacked_wheels/"$(basename "$wheel" .whl)" "$wheel"
done
rm dist/*.whl # Remove original .whl files to avoid confusion
- name: List unpacked wheel directories
shell: bash
run: ls -lh unpacked_wheels/
- uses: actions/upload-artifact@v4
with:
name: pypi_files-${{ matrix.os }}-${{ matrix.target }}
path: unpacked_wheels/
- uses: actions/upload-artifact@v4
with:
name: pypi_files_sdist-${{ matrix.os }}-${{ matrix.target }}
path: dist/
inspect-pypi-assets:
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: set up python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: get dist artifacts
uses: actions/download-artifact@v4
with:
pattern: pypi_files-*
merge-multiple: true
path: unpacked_wheels
- name: get dist artifacts
uses: actions/download-artifact@v4
with:
pattern: pypi_files_sdist-*
merge-multiple: true
path: dist
- name: list unpacked files
run: |
ls -lh unpacked_wheels/
echo "`ls unpacked_wheels | wc -l` files"
- name: list dist files
run: |
ls -lh dist/
echo "`ls dist | wc -l` files"
- name: extract and list sdist file
run: |
mkdir sdist-files
tar -xvf dist/*.tar.gz -C sdist-files
find sdist-files -print
# Unzip wheel files to directories
- name: Zip Wheels
run: |
for dir in unpacked_wheels/*; do
# Check if it's a directory
if [ -d "$dir" ]; then
# Get the base name of the directory
base_name=$(basename "$dir")
# Zip the directory into a .whl file inside the dist directory
cd unpacked_wheels/$base_name
zip -r "../../dist/${base_name}.whl" .
cd ../..
fi
done
- run: pip install twine
- run: twine check dist/*
release:
needs: [check, build, inspect-pypi-assets]
if: "success() && startsWith(github.ref, 'refs/tags/')"
# pypi release script requires linux runner
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: get unpacked_wheels artifacts
uses: actions/download-artifact@v4
with:
pattern: pypi_files-*
merge-multiple: true
path: unpacked_wheels
- name: get dist artifacts
uses: actions/download-artifact@v4
with:
pattern: pypi_files_sdist-*
merge-multiple: true
path: dist
- run: ls -lh unpacked_wheels
- run: ls -lh dist
# Unzip wheel files to directories
- name: Zip Wheels
run: |
for dir in unpacked_wheels/*; do
# Check if it's a directory
if [ -d "$dir" ]; then
# Get the base name of the directory
base_name=$(basename "$dir")
# Zip the directory into a .whl file inside the dist directory
cd unpacked_wheels/$base_name
zip -r "../../dist/${base_name}.whl" .
cd ../..
fi
done
- uses: actions/upload-artifact@v4
with:
name: final_dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
lib-integration-test:
name: Integration Tests - py${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-python-rust
with:
python-version: ${{ matrix.python-version }}
cache-prefix: 'integration'
- name: Install dependencies
run: make install-deps-lib
- name: Run tests
timeout-minutes: 10
run: make test-lib-integrations
cma-test:
name: CMA Test - py${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-python-rust
with:
python-version: ${{ matrix.python-version }}
cache-prefix: 'cma'
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Install dependencies
run: make install-deps-create-mountaineer-app
- name: Run tests
run: make test-create-mountaineer-app
- name: Run integration tests
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Full Build')
run: make test-create-mountaineer-app-integrations test-args="-vv"
cma-build:
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'Full Build')
strategy:
fail-fast: false
matrix:
include:
# linux
- os: linux
target: x86_64
- os: linux
target: aarch64
# macos
- os: macos
target: x86_64
- os: macos
target: aarch64
runs-on: ${{ (matrix.os == 'linux' && 'ubuntu') || matrix.os }}-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
architecture: ${{ matrix.python-architecture || 'x64' }}
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Update version in pyproject.toml
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
run: |
cd .github
uv venv
uv sync
if [ "${{ runner.os }}" = "Windows" ]; then
source .venv/Scripts/activate
else
source .venv/bin/activate
fi
cd ..
cd create_mountaineer_app
python ../.github/scripts/update_version.py ${{ github.ref_name }}
- name: Build
run: |
make install-deps-create-mountaineer-app
cd create_mountaineer_app && uv build
- uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}-${{ matrix.target }}
path: create_mountaineer_app/dist
cma-release:
needs: [cma-test, cma-build, release]
if: "success() && startsWith(github.ref, 'refs/tags/')"
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
contents: read
steps:
- uses: actions/download-artifact@v4
with:
pattern: dist-*
merge-multiple: true
path: dist
- run: ls -lh dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1