forked from mozilla/glean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.yml
1181 lines (1108 loc) · 36.2 KB
/
config.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
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
---
version: 2.1
###########################################################################
# DEFINITIONS
definitions:
- release_filters: &release-filters
branches:
ignore: /.*/
tags:
only: /^v.*/
- ci_filters: &ci-filters
branches:
ignore: release
##########################################################################
# COMMANDS
commands:
skip-if-doc-only:
steps:
- run:
name: Check doc only skip condition
command: |
if git log -1 "$CIRCLE_SHA1" | grep -q '\[doc only\]'; then
echo "Skipping this step. Last commit was tagged to not require tests."
circleci-agent step halt
fi
setup-rust-toolchain:
parameters:
rust-version:
type: string
default: "stable"
steps:
- run:
name: Turn on RUST_BACKTRACE and RUST_LOG for any job that installs rustc
command: |
echo "export RUST_BACKTRACE=1" >> $BASH_ENV
echo "export RUST_LOG=glean_core=debug" >> $BASH_ENV
echo "export CARGO_INCREMENTAL=0" >> $BASH_ENV
- run:
name: Setup Rust toolchain
command: |
rustup install <<parameters.rust-version>>
rustup default <<parameters.rust-version>>
rustc --version
test-rust:
parameters:
rust-version:
type: string
default: "stable"
steps:
- checkout
- skip-if-doc-only
- setup-rust-toolchain:
rust-version: <<parameters.rust-version>>
- run:
name: Test
command: |
export GLEAN_TEST_COVERAGE=$(realpath glean_coverage.txt)
cargo test --verbose --jobs 6 -- --nocapture
- run:
name: Install required Python dependencies
command: |
sudo apt update
sudo apt install --yes --no-install-recommends \
python3-pip \
python3.10-venv
- run:
name: Run Rust sample
command: |
cargo run -p sample
- run:
name: Run Rust RLB test
command: |
glean-core/rlb/tests/test-shutdown-blocking.sh
- run:
name: Run Rust RLB crash test
command: |
glean-core/rlb/tests/test-thread-crashing.sh
- run:
name: Upload coverage report
command: |
pip3 install $(grep glean_parser pyproject.toml | tr -d ',"')
glean_parser coverage --allow-reserved -c glean_coverage.txt -f codecovio -o codecov.json glean-core/metrics.yaml
bin/codecov.sh -X yaml -f codecov.json
install-rustup:
steps:
- run:
name: Installing rustup
command: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
- run:
name: Setup custom environment variables
command: |
echo 'export PATH=$HOME/.cargo/bin:$PATH' >> $BASH_ENV
install-android-ndk:
steps:
- run:
name: Install missing Android SDK & NDK
command: |
sdkmanager \
"build-tools;34.0.0" \
"ndk;26.2.11394342"
android-setup:
steps:
- install-rustup
- setup-rust-toolchain:
rust-version: stable
- install-android-ndk
- run:
name: Restrict to Linux builds only
command: |
echo "rust.targets=linux-x86-64" > local.properties
test-python:
steps:
- install-rustup
- setup-rust-toolchain
- run:
name: Remove coredump file restriction
command: |
# tell the operating system to remove the file size limit on core dump files
ulimit -c unlimited
- run:
name: Python tests
command: |
export PYTEST_ARGS=-v
make test-python
- run:
name: Detect and gather coredump files
when: always
command: |
mkdir -p ~/coredumps
# Try to copy the core file(s). Don't fail if they don't exist.
cp core.* ~/coredumps || true
- store_artifacts:
path: ~/coredumps
destination: coredumps
build-windows-x86_64-wheel:
steps:
- install-rustup
- setup-rust-toolchain
- install-mingw
- run:
name: Install Python development tools for host
command:
make setup-python
- run:
name: Build Windows wheel
command: |
make build-python-wheel GLEAN_BUILD_TARGET=x86_64-pc-windows-gnu
build-windows-i686-wheel:
steps:
- install-rustup
- setup-rust-toolchain
- install-mingw
- run:
name: Install Python development tools for host
command:
make setup-python
- run:
name: Build Windows wheel
command: |
make build-python-wheel GLEAN_BUILD_TARGET=i686-pc-windows-gnu
install-python-windows-deps:
steps:
- run:
name: Set up dependencies for Python for Windows
command: |
echo "export WINEDEBUG=-all" >> $BASH_ENV
wget https://bootstrap.pypa.io/get-pip.py
$WINPYTHON get-pip.py
echo "import site" >> winpython/python38._pth
echo "import sys; sys.path.insert(0, '')" >> winpython/sitecustomize.py
# The Windows-Python-installed-inside-Wine thing can't actually build wheels,
# so just install all of the wheels that were created as part of creating the
# environment on the host system before attempting to install everything in
# requirements_dev.txt
find ~/.cache/pip -name "*.whl" -exec $WINPYTHON -m pip install {} \;
$WINPYTHON -m pip install -r glean-core/python/requirements_dev.txt --no-warn-script-location
$WINPYTHON -m pip install target/wheels/*.whl --no-warn-script-location
install-mingw:
steps:
- run:
name: Install mingw
command: |
sudo apt update
# This package contains tools for both i686 and x86_64 targets
sudo apt install -y gcc-mingw-w64
- run:
name: Add mingw target
command: |
rustup target add x86_64-pc-windows-gnu
rustup target add i686-pc-windows-gnu
# Set the linker to use for Rust/mingw
echo '[target.x86_64-pc-windows-gnu]' >> ~/.cargo/config
echo 'linker = "/usr/bin/x86_64-w64-mingw32-gcc"' >> ~/.cargo/config
echo '[target.i686-pc-windows-gnu]' >> ~/.cargo/config
echo 'linker = "/usr/bin/i686-w64-mingw32-gcc"' >> ~/.cargo/config
install-ghr-darwin:
steps:
- run:
name: Get ghr release tool
command: |
GHR_VERSION=v0.16.2
GHR=ghr_${GHR_VERSION}_darwin_arm64
GHR_SHA256=f762742b3a1a6a10c87ca1bfcc043e9e535ce4d1defa02e4e9d5a4875c1116ba
curl -sfSL --retry 5 -O "https://github.com/tcnksm/ghr/releases/download/${GHR_VERSION}/${GHR}.zip"
echo "${GHR_SHA256} *${GHR}.zip" | shasum -a 256 -c -
unzip "${GHR}.zip"
cp ./${GHR}/ghr ghr
install-ghr-linux:
steps:
- run:
name: Get ghr release tool
command: |
GHR_VERSION=v0.16.2
GHR=ghr_${GHR_VERSION}_linux_amd64
GHR_SHA256=084ed9819dff71ea77f77a3071a643b6d1cbe5d2ab57bb5f56bb23de17189cd0
curl -sfSL --retry 5 -O "https://github.com/tcnksm/ghr/releases/download/${GHR_VERSION}/${GHR}.tar.gz"
echo "${GHR_SHA256} *${GHR}.tar.gz" | sha256sum -c -
tar -xf "${GHR}.tar.gz"
cp ./${GHR}/ghr ghr
jobs:
###########################################################################
# Project-level
License check:
docker:
- image: cimg/rust:1.67
steps:
- checkout
- run:
name: Install cargo-deny
command: |
DENY_VERSION=0.14.20
DENY="cargo-deny-${DENY_VERSION}-x86_64-unknown-linux-musl"
DENY_SHA256=1c9f8cfc23647346f1aa7ba0ed3167191f3198aba3dc5a957fda6f85a82fc424
curl -sfSL --retry 5 -O "https://github.com/EmbarkStudios/cargo-deny/releases/download/${DENY_VERSION}/${DENY}.tar.gz"
echo "${DENY_SHA256} *${DENY}.tar.gz" | shasum -a 256 -c -
tar -xvf "${DENY}.tar.gz"
mv "${DENY}/cargo-deny" ~/.cargo/bin/cargo-deny
chmod +x ~/.cargo/bin/cargo-deny
- run:
name: Run license check
command: cargo deny check licenses
- run:
name: Run dependency ban check
command: cargo deny check bans
Check vendored schema:
docker:
- image: cimg/rust:1.67
steps:
- checkout
- run:
name: Check vendored schema for upstream updates
command: |
bin/update-schema.sh HEAD
if ! git diff --exit-code HEAD -- glean-core/preview/tests/glean.1.schema.json; then
echo "===================================="
echo "Latest schema from upstream changed."
echo "Please regenerate the file using:"
echo " bin/update-schema.sh latest"
echo "Commit the modified files and push."
echo "===================================="
exit 1
fi
Lint YAML with yamllint:
docker:
- image: cimg/python:3.8
steps:
- checkout
- run: pip install yamllint
- run: make lint-yaml
###########################################################################
# Rust / C / FFI
Check Rust formatting:
docker:
- image: cimg/rust:1.67
steps:
- checkout
- run: rustup component add rustfmt
- run: rustfmt --version
- run: cargo fmt -- --check
Lint Rust with clippy:
docker:
- image: cimg/rust:1.67
steps:
- checkout
- run: rustup component add clippy
- run: cargo clippy --version
- run:
name: Install required Python dependencies
command: |
sudo apt update
sudo apt install --yes --no-install-recommends \
python3.10-venv
- run:
name: Clippy
command: make lint-rust
Rust tests - stable:
docker:
- image: cimg/rust:1.67
resource_class: "medium+"
steps:
- test-rust
# RLB Windows compile test
- install-mingw
- run:
name: Check RLB on Windows x86_64
command: |
cargo check -p glean --examples --tests --target x86_64-pc-windows-gnu
- run:
name: Check RLB on Windows i686
command: |
cargo check -p glean --examples --tests --target i686-pc-windows-gnu
Rust tests - beta:
docker:
- image: cimg/rust:1.67
steps:
- test-rust:
rust-version: "beta"
Rust tests - minimum version:
docker:
- image: cimg/rust:1.67
resource_class: "medium+"
steps:
- test-rust:
rust-version: "1.66.1"
Generate Rust documentation:
docker:
- image: cimg/rust:1.67
steps:
- checkout
- run:
name: Version information
command: rustc --version; cargo --version; rustup --version
- run:
name: Install mdbook-dtmo
command: |
MDBOOK_VERSION=0.15.2
MDBOOK="mdbook-dtmo-${MDBOOK_VERSION}-x86_64-unknown-linux-musl.tar.gz"
MDBOOK_SHA256=87f5cb874faadc745f033b646d358669b172edf19d2ca0a4e291a9c627e52e13
curl -sfSL --retry 5 -O "https://github.com/badboy/mdbook-dtmo/releases/download/${MDBOOK_VERSION}/${MDBOOK}"
echo "${MDBOOK_SHA256} *${MDBOOK}" | shasum -a 256 -c -
tar -xvf "${MDBOOK}"
# We rename it to mdbook here, so other tools keep working as expected
mv mdbook-dtmo ~/.cargo/bin/mdbook
mdbook --version
- run:
name: Build Rust documentation
command: bin/build-rust-docs.sh
- persist_to_workspace:
root: build/
paths:
- docs/book
- docs/dev
- docs/docs
- docs/shared
- docs/index.html
Publish Rust crates:
docker:
- image: cimg/rust:1.75
steps:
- checkout
- run:
name: Publish Cargo Package
command: |
# Login to crates.io so the following commands work
cargo login "$CRATES_IO_TOKEN"
# Publish all crates from CI.
# The token is set in CircleCI settings.
# Need some sleep inbetween to ensure crates.io is updated.
pushd glean-core
cargo publish --verbose
pushd rlb
cargo publish --verbose
###########################################################################
# Android / Kotlin / Java
Lint Android with ktlint and detekt:
docker:
- image: cimg/android:2024.01.1-browsers
steps:
- checkout
- android-setup
- run: ./gradlew --no-daemon lint
- run: ./gradlew --no-daemon ktlint
- run: ./gradlew --no-daemon detekt
Android tests:
docker:
- image: cimg/android:2024.01.1-browsers
steps:
- checkout
- skip-if-doc-only
- android-setup
- run:
name: Remove coredump file restriction
command: |
# tell the operating system to remove the file size limit on core dump files
ulimit -c unlimited
- run:
name: Android tests
command: ./gradlew --no-daemon :glean:testDebugUnitTest
environment:
GRADLE_OPTS: -Xmx2048m
TARGET_CFLAGS: -DNDEBUG
- run:
name: Save test results
command: |
mkdir -p ~/test-results/junit/
mkdir -p ~/test-results/tests/
cp -a glean-core/android/build/reports/tests ~/test-results/
find glean-core/android/build -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/test-results/junit/ \;
when: always
- store_artifacts:
path: ~/test-results/tests
destination: test-results
- run:
name: Detect and gather coredump files
command: |
mkdir -p ~/coredumps
# Try to copy the core file from a default location. Don't fail if it doesn't exist.
cp -a glean-core/android/core ~/coredumps || true
# The JVM/Gradle might also produce a log file named like "hs_err_pid3247.log", let's copy that as well
find . -type f -name "hs_*.log" | xargs -I% cp -a % ~/coredumps/%
- store_artifacts:
path: ~/coredumps
destination: coredumps
- store_test_results:
path: ~/test-results
- run:
name: Build Android Sample App
command: |
./gradlew :glean-sample-app:assembleAndroidTest
environment:
GRADLE_OPTS: -Xmx2048m
TARGET_CFLAGS: -DNDEBUG
###########################################################################
# Swift / iOS / macOS
Check Swift formatting:
macos:
xcode: "15.1"
resource_class: "macos.m1.medium.gen1"
steps:
- checkout
- run:
name: Install lint tools
command: |
export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_INSTALL_CLEANUP=1
brew install swiftlint
- run:
name: Run swiftlint
command: |
swiftlint version
swiftlint --strict
iOS build and test:
macos:
xcode: "15.1"
resource_class: "macos.m1.medium.gen1"
steps:
- checkout
- run:
name: Show Ruby environment
command: |
ruby --version
gem env
- install-rustup
- setup-rust-toolchain
- restore_cache:
name: Restore rubygems cache
key: swift-docs-gems-v20
- run:
name: Install jazzy
command: gem install --no-document jazzy
- save_cache:
name: Save rubygems cache
# NEEDS TO CHANGE WHEN JAZZY OR RUBY IS UPDATED
key: swift-docs-gems-v20
paths:
- ~/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0
- run:
name: Setup build environment
command: |
set -x
rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios
# For some reason everything works fine if we use the host clang,
# not the Xcode-bundled clang.
echo '[target.aarch64-apple-darwin]' >> ~/.cargo/config
echo 'linker = "/usr/bin/cc"' >> ~/.cargo/config
# List available devices -- allows us to see what's there
DEVICES=$(xcrun xctrace list devices 2>&1)
echo "$DEVICES"
# Pick a device and start it
UUID=$(echo "$DEVICES" | grep --max-count=1 'iPhone 15 Simulator (17' | awk -F'[()]' '{print $4}')
xcrun simctl boot "$UUID"
# Store build type for use in cache key
if [ -z "${CIRCLE_TAG}" ]; then
echo "debug" > buildtype.txt
else
echo "release" > buildtype.txt
fi
- restore_cache:
keys:
- v2-cargo-cache-{{arch}}-{{checksum "buildtype.txt"}}-{{checksum "Cargo.lock"}}
- run:
name: Run iOS build
command: bash bin/run-ios-build.sh
- save_cache:
paths:
- /Users/distiller/.cargo/registry
- target
key: v2-cargo-cache-{{arch}}-{{checksum "buildtype.txt"}}-{{checksum "Cargo.lock"}}
- run:
name: Run iOS tests
command: |
if git log -1 "$CIRCLE_SHA1" | grep -q '\[doc only\]'; then
echo "Skipping this step. Last commit was tagged to not require tests."
else
bash bin/run-ios-tests.sh
fi
- run:
name: Generate Swift documentation
command: |
# Skip doc generation for pull requests.
if [ "$CIRCLE_BRANCH" = "main" ]; then
bash bin/build-swift-docs.sh
else
mkdir -p build/docs/swift
fi
- store_artifacts:
path: raw_xcodebuild.log
destination: raw_xcodebuild.log
- store_artifacts:
path: raw_xcodetest.log
destination: raw_xcodetest.log
- persist_to_workspace:
root: build/
paths: docs/swift
- run:
name: Build XCFramework archive
no_output_timeout: 20m
command: |
if [ -z "${CIRCLE_TAG}" ]; then
# No need to build the framework archive unless we build for a tagged release.
circleci-agent step halt
else
bash bin/build-xcframework.sh
fi
- persist_to_workspace:
root: .
paths:
- Glean.xcframework.zip
iOS integration test:
macos:
xcode: "15.1"
resource_class: "macos.m1.medium.gen1"
steps:
- checkout
- skip-if-doc-only
- install-rustup
- setup-rust-toolchain
- run:
name: Setup build environment
command: |
set -x
rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios
# For some reason everything works fine if we use the host clang,
# not the Xcode-bundled clang.
echo '[target.aarch64-apple-darwin]' >> ~/.cargo/config
echo 'linker = "/usr/bin/cc"' >> ~/.cargo/config
# List available devices -- allows us to see what's there
DEVICES=$(xcrun xctrace list devices 2>&1)
echo "$DEVICES"
# Pick a device and start it
UUID=$(echo "$DEVICES" | grep --max-count=1 'iPhone 15 Simulator (17' | awk -F'[()]' '{print $4}')
xcrun simctl boot "$UUID"
- run:
name: Build XCFramework archive
command: |
bash bin/build-xcframework.sh
- run:
name: Build sample app
command: |
bash bin/run-ios-sample-app-build.sh
- store_artifacts:
path: raw_sample_xcodebuild.log
destination: raw_sample_xcodebuild.log
- run:
name: Run sample app tests
command: |
bash bin/run-ios-sample-app-test.sh
- store_artifacts:
path: raw_sample_xcodetest.log
destination: raw_sample_xcodetest.log
iOS Framework release:
macos:
xcode: "15.1"
resource_class: "macos.m1.medium.gen1"
steps:
- checkout
- attach_workspace:
at: .
- install-ghr-darwin
- run:
name: Release framework archive on GitHub
command: |
./ghr -replace "${CIRCLE_TAG}" Glean.xcframework.zip
glean-swift release:
docker:
- image: cimg/rust:1.67
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Release glean-swift
command: |
git config --global user.email "[email protected]"
git config --global user.name "Glean automated release"
./bin/publish-glean-swift.sh "${CIRCLE_TAG}"
###########################################################################
# Python
Lint Python:
docker:
- image: cimg/python:3.10
steps:
- checkout
- install-rustup
- run:
name: Run uniffi-bindgen
command: make bindgen-python
- run:
name: Python lints
command: make lint-python
Python 3_8 tests:
docker:
- image: cimg/python:3.8
steps:
- checkout
- test-python
Python 3_9 tests:
docker:
- image: cimg/python:3.9
steps:
- checkout
- test-python
Python 3_9 on Alpine tests:
docker:
- image: python:3.9-alpine
shell: /bin/sh -leo pipefail
environment:
- BASH_ENV: /etc/profile
steps:
- run:
name: Install dependencies
command: |
apk add curl git gcc musl-dev libffi-dev openssh-client make openssl-dev
- checkout
- test-python
Python 3_10 tests:
docker:
- image: cimg/python:3.10
steps:
- checkout
- test-python
- persist_to_workspace:
root: .
paths: .venv3.10
Python 3_11 tests:
docker:
- image: cimg/python:3.11
steps:
- checkout
- test-python
Python 3_12 tests:
docker:
- image: cimg/python:3.12
steps:
- checkout
- test-python
Python Windows x86_64 tests:
docker:
- image: cimg/python:3.8
steps:
- checkout
- skip-if-doc-only
- build-windows-x86_64-wheel
- run:
name: Install Wine
command: |
sudo apt install wine64
- run:
name: Install Python for Windows
command: |
wget https://www.python.org/ftp/python/3.8.2/python-3.8.2-embed-amd64.zip
mkdir winpython
unzip python-3.8.2-embed-amd64.zip -d winpython
echo "export WINPYTHON=\"wine64-stable winpython/python.exe\"" >> $BASH_ENV
- install-python-windows-deps
- run:
name: Build bcryptprimitives.dll shim
command: |
rustc tools/patches/bcryptprimitives.rs -Copt-level=3 -Clto=fat --out-dir wine_shims --target x86_64-pc-windows-gnu
# This preloads our bcryptprimitives shim.
shimpath='Z:\\\\home\\\\circleci\\\\project\\\\wine_shims\\\\bcryptprimitives.dll'
echo "import ctypes; ctypes.cdll.LoadLibrary('$shimpath')" >> winpython/sitecustomize.py
- run:
name: Run tests
command: |
$WINPYTHON -m pytest -s glean-core/python/tests
Python Windows i686 tests:
docker:
- image: cimg/python:3.8
steps:
- checkout
- skip-if-doc-only
- build-windows-i686-wheel
- run:
name: Install Wine
command: |
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install wine32
- run:
name: Install Python for Windows
command: |
wget https://www.python.org/ftp/python/3.8.2/python-3.8.2-embed-win32.zip
mkdir winpython
unzip python-3.8.2-embed-win32.zip -d winpython
echo "export WINPYTHON=\"wine winpython/python.exe\"" >> $BASH_ENV
- install-python-windows-deps
- run:
name: Build bcryptprimitives.dll shim
command: |
rustc tools/patches/bcryptprimitives.rs -Copt-level=3 -Clto=fat --out-dir wine_shims --target i686-pc-windows-gnu
# This preloads our bcryptprimitives shim.
shimpath='Z:\\\\home\\\\circleci\\\\project\\\\wine_shims\\\\bcryptprimitives.dll'
echo "import ctypes; ctypes.cdll.LoadLibrary('$shimpath')" >> winpython/sitecustomize.py
- run:
name: Run tests
command: |
$WINPYTHON -m pytest -s glean-core/python/tests
Generate Python documentation:
docker:
- image: cimg/python:3.10
steps:
- install-rustup
- setup-rust-toolchain
- checkout
- attach_workspace:
at: .
- run:
name: Generate Python docs
command: |
make docs-python
- persist_to_workspace:
root: build/
paths: docs/python
pypi-source-release:
docker:
- image: cimg/python:3.8
steps:
- install-rustup
- setup-rust-toolchain
- checkout
- run:
name: Setup default Python version
command: |
echo 'export PATH=/opt/python/cp38-cp38/bin:$PATH' >> $BASH_ENV
- run:
name: Setup Python env
command: |
make setup-python
- run:
name: Build Python source distribution
command: |
make build-python-sdist
- run:
name: Upload Linux source distribution
command: |
# Requires that the TWINE_USERNAME and TWINE_PASSWORD environment
# variables are configured in CircleCI's environment variables.
.venv3.8/bin/python3 -m twine upload target/wheels/*
pypi-linux-release:
docker:
# The official docker image for building manylinux2010 wheels
- image: quay.io/pypa/manylinux2014_x86_64
steps:
# manylinux2014 doesn't have ssh installed.
- run:
name: Install missing tools
command: yum install -y openssh-clients
- install-rustup
- setup-rust-toolchain
- checkout
- run:
name: Setup default Python version
command: |
echo 'export PATH=/opt/python/cp38-cp38/bin:$PATH' >> $BASH_ENV
- run:
name: Setup Python env
command: |
make setup-python
- run:
name: Build Python package
command: |
make build-python-wheel
- run:
name: Upload Linux wheel
command: |
# Requires that the TWINE_USERNAME and TWINE_PASSWORD environment
# variables are configured in CircleCI's environment variables.
.venv3.8/bin/python3 -m twine upload target/wheels/*
- install-ghr-linux
- run:
name: Publish to Github
command: |
# Upload to GitHub
./ghr -replace ${CIRCLE_TAG} target/wheels
pypi-macos-release:
macos:
xcode: "15.1"
resource_class: "macos.m1.medium.gen1"
steps:
- install-rustup
- setup-rust-toolchain
- checkout
- run:
name: Install Python development tools for host
command: |
rustup target add x86_64-apple-darwin
make setup-python
- run:
name: Build macOS x86_64 wheel
command: |
make build-python-wheel GLEAN_BUILD_TARGET=x86_64-apple-darwin
- run:
name: Build macOS aarch64 wheel
command: |
make build-python-wheel GLEAN_BUILD_TARGET=aarch64-apple-darwin
- run:
name: Build macOS universal2 wheel
command: |
make build-python-wheel GLEAN_BUILD_TARGET="universal2-apple-darwin"
- run:
name: Upload wheels to PyPI
command: |
# Requires that the TWINE_USERNAME and TWINE_PASSWORD environment
# variables are configured in CircleCI's environment variables.
.venv3.11/bin/python3 -m twine upload target/wheels/*
- install-ghr-darwin
- run:
name: Publish to Github
command: |
# Upload to GitHub
./ghr -replace ${CIRCLE_TAG} target/wheels
pypi-windows-x86_64-release:
docker:
- image: cimg/python:3.8
steps:
- checkout
- build-windows-x86_64-wheel
- run:
name: Upload to PyPI
command: |
# Requires that the TWINE_USERNAME and TWINE_PASSWORD environment
# variables are configured in CircleCI's environment variables.
.venv3.8/bin/python3 -m twine upload target/wheels/*
- install-ghr-linux
- run:
name: Publish to Github
command: |
# Upload to GitHub
./ghr -replace ${CIRCLE_TAG} target/wheels
pypi-windows-i686-release:
docker:
- image: cimg/python:3.8
steps:
- checkout
- build-windows-i686-wheel
- run:
name: Upload to PyPI
command: |
# Requires that the TWINE_USERNAME and TWINE_PASSWORD environment
# variables are configured in CircleCI's environment variables.
.venv3.8/bin/python3 -m twine upload target/wheels/*
- install-ghr-linux
- run:
name: Publish to Github
command: |
# Upload to GitHub
./ghr -replace ${CIRCLE_TAG} target/wheels
###########################################################################
# Docs
Docs internal metrics check:
docker:
- image: cimg/python:3.10
steps:
- checkout
- run:
name: Internal metrics docs consistency check
command: |
make docs-metrics
if ! git diff --exit-code HEAD -- docs/user/collected-metrics/metrics.md; then
echo "=================================================="
echo "metrics.md is different from what's stored in git."
echo "Please regenerate the file using:"
echo " make docs-metrics"
echo "Commit the modified file and push."
echo "=================================================="
exit 1
fi
docs-linkcheck:
docker:
- image: cimg/node:17.9
steps:
- checkout
- run:
name: Install linkchecker
command: npm install -g link-checker
- attach_workspace:
at: build/
- run:
name: Check internal documentation links
command: |
make linkcheck-raw
docs-spellcheck:
docker:
- image: cimg/base:2022.03
steps:
- checkout
- run:
name: Upgrade packages
command: sudo apt update
- run: