This repository has been archived by the owner on Aug 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
740 lines (710 loc) · 26 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
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
name: SDK Build and Test
on:
push:
branches: [ main ]
tags:
- python-v*
- c-v*
pull_request:
workflow_dispatch:
env:
CARGO_INCREMENTAL: 0
CARGO_PROFILE_DEV_DEBUG: 0
RUSTFLAGS: "-D warnings"
jobs:
# lint-commits:
# name: Conventional commits
# runs-on: ubuntu-22.04
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - run: npm install -g @commitlint/cli @commitlint/config-conventional
# - run: commitlint --config .commitlintrc.json --from ${{ github.head_ref || github.ref }}
fetch:
name: Fetch Dependencies
# From what I tried Windows cannot get cache from ubuntu even though the key is the same. MacOS can though.
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- windows-2022
steps:
- uses: actions/checkout@v4
# We want to use sparse registry but for that we need nightly
- name: Generate Cargo.lock
run: cargo generate-lockfile
# Generating the lockfile can clone git repositories and tar can then fail for the cache
- name: Cleanup Cargo Home
run: rm -rf ~/.cargo/registry ~/.cargo/git
shell: bash
- name: Cache Registry
id: cache
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Fetch
run: cargo fetch --locked
if: steps.cache.outputs.cache-hit != 'true'
# We need the other jobs in this workflow to download this version of cargo.lock
# We cannot force cache update even if we wanted to so we use artifacts instead
- name: Upload Cargo.lock
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }}
path: Cargo.lock
format-rust:
name: Format
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: cargo fmt --all -- --check
lint-rust:
name: Clippy
needs:
- fetch
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Download cargo.lock
uses: actions/download-artifact@v4
with:
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }}
- name: Cache Registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache Compiled Dependencies
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}-stable-dev
- name: Clippy
run: cargo clippy --frozen --all-targets -- -D warnings
build:
name: Build
needs:
- fetch
runs-on: ${{ startsWith(matrix.os_runtime, 'unknown-linux-gnu') && 'ubuntu-22.04' || matrix.os_runtime == 'pc-windows-msvc' && 'windows-2022' || 'macos-13' }}
strategy:
fail-fast: false
# Run all 4 builds on ubuntu (nightly - stable x dev - release)
# Run only stable builds on Windows and MacOS to save up on compilation times
# Does not stop the pipeline if only nightly builds fail
matrix:
cpu:
- x86_64
os_runtime:
- unknown-linux-gnu
toolchain:
- stable
- nightly
configuration:
- release
- dev
artifact_name:
- linux-x64
include:
- cpu: i686
os_runtime: unknown-linux-gnu
toolchain: stable
configuration: release
artifact_name: linux-x86
- cpu: aarch64
os_runtime: unknown-linux-gnu
toolchain: stable
configuration: release
artifact_name: linux-aarch64
- cpu: armv7
os_runtime: unknown-linux-gnueabihf
toolchain: stable
configuration: release
artifact_name: linux-armv7
- cpu: x86_64
os_runtime: pc-windows-msvc
toolchain: stable
configuration: release
artifact_name: win-x64
- cpu: x86_64
os_runtime: apple-darwin
toolchain: stable
configuration: release
artifact_name: osx-x64
steps:
- uses: actions/checkout@v4
- name: Download cargo.lock
uses: actions/download-artifact@v4
with:
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }}
- name: Cache Registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache Compiled Dependencies
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.toolchain }}-${{ matrix.configuration }}
if: ${{ matrix.cpu == 'x86_64' }}
- name: Install libraries for cross compilation to 32bit
run: |
sudo apt-get update
sudo apt-get install -y g++-i686-linux-gnu libc6-dev-i386-cross
if: ${{ matrix.cpu == 'i686' }}
- name: Set up environment variables for cross compilation to 32bit
run: |
cat << EOF >> $GITHUB_ENV
CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=i686-linux-gnu-gcc
CC_i686_unknown_linux_gnu=i686-linux-gnu-gcc
CXX_i686_unknown_linux_gnu=i686-linux-gnu-g++
EOF
if: ${{ matrix.cpu == 'i686' }}
- name: Install libraries for cross compilation to AArch64
run: |
sudo apt-get update
sudo apt-get install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross
if: ${{ matrix.cpu == 'aarch64' }}
- name: Set up environment variables for cross compilation to AArch64
run: |
cat << EOF >> $GITHUB_ENV
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
EOF
if: ${{ matrix.cpu == 'aarch64' }}
- name: Install libraries for cross compilation to ARMv7
run: |
sudo apt-get update
sudo apt-get install -y g++-arm-linux-gnueabihf libc6-dev-armhf-cross
if: ${{ matrix.cpu == 'armv7' }}
- name: Set up environment variables for cross compilation to ARMv7
run: |
cat << EOF >> $GITHUB_ENV
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
CC_armv7_unknown_Linux_gnueabihf=arm-linux-gnueabihf-gcc
CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
EOF
if: ${{ matrix.cpu == 'armv7' }}
- name: Install Target
run: rustup target add ${{ matrix.cpu }}-${{ matrix.os_runtime }}
if: ${{ matrix.cpu != 'x86_64' }}
# We can use only the CPU that matches the runner
- name: Select Toolchain
run: rustup default ${{ matrix.toolchain }}-${{ matrix.cpu }}-${{ matrix.os_runtime }}
if: ${{ matrix.cpu == 'x86_64' }}
- name: Build
# Skip spotflow-py if we're building on macOS or other CPU than x64. It does not work because of linkage issues, maturin builds correctly
run: cargo build --all-targets --target ${{ matrix.cpu }}-${{ matrix.os_runtime }} ${{ matrix.cpu == 'x86_64' && '--offline' || '' }} --verbose --profile ${{ matrix.configuration }} --workspace ${{ (runner.os == 'macOS' || matrix.cpu != 'x86_64') && '--exclude spotflow-py' || '' }}
env:
CARGO_PROFILE_DEV_DEBUG: 0
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
- name: Pack C interface
shell: pwsh
run: spotflow-c/pack.ps1 -Os ${{ runner.os }} -TargetDir ../target/${{ matrix.cpu }}-${{ matrix.os_runtime }}/release
if: ${{ matrix.toolchain == 'stable' && matrix.configuration == 'release' }}
- name: Upload C interface
uses: actions/upload-artifact@v4
with:
name: c-${{ matrix.artifact_name }}
path: target/${{ matrix.cpu }}-${{ matrix.os_runtime }}/release/c
if: ${{ matrix.toolchain == 'stable' && matrix.configuration == 'release' }}
# Prevents from caching and causing weird errors when modifying the pipeline, such as "target/release/c already exists"
- name: Clean up C interface
shell: pwsh
run: Remove-Item -Recurse -Force target/${{ matrix.cpu }}-${{ matrix.os_runtime }}/release/c
if: ${{ matrix.toolchain == 'stable' && matrix.configuration == 'release' }}
test:
name: Test
needs:
- build
permissions:
contents: read
id-token: write
environment: platform-test
runs-on: ubuntu-22.04
strategy:
matrix:
toolchain:
- stable
configuration:
- release
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Download cargo.lock
uses: actions/download-artifact@v4
with:
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }}
- name: Cache Registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache Compiled Dependencies
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.toolchain }}-${{ matrix.configuration }}
- name: ⛓ Select Toolchain
run: rustup default ${{ matrix.toolchain }}
- name: Test no run
run: cargo test --offline --verbose --profile ${{ matrix.configuration }} --no-run
- name: Azure Login
uses: azure/login@v2
with:
client-id: ${{ secrets.DATAMOLE_AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.DATAMOLE_AZURE_TENANT_ID }}
allow-no-subscriptions: true
- name: Test
run: cargo test --offline --verbose --profile ${{ matrix.configuration }}
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
if: ${{ matrix.toolchain == 'stable' && matrix.configuration == 'release' }}
env:
SPOTFLOW_DEVICE_SDK_TEST_INSTANCE: ${{ secrets.TEST_INSTANCE }}
SPOTFLOW_DEVICE_SDK_TEST_PROVISIONING_TOKEN: ${{ secrets.TEST_PROVISIONING_TOKEN }}
SPOTFLOW_DEVICE_SDK_TEST_WORKSPACE_ID: ${{ secrets.TEST_WORKSPACE_ID }}
- name: Allow failures for nightly
run: true
# Skip until we have actual documentation to be checked
# check-docs:
# name: Documentation
# runs-on: ubuntu-22.04
# env:
# RUSTDOCFLAGS: -D warnings
# steps:
# - uses: actions/checkout@v4
# - run: cargo doc --no-deps --document-private-items
test-c:
name: Test C Library
needs:
- build
strategy:
fail-fast: false
matrix:
cpu:
- x86_64
os:
- ubuntu-22.04
- windows-2022
# - macos-13 # Skip until it is fixed
include:
- cpu: i686
os: ubuntu-22.04
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Download C interface
uses: actions/download-artifact@v4
with:
name: c-${{ matrix.os == 'ubuntu-22.04' && 'linux' || matrix.os == 'windows-2022' && 'win' || 'osx' }}-x64
path: target/release/c
- name: Compile GCC dynamic library project with Make
run: make
working-directory: target/release/c/examples/gcc_makefile_dynamic
if: ${{ runner.os == 'Linux'}}
- name: Compile GCC static library project with Make
run: make
working-directory: target/release/c/examples/gcc_makefile_static
if: ${{ runner.os == 'Linux'}}
- name: Compile Visual Studio dynamic library project with MSBuild
shell: cmd
run: ${{ '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" && msbuild' }}
working-directory: target/release/c/examples/vs2022_dynamic
if: ${{ runner.os == 'Windows' }}
- name: Compile Visual Studio static library project with MSBuild
shell: cmd
run: ${{ '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" && msbuild' }}
working-directory: target/release/c/examples/vs2022_static
if: ${{ runner.os == 'Windows' }}
- name: Compile Clang dynamic library project with Make
run: make run
working-directory: target/release/c/examples/clang_makefile_dynamic
if: ${{ runner.os == 'macOS' }}
- name: Compile Clang static library project with Make
run: make run
working-directory: target/release/c/examples/clang_makefile_static
if: ${{ runner.os == 'macOS' }}
build-c:
name: Build and test C Library using CMake
if: ${{ false }} # Skip until the CMake build is fixed
needs:
- build
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- windows-2022
- macos-13
runs-on: ${{ matrix.os }}
timeout-minutes: 10
environment: platform-test
steps:
- uses: actions/checkout@v4
- name: Download cargo.lock
uses: actions/download-artifact@v4
with:
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }}
- name: Cache Registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
# Cache cannot be reused from the build steps since CMake will just build it in its own directory.
# Rather it probably can be but it will require some effort around moving the target directory around.
# This will most likely not work in its simplest form because of dep-info files
- name: Prepare C Example
run: cmake -S . -B build
working-directory: examples/c
# if: ${{ matrix.os == 'ubuntu-22.04' && matrix.toolchain == 'stable' && matrix.configuration == 'release' }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
architecture: x64
- run: pip install azure.identity
- name: Azure Login
uses: azure/login@v2
with:
client-id: ${{ secrets.DATAMOLE_AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.DATAMOLE_AZURE_TENANT_ID }}
allow-no-subscriptions: true
- name: Run C Example
run: cmake --build build
working-directory: examples/c
env:
SPOTFLOW_TEST_DEVICE_ID: test-device-c-${{ matrix.os }}
build-python-linux:
runs-on: ubuntu-22.04
needs:
- build
defaults:
run:
working-directory: spotflow-py
steps:
- uses: actions/checkout@v4
- name: Download cargo.lock
uses: actions/download-artifact@v4
with:
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }}
- name: Cache Registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache Compiled Dependencies
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-stable-release
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
architecture: x64
# Install maturin with patchelf because the utility in ubuntu repo is outdated and has a bug
- name: Set up Maturin
run: pip install maturin[patchelf]
- run: maturin build --offline --release --sdist -o dist
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-x64
path: spotflow-py/dist
build-python-windows:
runs-on: windows-latest
needs:
- build
defaults:
run:
working-directory: spotflow-py
steps:
- uses: actions/checkout@v4
- name: Download cargo.lock
uses: actions/download-artifact@v4
with:
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }}
- name: Cache Registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache Compiled Dependencies
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-stable-release
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
architecture: x64
- name: Set up Maturin
run: pip install maturin
- run: maturin build --offline --release -o dist
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-win-x64
path: spotflow-py/dist
build-python-macos:
runs-on: macos-13
needs:
- build
defaults:
run:
working-directory: spotflow-py
steps:
- uses: actions/checkout@v4
- name: Download cargo.lock
uses: actions/download-artifact@v4
with:
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }}
- name: Cache Registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache Compiled Dependencies
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-stable-release
- run: rustup target list --installed
- run: rustup target add aarch64-apple-darwin
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
architecture: x64
- name: Set up Maturin
run: pip install maturin
- run: maturin build --offline --release -o dist --target universal2-apple-darwin
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-x64
path: spotflow-py/dist
build-python-aarch64:
runs-on: ubuntu-22.04
needs:
- build
defaults:
run:
working-directory: spotflow-py
steps:
- uses: actions/checkout@v4
- name: Download cargo.lock
uses: actions/download-artifact@v4
with:
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }}
- name: Cache Registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
# There are no other steps that would use aarch64 compiled binaries so we will not cache them
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
# Install maturin with patchelf because the utility in ubuntu repo is outdated and has a bug
- name: Set up Maturin
run: pip install maturin[patchelf]
- run: |
sudo apt-get update
sudo apt-get install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross
- run: rustup target add aarch64-unknown-linux-gnu
- run: |
cat << EOF >> $GITHUB_ENV
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
EOF
- run: maturin build -o dist --target aarch64-unknown-linux-gnu
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-aarch64
path: spotflow-py/dist
build-python-armv7:
runs-on: ubuntu-22.04
needs:
- build
defaults:
run:
working-directory: spotflow-py
steps:
- uses: actions/checkout@v4
- name: Download cargo.lock
uses: actions/download-artifact@v4
with:
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }}
- name: Cache Registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
# There are no other steps that would use armv7 compiled binaries so we will not cache them
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
# Install maturin with patchelf because the utility in ubuntu repo is outdated and has a bug
- name: Set up Maturin
run: pip install maturin[patchelf]
- run: |
sudo apt-get update
sudo apt-get install -y g++-arm-linux-gnueabihf libc6-dev-armhf-cross
- run: rustup target add armv7-unknown-linux-gnueabihf
- run: |
cat << EOF >> $GITHUB_ENV
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
CC_armv7_unknown_Linux_gnueabihf=arm-linux-gnueabihf-gcc
CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++
EOF
- run: maturin build -o dist --target armv7-unknown-linux-gnueabihf
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-armv7
path: spotflow-py/dist
release-python-packages:
name: Release Python Packages
runs-on: ubuntu-22.04
environment: pypi
if: startsWith(github.event.ref, 'refs/tags/python-v')
needs:
- build
- test
- build-python-macos
- build-python-windows
- build-python-armv7
- build-python-aarch64
- test-python-linux
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
architecture: x64
- name: Set up Maturin
run: pip install maturin
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
- run: maturin upload --username "__token__" --password ${{ secrets.PYPI_TOKEN }} *.whl
release-c-packages:
name: Release C Packages
runs-on: ubuntu-22.04
environment: cdn
if: startsWith(github.event.ref, 'refs/tags/c-v')
needs:
- build
- test
- test-c
permissions:
actions: read
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: c/artifacts
pattern: c-*
- uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.CDN_SUBSCRIPTION_ID }}
- name: Publish C interface
shell: pwsh
run: >
spotflow-c/publish.ps1
-ArtifactsDir c/artifacts
-StagingDir c/staging
-GitHubRef '${{ github.event.ref }}'
-AccountName '${{ secrets.CDN_STORAGE_ACCOUNT_NAME }}'
-ContainerName '${{ secrets.CDN_STORAGE_CONTAINER_NAME }}'
- name: Wait before purging CDN
run: sleep 60
- name: Purge CDN
run: >
az cdn endpoint purge
-g '${{ secrets.CDN_RESOURCE_GROUP_NAME }}'
--profile-name '${{ secrets.CDN_PROFILE_NAME }}'
-n '${{ secrets.CDN_ENDPOINT_NAME }}'
--content-paths '/*'
test-python-linux:
if: ${{ false }} # Skip until Python tests are fixed
runs-on: ubuntu-22.04
needs: build-python-linux
environment: platform-test
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: wheels-linux-x64
path: wheels
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
architecture: x64
- name: Azure Login
uses: azure/login@v2
with:
client-id: ${{ secrets.DATAMOLE_AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.DATAMOLE_AZURE_TENANT_ID }}
allow-no-subscriptions: true
- name: Set up Maturin
run: pip install wheels/spotflow_device-*-manylinux_2_*.whl
- run: pip install azure.identity
- run: python examples/python/messages.py
env:
SPOTFLOW_DEVICE_SDK_TEST_INSTANCE: ${{ secrets.TEST_INSTANCE }}
SPOTFLOW_DEVICE_SDK_TEST_PROVISIONING_TOKEN: ${{ secrets.TEST_PROVISIONING_TOKEN }}
SPOTFLOW_DEVICE_SDK_TEST_WORKSPACE_ID: ${{ secrets.TEST_WORKSPACE_ID }}