-
Notifications
You must be signed in to change notification settings - Fork 13
711 lines (586 loc) · 21.3 KB
/
test.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
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
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
# 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: {}
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"]
services:
docker:
image: docker:24.0.2
options: --privileged
env:
PYTHON: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v4
- name: set up python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: install rust stable
uses: dtolnay/rust-toolchain@stable
- id: cache-rust
name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: v1
- name: install golang
uses: actions/setup-go@v3
with:
go-version: "1.21.2"
- name: Log go env
run: |
go env
- name: Get GOROOT
run: |
echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Install main dependencies
run: |
export PATH="/Users/runner/.local/bin:/Users/runner/.cargo/bin:$PATH"
make clean-poetry-lock
make install-deps-lib
- name: Tests
run: make test-lib
env:
GOROOT: ${{ env.GOROOT }}
GOPATH: ${{ env.GOPATH }}
GOMODCACHE: ${{ env.GOMODCACHE }}
lint:
name: lint py${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: install rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: cache rust
uses: Swatinem/rust-cache@v2
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 -
- name: install golang
uses: actions/setup-go@v3
with:
go-version: "1.21.2"
- name: Log go env
run: |
go env
- name: Get GOROOT
run: |
echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV
- name: Log go env
run: |
go env
- name: Install dependencies
run: |
export PATH="/Users/runner/.local/bin:/Users/runner/.cargo/bin:$PATH"
make clean-poetry-lock
make install-deps
env:
GOROOT: ${{ env.GOROOT }}
GOPATH: ${{ env.GOPATH }}
GOMODCACHE: ${{ env.GOMODCACHE }}
- name: Run typehinting
run: make lint-validation
- name: Lint Clippy
run: cargo clippy -- -D warnings
env:
GOROOT: ${{ env.GOROOT }}
GOPATH: ${{ env.GOPATH }}
GOMODCACHE: ${{ env.GOMODCACHE }}
# 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: install golang
uses: actions/setup-go@v3
with:
go-version: "1.21.2"
- name: Log go env
run: |
go env
- name: Get GOROOT
run: |
echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV
# 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:
# The main contraint with our architecture choices at the moment is the dependency
# on rusty_v8, which only supports x86_64 and aarch64. Deno is tracking: https://github.com/denoland/deno/issues/7517
# linux
- os: linux
target: x86_64
- os: linux
target: aarch64
# macos
- os: macos
target: x86_64
- os: macos
target: aarch64
# windows
- os: windows
target: x86_64
runs-on: ${{ (matrix.os == 'linux' && 'ubuntu') || matrix.os }}-${{ matrix.release || '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 golang
uses: actions/setup-go@v3
with:
go-version: "1.21.2"
- name: Set golang build architecture
shell: bash
run: |
case "${{ matrix.target }}" in
x86_64) export GOARCH="amd64";;
aarch64) export GOARCH="arm64";;
*) echo "Unsupported architecture: ${{ matrix.target }}"; exit 1;;
esac
echo "GOARCH=${GOARCH}"
echo "GOARCH=${GOARCH}" >> $GITHUB_ENV
# Must be explicitly specified for cross-compilation
# Otherwise it causes the misleading "go: no Go source files" error
echo "CGO_ENABLED=1" >> $GITHUB_ENV
- name: Log go env
run: |
go env
- name: Get GOROOT
run: |
echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV
- run: pip install -U twine
#
# Bump release version
# Our managed directory uses poetry for these dependencies but there's an issue
# with installing poetry on windows runners, so we use a global python install
# for the required dependencies
#
- name: Update version
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
run: |
pip install packaging toml
python .github/scripts/update_version.py ${{ github.ref_name }}
#
# 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' }}
rust-toolchain: stable
docker-options: -e CI -e CI_TARGET=${{ matrix.target }} -e GOARCH=${{ env.GOARCH }} -e CGO_ENABLED=${{ env.CGO_ENABLED }}
# 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
before-script-linux: |
# Install go within the docker container - only used for manylinux builds
# since they need an isolated docker context. The other build pipelines
# just run within the host so use the global worker's go install.
# Determine the machine architecture
echo "Raw architecture: $(uname -m)"
# Log the current glibc version
ldd --version
# System configs
uname -a
cat /etc/os-release
cat /proc/version
# Determine distribution from /etc/os-release
DISTRO=$(grep ^ID= /etc/os-release | cut -d= -f2 | tr -d '"')
# Install necessary packages based on the distribution
if [ "$DISTRO" = "centos" ]; then
# CentOS specific package installation
yum -y install wget llvm-toolset-7 centos-release-scl
export PATH=/opt/rh/llvm-toolset-7/root/usr/bin:/opt/rh/llvm-toolset-7/root/usr/sbin:/opt/rh/devtoolset-10/root/usr/bin:$PATH
export LIBCLANG_PATH=/opt/rh/llvm-toolset-7/root/usr/lib64/
elif [ "$DISTRO" = "ubuntu" ]; then
# Ubuntu specific package installation
# Clang is already installed as part of the base image
apt-get update
apt-get -y install wget
# The maturin environment includes the gcc cross-compilers for aarch64, but it
# doesn't include the necessary headers
# This causes issues when rust / bindgen tries to run clang, which will fail with
# missing headers like 'bits/libc-header-start.h' file not found
# We install the headers here to fix this issue
apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
find /usr -name libc-header-start.h
else
echo "Unsupported distribution: $DISTRO"
exit 1
fi
clang --version
ls -ls /usr/bin
case "${{ matrix.target }}" in
x86_64) ;;
aarch64)
export PATH=$PATH:/usr/aarch64-unknown-linux-gnu/bin;
aarch64-unknown-linux-gnu-gcc --version;
export CC=aarch64-unknown-linux-gnu-gcc;;
*) echo "Unsupported architecture: ${{ matrix.target }}"; exit 1;;
esac
echo "GOARCH=${GOARCH}"
GOVERSION="1.22.1"
# Download and Install Go - we will always be running on a x86_64 runner
# despite the build architecture
wget -q https://go.dev/dl/go${GOVERSION}.linux-amd64.tar.gz
tar -C /usr/local -xzf go${GOVERSION}.linux-amd64.tar.gz
rm -f go${GOVERSION}.linux-amd64.tar.gz
# Set up Go environment variables
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
go env
go version
go tool dist list
env:
GOROOT: ${{ env.GOROOT }}
GOPATH: ${{ env.GOPATH }}
GOMODCACHE: ${{ env.GOMODCACHE }}
- 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"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: install golang
uses: actions/setup-go@v3
with:
go-version: "1.21.2"
- name: Log go env
run: |
go env
- name: Get GOROOT
run: |
echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: make install-deps-lib
- name: Run tests
run: make test-lib-integrations
env:
GOROOT: ${{ env.GOROOT }}
GOPATH: ${{ env.GOPATH }}
GOMODCACHE: ${{ env.GOMODCACHE }}
# Tie create-mountaineer-app distribution to the release of the main
# package, since if the main package fails we shouldn't yet bump the
# create-mountaineer-app version.
cma-test:
name: CMA Test - py${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: install golang
uses: actions/setup-go@v3
with:
go-version: "1.21.2"
- name: Log go env
run: |
go env
- name: Get GOROOT
run: |
echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- 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"
env:
GOROOT: ${{ env.GOROOT }}
GOPATH: ${{ env.GOPATH }}
GOMODCACHE: ${{ env.GOMODCACHE }}
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 Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Update version in pyproject.toml
if: startsWith(github.ref, 'refs/tags/v')
run: |
cd create_mountaineer_app
VERSION=${GITHUB_REF#refs/tags/v}
echo "Version to update: $VERSION"
poetry version $VERSION
- name: Build
run: |
cd create_mountaineer_app
poetry 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