-
Notifications
You must be signed in to change notification settings - Fork 183
1001 lines (975 loc) · 35.8 KB
/
release.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
name: Create Release
on:
push:
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
branches:
- main
jobs:
version:
name: Compute and verify the version number
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/check_version
- name: Set version env
run: echo "oso_version=$(cat VERSION)" >> $GITHUB_ENV
- name: Check github ref matches
if: startsWith(github.ref, 'refs/tags/')
env:
github_ref: ${{ github.ref }}
run: grep "${github_ref/refs\/tags\/v/}" VERSION
# Dispatch an oso_release event to other repos to test against this commit
dispatch:
strategy:
matrix:
repo: ["osohq/oso-flask-integration"]
runs-on: ubuntu-latest
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_API_TOKEN }}
repository: ${{ matrix.repo }}
event-type: oso_release
client-payload: '{"commit": "${{ github.sha }}"}'
linux_libs:
name: Build release libraries on Linux
runs-on: ubuntu-latest
needs: [version]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.69.0
override: true
- name: Install cross
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release download --repo cross-rs/cross --pattern 'cross-x86_64-unknown-linux-gnu\.tar\.gz'
tar -xzvf cross-x86_64-unknown-linux-gnu.tar.gz
- name: Build aarch64 dynamic lib
run: |
rustup target add aarch64-unknown-linux-gnu
RUSTFLAGS="-C target-feature=-crt-static" ./cross build --target aarch64-unknown-linux-gnu --release -p polar-c-api
- name: Build aarch64 release musl library
run: |
rustup target add aarch64-unknown-linux-musl
RUSTFLAGS="-C target-feature=-crt-static" ./cross build --target aarch64-unknown-linux-musl --release -p polar-c-api
- name: Build x86_64 release libraries
run: cargo build --release -p polar-c-api
- name: Build x86_64 release musl library
run: |
rustup target add x86_64-unknown-linux-musl
RUSTFLAGS="-C target-feature=-crt-static" cargo build --target x86_64-unknown-linux-musl --release -p polar-c-api
- name: Rename static lib
run: mv target/release/libpolar.a target/libpolar-${{runner.os}}.a
- name: Rename x86_64 static lib
run: mv target/x86_64-unknown-linux-musl/release/libpolar.a target/libpolar-musl-x86_64.a
- name: Rename aarch64 static lib
run: mv target/aarch64-unknown-linux-musl/release/libpolar.a target/libpolar-musl-aarch64.a
- name: Rename x86_64 dynamic lib
run: mv target/release/libpolar.so target/libpolar-x86_64.so
- name: Rename aarch64 dynamic lib
run: mv target/aarch64-unknown-linux-gnu/release/libpolar.so target/libpolar-aarch64.so
- uses: actions/upload-artifact@v2
with:
name: oso_library
path: |
target/libpolar-x86_64.so
target/libpolar-aarch64.so
- uses: actions/upload-artifact@v2
with:
name: oso_library
path: polar-c-api/polar.h
- uses: actions/upload-artifact@v2
with:
name: oso_static_library
path: |
target/libpolar-${{runner.os}}.a
target/libpolar-musl-x86_64.a
target/libpolar-musl-aarch64.a
- uses: actions/upload-artifact@v2
with:
name: oso_static_library
path: polar-c-api/polar.h
macos_libs:
name: Build release libraries on MacOS
runs-on: macos-11
needs: [version]
steps:
- uses: actions/checkout@v2
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.69.0
override: true
- name: Build release library
run: cargo build --release -p polar-c-api
- name: Build release arm library
run: |
rustup target add aarch64-apple-darwin
SDKROOT=$(xcrun -sdk macosx11.0 --show-sdk-path) \
MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.0 --show-sdk-platform-version) \
cargo build --target aarch64-apple-darwin --release -p polar-c-api
- name: Rename static lib
run: mv target/release/libpolar.a target/libpolar-macOS.a
- name: Rename static ARM lib
run: mv target/aarch64-apple-darwin/release/libpolar.a target/libpolar-macOS-arm.a
- name: Rename dynamic lib
run: mv target/release/libpolar.dylib target/libpolar-macOS.dylib
- name: Rename dynamic ARM lib
run: mv target/aarch64-apple-darwin/release/libpolar.dylib target/libpolar-macOS-arm.dylib
- name: Merge dynamic libs into fat dynamic lib
run: lipo -create target/libpolar-macOS.dylib target/libpolar-macOS-arm.dylib -output target/libpolar-macOS-fat.dylib
- name: Merge static libs into fat static lib
run: lipo -create target/libpolar-macOS.a target/libpolar-macOS-arm.a -output target/libpolar-macOS-fat.a
- uses: actions/upload-artifact@v2
with:
name: oso_library
path: |
target/libpolar-macOS-fat.dylib
target/libpolar-macOS.dylib
target/libpolar-macOS-arm.dylib
- uses: actions/upload-artifact@v2
with:
name: oso_static_library
if-no-files-found: error
path: |
target/libpolar-macOS-fat.a
target/libpolar-macOS.a
target/libpolar-macOS-arm.a
- uses: actions/upload-artifact@v2
with:
name: oso_static_library
path: polar-c-api/polar.h
if-no-files-found: error
windows_libs:
name: Build release libraries on Windows
runs-on: windows-2019
needs: [version]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.69.0
override: true
- name: Build release library
run: cargo build --release -p polar-c-api
- name: Build release MinGW library
run: |
rustup target add x86_64-pc-windows-gnu
cargo build --target x86_64-pc-windows-gnu --release -p polar-c-api
- name: Rename static lib
run: |
mv -Force target/x86_64-pc-windows-gnu/release/libpolar.a target/x86_64-pc-windows-gnu/release/libpolar-${{runner.os}}.a
- uses: actions/upload-artifact@v2
with:
name: oso_library
path: target/release/polar.dll
- uses: actions/upload-artifact@v2
with:
name: oso_static_library
path: target/release/polar.lib
- uses: actions/upload-artifact@v2
with:
name: oso_static_library
path: target/x86_64-pc-windows-gnu/release/libpolar-${{runner.os}}.a
- uses: actions/upload-artifact@v2
with:
name: oso_static_library
path: polar-c-api/polar.h
build_go:
name: Build go.
runs-on: ubuntu-latest
needs: [linux_libs, macos_libs, windows_libs]
steps:
- uses: actions/checkout@v2
- name: Set version env
id: version
run: echo "::set-output name=oso_version::$(cat VERSION)"
- name: Download static libs
uses: actions/download-artifact@v1
with:
name: oso_static_library
- name: Copy specs into go test package.
run: cp -r test/spec languages/go/tests/spec
- name: Copy policies into go test package.
run: cp -r test/policies languages/go/tests/policies
- name: Copy libraries into go package.
run: |
mkdir -p languages/go/native
cp -r oso_static_library/polar.h languages/go/internal/ffi/native/polar.h
mkdir -p languages/go/native/linux/amd64
cp -r oso_static_library/libpolar-musl-x86_64.a languages/go/internal/ffi/native/linux/amd64/libpolar.a
mkdir -p languages/go/native/linux/arm64
cp -r oso_static_library/libpolar-musl-aarch64.a languages/go/internal/ffi/native/linux/arm64/libpolar.a
mkdir -p languages/go/native/macos/amd64
cp -r oso_static_library/libpolar-macOS.a languages/go/internal/ffi/native/macos/amd64/libpolar.a
mkdir -p languages/go/native/macos/arm64
cp -r oso_static_library/libpolar-macOS-arm.a languages/go/internal/ffi/native/macos/arm64/libpolar.a
mkdir -p languages/go/native/windows
cp -r oso_static_library/libpolar-Windows.a languages/go/internal/ffi/native/windows/libpolar.a
rm languages/go/Makefile
- name: Copy license.
run: cp LICENSE languages/go/LICENSE
- uses: actions/upload-artifact@v2
with:
name: go
path: languages/go
build_jar:
name: Build jar.
runs-on: ubuntu-latest
needs: [linux_libs, macos_libs, windows_libs]
steps:
- uses: actions/checkout@v2
- name: Set version env
id: version
run: echo "::set-output name=oso_version::$(cat VERSION)"
- uses: actions/setup-java@v1
with:
java-version: "11"
- name: Download dylibs
uses: actions/download-artifact@v1
with:
name: oso_library
- name: Copy libraries into resources.
run: |
mkdir -p languages/java/oso/src/main/resources/linux
cp -r oso_library/libpolar-x86_64.so languages/java/oso/src/main/resources/linux/libpolar.so
mkdir -p languages/java/oso/src/main/resources/macos
cp -r oso_library/libpolar-macOS-fat.dylib languages/java/oso/src/main/resources/macos/libpolar.dylib
mkdir -p languages/java/oso/src/main/resources/win
cp -r oso_library/polar.dll languages/java/oso/src/main/resources/win/
- name: Test
run: |
mvn -q test
working-directory: languages/java/oso
- name: Build
run: |
mvn -q package
working-directory: languages/java/oso
- uses: actions/upload-artifact@v2
with:
name: jar
path: languages/java/oso/target/oso-${{ steps.version.outputs.oso_version }}.jar
build_gem:
name: Build Gem.
runs-on: ubuntu-latest
needs: [linux_libs, macos_libs, windows_libs]
steps:
- uses: actions/checkout@v2
- name: Install Ruby + gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
working-directory: "languages/ruby"
- name: Set version env
id: version
run: echo "oso_version=$(cat VERSION)" >> $GITHUB_ENV
- name: Download dylibs
uses: actions/download-artifact@v1
with:
name: oso_library
- name: Copy libraries into resources.
run: |
mkdir -p languages/ruby/ext/oso-oso/lib
cp -r oso_library/libpolar-x86_64.so languages/ruby/ext/oso-oso/lib/
cp -r oso_library/libpolar-aarch64.so languages/ruby/ext/oso-oso/lib/
cp -r oso_library/libpolar-macOS-fat.dylib languages/ruby/ext/oso-oso/lib/libpolar.dylib
cp -r oso_library/polar.dll languages/ruby/ext/oso-oso/lib/
- name: Test
run: |
bundle install
bundle exec rake spec
working-directory: languages/ruby
- name: Build
run: |
gem build oso-oso.gemspec
working-directory: languages/ruby
- uses: actions/upload-artifact@v2
with:
name: gem
path: languages/ruby/*.gem
build_linux_wheels:
name: Build wheels on Linux
runs-on: ubuntu-latest
needs: [version, linux_libs]
steps:
- uses: actions/checkout@v2
- name: Download static libs
uses: actions/download-artifact@v1
with:
name: oso_static_library
- name: Copy static library.
run: |
mkdir -p languages/python/oso/native
cp -r oso_static_library/libpolar-musl-x86_64.a languages/python/oso/native/libpolar.a
cp -r oso_static_library/polar.h languages/python/oso/native/polar.h
- name: Copy in readme
run: |
rm languages/python/oso/README.md
cp README.md languages/python/oso/README.md
- name: Build wheels
uses: pypa/[email protected]
env:
# Skip Python 2.7 and Python 3.5
CIBW_SKIP: "cp27-* cp35-* pp27-*"
# 64-bit builds only
CIBW_BUILD: "*64"
# Used in build.py to find right files
CIBW_ENVIRONMENT: OSO_ENV=CI
with:
package-dir: languages/python/oso
- uses: actions/upload-artifact@v2
with:
name: wheel
path: ./wheelhouse/*.whl
build_macos_wheels:
name: Build wheels on MacOS
runs-on: macos-12
needs: [version, macos_libs]
steps:
- uses: actions/checkout@v2
- name: Download static libs
uses: actions/download-artifact@v1
with:
name: oso_static_library
- name: Copy static library.
run: |
mkdir -p languages/python/oso/native
cp -r oso_static_library/libpolar-macOS-fat.a languages/python/oso/native/libpolar.a
cp -r oso_static_library/polar.h languages/python/oso/native/polar.h
- name: Copy in readme
run: |
rm languages/python/oso/README.md
cp README.md languages/python/oso/README.md
- name: Build wheels
uses: pypa/[email protected]
env:
# Skip Python 2.7 and Python 3.5
CIBW_SKIP: "cp27-* cp35-* pp27-*"
# 64-bit builds only
CIBW_BUILD: "*64"
# Used in build.py to find right files
CIBW_ENVIRONMENT: OSO_ENV=CI
# Build a macos wheel that works for x86 and ARM
CIBW_ARCHS: x86_64 arm64 universal2
with:
package-dir: languages/python/oso
- uses: actions/upload-artifact@v2
with:
name: wheel
path: ./wheelhouse/*.whl
build_windows_wheels:
name: Build wheels on Windows
runs-on: windows-2019
needs: [version, windows_libs]
steps:
- uses: actions/checkout@v2
- name: Download static libs
uses: actions/download-artifact@v1
with:
name: oso_static_library
- name: Copy static library.
run: |
mkdir -p languages/python/oso/native
cp -r oso_static_library/polar.lib languages/python/oso/native/polar.lib
cp -r oso_static_library/polar.h languages/python/oso/native/polar.h
- name: Copy in readme
run: |
rm languages/python/oso/README.md
cp README.md languages/python/oso/README.md
- name: Build wheels
uses: pypa/[email protected]
env:
# Skip Python 2.7 and Python 3.5
CIBW_SKIP: "cp27-* cp35-* pp27-*"
# 64-bit builds only
CIBW_BUILD: "*64"
# Used in build.py to find right files
CIBW_ENVIRONMENT: OSO_ENV=CI
with:
package-dir: languages/python/oso
- uses: actions/upload-artifact@v2
with:
name: wheel
path: ./wheelhouse/*.whl
build_js:
name: Build js.
runs-on: ubuntu-latest
needs: [version]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: "12"
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.69.0
override: true
- name: Add WebAssembly target
run: rustup target add wasm32-unknown-unknown
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build
working-directory: languages/js
run: |
make CARGO_FLAGS=--release build
rm -rf node_modules
- name: Copy main README into project directory
working-directory: languages/js
run: cp ../../README.md .
- uses: actions/upload-artifact@v2
with:
name: oso_js_node
path: languages/js/*
validate_go:
name: Test go ${{ matrix.go-version }} on ${{ matrix.os }}
needs: [build_go]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-11, windows-2019]
go-version: ["1.14", "1.15", "1.16", "1.17"]
steps:
- uses: actions/checkout@v2
- name: Set version env
id: version
run: echo "::set-output name=oso_version::$(cat VERSION)"
- name: Set up go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Download go package from package run
uses: actions/download-artifact@v1
with:
name: go
- name: "test"
env:
POLAR_IGNORE_NO_ALLOW_WARNING: 1
run: |
go build
go test -v ./internal/host
cd tests && go test -v
working-directory: go
- name: "test musl"
if: runner.os == 'Linux'
run: docker run --rm --env POLAR_IGNORE_NO_ALLOW_WARNING=1 -v `pwd`:/oso tetafro/golang-gcc:${{ matrix.go-version }}-alpine /bin/sh -c 'cd /oso && go test -v ./internal/host && cd tests && go test -v'
working-directory: go
- name: "test buster"
if: runner.os == 'Linux'
run: docker run --rm --env POLAR_IGNORE_NO_ALLOW_WARNING=1 -v `pwd`:/oso golang:${{ matrix.go-version }}-buster /bin/sh -c 'cd /oso && go test -v ./internal/host && cd tests && go test -v'
working-directory: go
validate_go_macos_arm:
name: Test go ${{ matrix.go-version }} on m1
needs: [build_go]
runs-on: [self-hosted, m1]
strategy:
matrix:
# go 1.16 is the earliest version supported on m1
go-version: ["1.16", "1.17"]
steps:
- uses: actions/checkout@v2
- name: Set version env
id: version
run: echo "::set-output name=oso_version::$(cat VERSION)"
- name: Download go package from package run
uses: actions/download-artifact@v1
with:
name: go
- name: "test"
run: |
~/go/bin/go${{ matrix.go-version }} build
~/go/bin/go${{ matrix.go-version }} test -v ./internal/host
cd tests && ~/go/bin/go${{ matrix.go-version }} test -v
working-directory: go
env:
POLAR_IGNORE_NO_ALLOW_WARNING: 1
CGO_ENABLED: 1
GOOS: darwin
GOARCH: arm64
validate_python_linux:
name: Test python ${{ matrix.python-version }} on Linux
needs: [build_linux_wheels]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v2
- name: Set version env
id: version
run: echo "::set-output name=oso_version::$(cat VERSION)"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Download oso python wheels from package run
uses: actions/download-artifact@v1
with:
name: wheel
- name: "test"
run: |
# first install _only_ the wheel and make sure it's available
pip install oso==${{ steps.version.outputs.oso_version }} -f ../wheel --no-deps --no-index
# then install deps too
pip install oso==${{ steps.version.outputs.oso_version }} -f ../wheel
python test.py
working-directory: test
validate_python_macos_11:
name: Test python ${{ matrix.python-version }} on MacOS
needs: [build_macos_wheels]
runs-on: macos-11
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v2
- name: Set version env
id: version
run: echo "::set-output name=oso_version::$(cat VERSION)"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Download oso python wheels from package run
uses: actions/download-artifact@v1
with:
name: wheel
- name: "test"
run: |
# first install _only_ the wheel and make sure it's available
pip install oso==${{ steps.version.outputs.oso_version }} -f ../wheel --no-deps --no-index
# then install deps too
pip install oso==${{ steps.version.outputs.oso_version }} -f ../wheel
python test.py
working-directory: test
validate_python_macos_arm:
name: Test python on MacOS M1
needs: [build_macos_wheels]
runs-on: [self-hosted, m1]
steps:
- uses: actions/checkout@v2
- name: Set version env
id: version
run: echo "::set-output name=oso_version::$(cat VERSION)"
- name: Download oso python wheels from package run
uses: actions/download-artifact@v1
with:
name: wheel
# 3.8 is the earliest python for M1
- name: "test python 3.8"
run: |
arch -arm64 /opt/homebrew/opt/[email protected]/bin/python3 -m venv venv38
arch -arm64 ./venv38/bin/pip install oso==${{ steps.version.outputs.oso_version }} -f ../wheel --no-deps --no-index
arch -arm64 ./venv38/bin/pip install oso==${{ steps.version.outputs.oso_version }} -f ../wheel
arch -arm64 ./venv38/bin/python test.py
working-directory: test
- name: "test python 3.9"
run: |
arch -arm64 /opt/homebrew/opt/[email protected]/bin/python3 -m venv venv39
arch -arm64 ./venv39/bin/pip install oso==${{ steps.version.outputs.oso_version }} -f ../wheel --no-deps --no-index
arch -arm64 ./venv39/bin/pip install oso==${{ steps.version.outputs.oso_version }} -f ../wheel
arch -arm64 ./venv39/bin/python test.py
working-directory: test
- name: "test python 3.10"
run: |
arch -arm64 /opt/homebrew/opt/[email protected]/bin/python3 -m venv venv310
arch -arm64 ./venv310/bin/pip install oso==${{ steps.version.outputs.oso_version }} -f ../wheel --no-deps --no-index
arch -arm64 ./venv310/bin/pip install oso==${{ steps.version.outputs.oso_version }} -f ../wheel
arch -arm64 ./venv310/bin/python test.py
working-directory: test
- name: "test python 3.11"
run: |
arch -arm64 /opt/homebrew/opt/[email protected]/bin/python3 -m venv venv311
arch -arm64 ./venv311/bin/pip install oso==${{ steps.version.outputs.oso_version }} -f ../wheel --no-deps --no-index
arch -arm64 ./venv311/bin/pip install oso==${{ steps.version.outputs.oso_version }} -f ../wheel
arch -arm64 ./venv311/bin/python test.py
working-directory: test
- name: "test python 3.12"
run: |
arch -arm64 /opt/homebrew/opt/[email protected]/bin/python3 -m venv venv312
arch -arm64 ./venv312/bin/pip install oso==${{ steps.version.outputs.oso_version }} -f ../wheel --no-deps --no-index
arch -arm64 ./venv312/bin/pip install oso==${{ steps.version.outputs.oso_version }} -f ../wheel
arch -arm64 ./venv312/bin/python test.py
working-directory: test
validate_python_windows:
name: Test python ${{ matrix.python-version }} on Windows
needs: [build_windows_wheels]
runs-on: windows-2019
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v2
- name: Set version env
id: version
run: echo "::set-output name=oso_version::$(cat VERSION)"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Download oso python wheels from package run
uses: actions/download-artifact@v1
with:
name: wheel
- name: "test"
run: |
# first install _only_ the wheel and make sure it's available
pip install oso==${{ steps.version.outputs.oso_version }} -f ../wheel --no-deps --no-index
# then install deps too
pip install oso==${{ steps.version.outputs.oso_version }} -f ../wheel
python test.py
working-directory: test
validate_python_musl:
name: Test python ${{ matrix.python-version }} on Alpine
needs: [build_linux_wheels]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v2
- name: Set version env
id: version
run: echo "::set-output name=oso_version::$(cat VERSION)"
- name: Download oso python wheels from package run
uses: actions/download-artifact@v1
with:
name: wheel
- run: docker run --rm --env OSO_VERSION -v `pwd`:/oso python:${{ matrix.python-version }}-alpine oso/scripts/test_musl.sh
env:
OSO_VERSION: ${{ steps.version.outputs.oso_version }}
validate_ruby:
name: Test ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
needs: [build_gem]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-11, windows-2019]
ruby-version: ["2.6", "2.7", "3.0", "3.1", "3.2"]
steps:
- uses: actions/checkout@v2
- name: Set version env
id: version
run: echo "oso_version=$(cat VERSION)" >> $GITHUB_ENV
- name: Set up ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
working-directory: "languages/ruby"
- name: Download oso gem from package run
uses: actions/download-artifact@v1
with:
name: gem
- name: "test"
if: runner.os != 'Windows'
run: |
gem install gem/*.gem
ruby languages/ruby/spec/oso/language_parity_spec.rb
- name: "test"
if: runner.os == 'Windows'
run: |
gem install gem/*.gem
ruby languages\ruby\spec\oso\language_parity_spec.rb
validate_java:
name: Test java ${{ matrix.java-version }} on ${{ matrix.os }}
needs: [build_jar]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-11, windows-2019]
java-version: [11, 12, 13, 14]
steps:
- uses: actions/checkout@v2
- name: Set version env
id: version
run: echo "::set-output name=oso_version::$(cat VERSION)"
- uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java-version }}
- name: Download oso jar from package run
uses: actions/download-artifact@v1
with:
name: jar
- name: Run tests
if: runner.os != 'Windows'
run: |
javac -cp "../jar/oso-${{ steps.version.outputs.oso_version }}.jar:." Test.java
java -cp "../jar/oso-${{ steps.version.outputs.oso_version }}.jar:." Test
working-directory: test
- name: Run tests
if: runner.os == 'Windows'
env:
github_ref: ${{ github.ref }}
run: |
javac -cp "..\jar\oso-${{ steps.version.outputs.oso_version }}.jar;." Test.java
java -cp "..\jar\oso-${{ steps.version.outputs.oso_version }}.jar;." Test
working-directory: test
validate_js:
name: Test node ${{ matrix.node-version }} on ${{ matrix.os }}
needs: [build_js]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-11, windows-2019]
node-version: ["12", "14", "16"]
steps:
- uses: actions/checkout@v2
- name: Set version env
id: version
run: echo "oso_version=$(cat VERSION)" >> $GITHUB_ENV
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Download oso js from package run
uses: actions/download-artifact@v1
with:
name: oso_js_node
- name: Install production dependencies
run: yarn install --production
working-directory: oso_js_node
- name: Run parity tests
run: node dist/test/parity.js
working-directory: oso_js_node
test_quickstarts:
name: Test Quickstarts
runs-on: ubuntu-latest
needs: [version]
steps:
- uses: actions/checkout@v2
- name: Initialize submodules
run: make -C docs/examples update-submodules
- name: Check that submodules are all up-to-date
run: |
git submodule foreach git remote update
git submodule foreach '[ -z $(git --no-pager diff origin/main main) ]'
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}
- name: Use Python 3.7
uses: actions/setup-python@v1
with:
python-version: "3.7"
- name: Use Ruby 2.7
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: "2.7"
working-directory: "docs/examples/quickstart/ruby"
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: "12"
- name: Use Java 11
uses: actions/setup-java@v1
with:
java-version: "11"
- name: Use stable Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.69.0
override: true
- name: Use Go 1.14
uses: actions/setup-go@v2
with:
go-version: "1.14"
- name: Run quickstart tests
run: make -C docs test-quickstarts-release
release:
name: Create release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
[
build_linux_wheels,
build_macos_wheels,
build_windows_wheels,
build_jar,
build_gem,
build_go,
validate_python_linux,
validate_python_macos_11,
validate_python_windows,
validate_python_musl,
validate_ruby,
validate_java,
validate_js,
validate_go,
test_quickstarts,
]
steps:
- name: Set version env
id: version
env:
github_ref: ${{ github.ref }}
run: echo "::set-output name=oso_version::${github_ref/refs\/tags\/v/}"
- name: Download oso dylibs
uses: actions/download-artifact@v1
with:
name: oso_library
- name: Zip libraries
run: zip --junk-paths -r oso-lib.zip oso_library/
- name: Download oso python wheels from package run
uses: actions/download-artifact@v1
with:
name: wheel
- name: Zip wheels
run: zip --junk-paths -r oso-python.zip wheel/
- name: Download oso gem from package run
uses: actions/download-artifact@v1
with:
name: gem
- name: Zip ruby gem
run: zip --junk-paths -r oso-ruby.zip gem/
- name: Download oso jar from package run
uses: actions/download-artifact@v1
with:
name: jar
- name: Zip Java JAR
run: zip --junk-paths -r oso-java.zip jar/
- name: Download oso javascript package from package run
uses: actions/download-artifact@v1
with:
name: oso_js_node
- name: Create JS release artifact
working-directory: oso_js_node
run: npm pack
- name: Download oso go lib
uses: actions/download-artifact@v1
with:
name: go
- name: Zip Go source code
run: zip -r go-oso.zip go/
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.version.outputs.oso_version }}
release_name: oso ${{ steps.version.outputs.oso_version }}
body: |
oso ${{ steps.version.outputs.oso_version }}
draft: false
prerelease: true
- name: Upload Libraries
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./oso-lib.zip
asset_name: oso-lib-${{ steps.version.outputs.oso_version }}.zip
asset_content_type: application/zip
- name: Upload Python Package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./oso-python.zip
asset_name: oso-python-${{ steps.version.outputs.oso_version }}.zip
asset_content_type: application/zip
- name: Upload Ruby Gem
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./oso-ruby.zip
asset_name: oso-ruby-${{ steps.version.outputs.oso_version }}.zip
asset_content_type: application/zip
- name: Upload Java Jar
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./oso-java.zip
asset_name: oso-java-${{ steps.version.outputs.oso_version }}.zip
asset_content_type: application/zip
- name: Upload Js Package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./oso_js_node/oso-${{ steps.version.outputs.oso_version }}.tgz
asset_name: oso-js-node-${{ steps.version.outputs.oso_version }}.tgz
asset_content_type: application/gzip
- name: Upload go package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./go-oso.zip
asset_name: go-oso-${{ steps.version.outputs.oso_version }}.zip
asset_content_type: application/zip
# TODO(gj): update this to post to Quill or a private channel on community Slack.
alert-failure:
name: Alert on failure
if: ${{ !success() }}
runs-on: ubuntu-latest
needs:
[
validate_python_linux,
validate_python_macos_11,
validate_python_macos_arm,
validate_python_windows,
validate_python_musl,
validate_ruby,
validate_java,
validate_js,
validate_go,
validate_go_macos_arm,
test_quickstarts,
]
steps:
- uses: rtCamp/action-slack-notify@master
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
env:
SLACK_CHANNEL: firehose
SLACK_COLOR: "danger"
SLACK_MESSAGE: "${{ github.event.head_commit.url }}"
SLACK_TITLE: "Release job failed."
SLACK_USERNAME: github-actions