950 lines (829 loc) · 33.5 KB
/
go.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
name: Build
on:
push:
branches:
- main
- develop
tags:
- build*
paths-ignore:
- "**/*.md"
- "docs/**"
- "licenses/**"
pull_request:
branches:
- main
- develop
paths-ignore:
- "**/*.md"
- "docs/**"
- "examples/**"
- "licenses/**"
env:
GOTESTCMD: "go test -timeout 1200s --tags \"json1 sqleanall\" -v ./..."
TESTSCRIPT: "test/python/main.py"
GOPRIVATE: github.com/stackql/*
GH_ACCESS_TOKEN: ${{ secrets.ACTIONS_PRIVATE_PACKAGE_SECRET }}
PLANCACHEENABLED: "true"
jobs:
winbuild:
name: Windows Build
runs-on: windows-latest
steps:
- name: Get rid of disruptive line endings before checkout
run: |
git config --global core.autocrlf false
- name: Check out code into the Go module directory
uses: actions/checkout@v4.1.1
- name: Set up Go 1.x
uses: actions/setup-go@v5.0.0
with:
go-version: ^1.19
check-latest: true
cache: true
id: go
- name: Setup Python
uses: actions/setup-python@v5.0.0
with:
cache: pip
python-version: '3.11'
- name: Cache Chocolatey packages
id: cache-choco
# uses: actions/cache@v3
uses: actions/cache@v4.0.0
env:
cache-name: cache-choco-packages
with:
path: 'C:\Users\${{ env.username }}\AppData\Local\Temp\chocolatey\'
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/chocolatey/**/*.zip', '**/chocolatey/**/*.7z') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
- if: ${{ steps.cache-choco.outputs.cache-hit == 'true' }}
name: List the state of Chocolatey packages
continue-on-error: true
run: |
dir "C:\Users\${{ env.username }}\AppData\Local\Temp\chocolatey\"
- name: Set up mingw
uses: egor-tensin/setup-mingw@v2.2.0
id: gccsetup
timeout-minutes: 20
with:
version: '8.1.0'
- name: Git Ref Parse
id: git_ref_parse
run: |
{
echo "SOURCE_NAME=${GITHUB_REF#refs/*/}"
echo "SOURCE_BRANCH=${GITHUB_REF#refs/heads/}"
echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}"
} >> "${GITHUB_STATE}"
- name: Choco install packages
uses: crazy-max/ghaction-chocolatey@v3.0.0
if: startsWith(steps.git_ref_parse.outputs.SOURCE_TAG, 'build-release')
timeout-minutes: 40
with:
args: "install --force postgresql13 openssl sqlite"
- name: Install Python dependencies
run: |
pip3 install -r cicd/requirements.txt
- name: Generate rewritten registry for simulations
run: |
python3 test\python\registry-rewrite.py
- name: Get dependencies
run: |
go env -w GOPRIVATE="github.com/stackql/*"
git config --global url."https://$env:GHACCESSTOKEN@github.com/".insteadOf "https://github.com/"
git --no-pager config --list
go get -v -t -d ./...
env:
CGO_ENABLED: 1
GHACCESSTOKEN: ${{env.GH_ACCESS_TOKEN}}
GOPRIVATE: ${{env.GOPRIVATE}}
- name: Generate Build Flags and Build
env:
BUILDCOMMITSHA: ${{github.sha}}
BUILDBRANCH: ${{github.ref}}
BUILDPLATFORM: ${{runner.os}}
BUILDPATCHVERSION: ${{github.run_number}}
CGO_ENABLED: 1
GH_ACCESS_TOKEN: ${{env.GH_ACCESS_TOKEN}}
GOPRIVATE: ${{env.GOPRIVATE}}
run: |
git config --global url.https://$env:GH_ACCESS_TOKEN@github.com/.insteadOf https://github.com/
$Version = convertfrom-stringdata (get-content ./cicd/version.txt -raw)
$BuildMajorVersion = $Version.'MajorVersion'
$BuildMinorVersion = $Version.'MinorVersion'
$env:BUILDMAJORVERSION = $BuildMajorVersion
$env:BUILDMINORVERSION = $BuildMinorVersion
echo "BUILDMAJORVERSION=$env:BUILDMAJORVERSION" >> $GITHUB_ENV
echo "BUILDMINORVERSION=$env:BUILDMINORVERSION" >> $GITHUB_ENV
echo "BUILDPATCHVERSION=$env:BUILDPATCHVERSION" >> $GITHUB_ENV
python cicd/python/build.py --verbose --build
- name: Test
if: success()
run: python cicd/python/build.py --verbose --test
- name: Mock Server Download
if: startsWith(steps.git_ref_parse.outputs.SOURCE_TAG, 'build-release')
run: |
mvn org.apache.maven.plugins:maven-dependency-plugin:3.0.2:copy `
'-Dartifact=org.mock-server:mockserver-netty:5.12.0:jar:shaded' `
'-DoutputDirectory=test/downloads'
- name: Create certificates for robot tests
if: startsWith(steps.git_ref_parse.outputs.SOURCE_TAG, 'build-release')
run: |
openssl req -x509 -keyout test/server/mtls/credentials/pg_server_key.pem -out test/server/mtls/credentials/pg_server_cert.pem -config test/server/mtls/openssl.cnf -days 365
openssl req -x509 -keyout test/server/mtls/credentials/pg_client_key.pem -out test/server/mtls/credentials/pg_client_cert.pem -config test/server/mtls/openssl.cnf -days 365
openssl req -x509 -keyout test/server/mtls/credentials/pg_rubbish_key.pem -out test/server/mtls/credentials/pg_rubbish_cert.pem -config test/server/mtls/openssl.cnf -days 365
- name: Run robot mocked functional tests
if: startsWith(steps.git_ref_parse.outputs.SOURCE_TAG, 'build-release')
env:
PSQL_EXE: C:\Program Files\PostgreSQL\13\bin\psql
SQLITE_EXE: C:\ProgramData\chocolatey\lib\SQLite\tools\sqlite3.exe
run: |
python cicd/python/build.py --robot-test
- name: Output from mocked functional tests
if: startsWith(steps.git_ref_parse.outputs.SOURCE_TAG, 'build-release')
run: |
cat ./test/robot/functional/output.xml
- name: Run robot integration tests
if: env.AZURE_CLIENT_SECRET != '' && startsWith(steps.git_ref_parse.outputs.SOURCE_TAG, 'build-release')
env:
PSQL_EXE: C:\Program Files\PostgreSQL\13\bin\psql
SQLITE_EXE: C:\ProgramData\chocolatey\lib\SQLite\tools\sqlite3.exe
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_INTEGRATION_TESTING_SUB_ID: ${{ secrets.AZURE_INTEGRATION_TESTING_SUB_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
run: |
python cicd/python/build.py --robot-test-integration
- name: Prepare Test DB
if: success()
run: copy test/db/db.sqlite test/db/tmp/python-tests-tmp-db.sqlite
- name: Test Script
if: success()
run: python.exe test/python/main.py
- name: Upload Artifact
# uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4.3.1
if: success()
with:
name: stackql_windows_amd64
path: build/stackql.exe
linuxbuild:
name: Linux Build
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4.1.1
- name: Set up Go 1.x
uses: actions/setup-go@v5.0.0
with:
go-version: ^1.19
check-latest: true
cache: true
id: go
- name: Setup Python
uses: actions/setup-python@v5.0.0
with:
cache: pip
python-version: '3.11'
- name: Git Ref Parse
id: git_ref_parse
run: |
{
echo "SOURCE_NAME=${GITHUB_REF#refs/*/}"
echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}"
echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}"
} >> "${GITHUB_STATE}"
- name: Set up GCC
uses: egor-tensin/setup-gcc@v1
id: gccsetup
with:
platform: x64
cygwin: 0
- name: Install psql
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends postgresql-client
- name: Install Python dependencies
run: |
pip3 install -r cicd/requirements.txt
- name: Generate rewritten registry for simulations
run: |
python3 test/python/registry-rewrite.py
- name: Get dependencies
run: |
git config --global "url.https://${GH_ACCESS_TOKEN}@github.com/.insteadOf" https://github.com/
go get -v -t -d ./...
go install golang.org/x/perf/cmd/benchstat@latest
env:
GH_ACCESS_TOKEN: ${{env.GH_ACCESS_TOKEN}}
GOPRIVATE: ${{env.GOPRIVATE}}
- name: Generate Build Flags and Build
env:
BUILDCOMMITSHA: ${{github.sha}}
BUILDBRANCH: ${{github.ref}}
BUILDPLATFORM: ${{runner.os}}
BUILDPATCHVERSION: ${{github.run_number}}
CGO_ENABLED: 1
CGO_LDFLAGS: '-static'
run: |
source cicd/version.txt
export BUILDMAJORVERSION="$MajorVersion"
export BUILDMINORVERSION="$MinorVersion"
if [[ ! "$BUILDBRANCH" == "*develop" ]]
then
# shellcheck disable=2269
export BUILDPATCHVERSION="${BUILDPATCHVERSION}"
fi
BUILDSHORTCOMMITSHA="$(echo "${BUILDCOMMITSHA}" | cut -c 1-7)"
export BUILDSHORTCOMMITSHA
BUILDDATE="$(date)"
export BUILDDATE
echo "BUILDMAJORVERSION: ${BUILDMAJORVERSION}"
echo "BUILDMINORVERSION: ${BUILDMINORVERSION}"
echo "BUILDPATCHVERSION: ${BUILDPATCHVERSION}"
echo "BUILDBRANCH: ${BUILDBRANCH}"
echo "BUILDCOMMITSHA: ${BUILDCOMMITSHA}"
echo "BUILDSHORTCOMMITSHA: ${BUILDSHORTCOMMITSHA}"
echo "BUILDDATE: ${BUILDDATE}"
echo "BUILDPLATFORM: ${BUILDPLATFORM}"
{
echo "BUILDMAJORVERSION=${BUILDMAJORVERSION}"
echo "BUILDMINORVERSION=${BUILDMINORVERSION}"
echo "BUILDPATCHVERSION=${BUILDPATCHVERSION}"
} >> "${GITHUB_ENV}"
python cicd/python/build.py --verbose --build
- name: Test
if: success()
run: python cicd/python/build.py --verbose --test
- name: Benchmark
if: success()
run: |
outFile="cicd/log/current-bench-nocache.txt"
baselineRefFile="cicd/ref/bench/baseline-go-bench.log"
thresholdRefFile="cicd/ref/bench/max-threshold-go-bench.log"
go test -run='^$' -bench . -benchtime=100x -count=6 \
--tags "json1 sqleanall" --ldflags "-X stackql/internal/stackql/planbuilder.PlanCacheEnabled=false" \
./... | tee ${outFile}
# shellcheck disable=SC2181
if [ "$?" = "0" ]; then
echo "Benchmarking run completed successfully"
else
echo "Benchmarking run failed"
exit 1
fi
echo ""
echo "##### Raw benchstat on current run #####"
echo ""
benchstat ${outFile} | tee cicd/log/raw-benchstat.txt
echo ""
echo "##### Comparing to baseline #####"
echo ""
benchstat -row .name -table .config -ignore goos,goarch,cpu ${baselineRefFile} ${outFile} | tee cicd/log/comparison-benchstat.txt
echo ""
echo "##### Comparing to max threshold #####"
echo ""
benchstat -row .name -table .config -ignore goos,goarch,cpu ${thresholdRefFile} ${outFile} | tee cicd/log/threshold-comparison-benchstat.txt
# shellcheck disable=SC2002,SC2062
comparisons=$( cat cicd/log/threshold-comparison-benchstat.txt \
| sed 's/.*\([+-][0-9][0-9]\.[0-9][0-9]*[%]\).*/\1/' \
| grep [+-][0-9][0-9]*\.[0-9][0-9]*[%] \
)
echo ""
echo "##### Comparisons #####"
echo ""
echo "${comparisons}"
# shellcheck disable=SC2062
nonNegativeComparisons=$( echo "${comparisons}" \
| grep -v [-].* \
|| true
)
echo "completed comparison logic"
if [ -z "${nonNegativeComparisons}" ]; then
echo "All max threshold comparisons are negative: this is acceptable"
else
echo "Some max threshold comparisons are positive or zero: this is unacceptable"
echo ""
echo "##### Non-negative comparisons #####"
echo "${nonNegativeComparisons}"
echo ""
exit 1
fi
- name: Mock Server Download
run: |
mvn \
org.apache.maven.plugins:maven-dependency-plugin:3.0.2:copy \
-Dartifact=org.mock-server:mockserver-netty:5.12.0:jar:shaded \
-DoutputDirectory=test/downloads
- name: Create certificates for robot tests
run: |
openssl req -x509 -keyout test/server/mtls/credentials/pg_server_key.pem -out test/server/mtls/credentials/pg_server_cert.pem -config test/server/mtls/openssl.cnf -days 365
openssl req -x509 -keyout test/server/mtls/credentials/pg_client_key.pem -out test/server/mtls/credentials/pg_client_cert.pem -config test/server/mtls/openssl.cnf -days 365
openssl req -x509 -keyout test/server/mtls/credentials/pg_rubbish_key.pem -out test/server/mtls/credentials/pg_rubbish_cert.pem -config test/server/mtls/openssl.cnf -days 365
- name: Run robot mocked functional tests
if: success()
run: |
python cicd/python/build.py --robot-test --config='{ "variables": { "SHOULD_RUN_DOCKER_EXTERNAL_TESTS": "true" } }'
- name: Output from mocked functional tests
if: always()
run: |
cat ./test/robot/functional/output.xml
- name: Run robot mocked functional tests with aggressive concurrency
if: success()
run: |
python cicd/python/build.py --robot-test --config='{ "variables": { "SHOULD_RUN_DOCKER_EXTERNAL_TESTS": "true", "CONCURRENCY_LIMIT": -1 } }'
- name: Output from mocked functional tests with aggressive concurrency
if: always()
run: |
cat ./test/robot/functional/output.xml
- name: Run robot integration tests
if: env.AZURE_CLIENT_SECRET != '' && startsWith(steps.git_ref_parse.outputs.SOURCE_TAG, 'build-release')
env:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_INTEGRATION_TESTING_SUB_ID: ${{ secrets.AZURE_INTEGRATION_TESTING_SUB_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
run: |
python cicd/python/build.py --robot-test-integration
- name: Prepare Test DB
if: success()
run: cp test/db/db.sqlite test/db/tmp/python-tests-tmp-db.sqlite
- name: Test Script
if: success()
run: python3 "${TESTSCRIPT}"
env:
TESTSCRIPT: ${{env.TESTSCRIPT}}
- name: Upload Artifact
uses: actions/upload-artifact@v4.3.1
if: success()
with:
name: stackql_linux_amd64
path: build/stackql
wsltest:
name: WSL Test
runs-on: windows-latest
needs: linuxbuild
steps:
- name: Get rid of disruptive line endings before checkout
run: |
git config --global core.autocrlf false
- name: Check out code into the Go module directory
uses: actions/checkout@v4.1.1
- name: Download Artifact
# uses: actions/download-artifact@v3
uses: actions/download-artifact@v4.1.2
with:
name: stackql_linux_amd64
path: build
- name: Setup WSL with dependencies
# uses: Vampire/setup-wsl@v1
uses: Vampire/setup-wsl@v3.0.0
with:
additional-packages:
maven
openjdk-11-jre
openssl
postgresql
python3
python3-pip
sqlite3
wsl-conf: |
[automount]
options = "metadata"
- shell: wsl-bash -u root {0}
name: Stackql permissions
run: |
chmod a+rwx build/stackql
ls -al build/stackql
- shell: wsl-bash -u root {0}
name: Install Python dependencies
run: pip3 install -r cicd/requirements.txt
- shell: wsl-bash {0}
name: Generate rewritten registry for simulations
run: python3 test/python/registry-rewrite.py
- shell: wsl-bash {0}
name: Mock Server Download
run: |
mvn \
org.apache.maven.plugins:maven-dependency-plugin:3.0.2:copy \
-Dartifact=org.mock-server:mockserver-netty:5.12.0:jar:shaded \
-DoutputDirectory=test/downloads
- shell: wsl-bash {0}
name: Create certificates for robot tests
run: |
openssl req -x509 -keyout test/server/mtls/credentials/pg_server_key.pem -out test/server/mtls/credentials/pg_server_cert.pem -config test/server/mtls/openssl.cnf -days 365
openssl req -x509 -keyout test/server/mtls/credentials/pg_client_key.pem -out test/server/mtls/credentials/pg_client_cert.pem -config test/server/mtls/openssl.cnf -days 365
openssl req -x509 -keyout test/server/mtls/credentials/pg_rubbish_key.pem -out test/server/mtls/credentials/pg_rubbish_cert.pem -config test/server/mtls/openssl.cnf -days 365
- shell: wsl-bash {0}
name: Run robot mocked functional tests
run: |
. cicd/version.txt
export BUILDBRANCH="${{github.ref}}"
export BUILDPATCHVERSION="${{github.run_number}}"
export BUILDMAJORVERSION=$MajorVersion
export BUILDMINORVERSION=$MinorVersion
echo "BUILDBRANCH=$BUILDBRANCH"
echo "BUILDMAJORVERSION=$BUILDMAJORVERSION"
echo "BUILDMINORVERSION=$BUILDMINORVERSION"
echo "BUILDPATCHVERSION=$BUILDPATCHVERSION"
if [[ ! "$BUILDBRANCH" == "*develop" ]]
then
export BUILDPATCHVERSION="${BUILDPATCHVERSION}"
fi
python3 cicd/python/build.py --robot-test --config='{ "variables": { "IS_WSL": true } }'
- shell: wsl-bash {0}
name: Output from mocked functional tests
if: always()
run: |
cat ./test/robot/functional/output.xml
- shell: wsl-bash {0}
name: Run robot integration tests
# This is a hack because if cannot directly access secrets
if: env.AZURE_CLIENT_SECRET != ''
env:
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
run: |
. cicd/version.txt
export AZURE_CLIENT_ID='${{ secrets.AZURE_CLIENT_ID }}'
export AZURE_CLIENT_SECRET='${{ secrets.AZURE_CLIENT_SECRET }}'
export AZURE_INTEGRATION_TESTING_SUB_ID='${{ secrets.AZURE_INTEGRATION_TESTING_SUB_ID }}'
export AZURE_TENANT_ID='${{ secrets.AZURE_TENANT_ID }}'
export BUILDBRANCH="${{github.ref}}"
export BUILDPATCHVERSION="${{github.run_number}}"
export BUILDMAJORVERSION=$MajorVersion
export BUILDMINORVERSION=$MinorVersion
echo "BUILDBRANCH=$BUILDBRANCH"
echo "BUILDMAJORVERSION=$BUILDMAJORVERSION"
echo "BUILDMINORVERSION=$BUILDMINORVERSION"
echo "BUILDPATCHVERSION=$BUILDPATCHVERSION"
if [[ ! "$BUILDBRANCH" == "*develop" ]]
then
export BUILDPATCHVERSION="${BUILDPATCHVERSION}"
fi
python3 cicd/python/build.py --robot-test-integration --config='{ "variables": { "IS_WSL": true } }'
macosbuild:
name: MacOS Build
runs-on: macos-11
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4.1.1
- name: Set up Go 1.x
uses: actions/setup-go@v5.0.0
with:
go-version: ^1.19
check-latest: true
cache: true
id: go
- name: Setup Python
uses: actions/setup-python@v5.0.0
with:
cache: pip
python-version: '3.11'
- name: Git Ref Parse
id: git_ref_parse
run: |
{
echo "SOURCE_NAME=${GITHUB_REF#refs/*/}"
echo "SOURCE_BRANCH=${GITHUB_REF#refs/heads/}"
echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}"
} >> "${GITHUB_STATE}"
- name: Install Python dependencies
run: |
pip3 install -r cicd/requirements.txt
- name: Generate rewritten registry for simulations
run: |
python3 test/python/registry-rewrite.py
- name: Get dependencies
run: |
git config --global "url.https://${GH_ACCESS_TOKEN}@github.com/.insteadOf" https://github.com/
go get -v -t -d ./...
env:
CGO_ENABLED: 1
GH_ACCESS_TOKEN: ${{env.GH_ACCESS_TOKEN}}
GOPRIVATE: ${{env.GOPRIVATE}}
- name: Generate Build Flags and Build
env:
BUILDCOMMITSHA: ${{github.sha}}
BUILDBRANCH: ${{github.ref}}
BUILDPLATFORM: ${{runner.os}}
BUILDPATCHVERSION: ${{github.run_number}}
CGO_ENABLED: 1
run: |
source cicd/version.txt
export BUILDMAJORVERSION="$MajorVersion"
export BUILDMINORVERSION="$MinorVersion"
if [[ ! "$BUILDBRANCH" == "*develop" ]]
then
# shellcheck disable=2269
export BUILDPATCHVERSION="${BUILDPATCHVERSION}"
fi
BUILDSHORTCOMMITSHA="$(echo "$BUILDCOMMITSHA" | cut -c 1-7)"
export BUILDSHORTCOMMITSHA
BUILDDATE="$(date)"
export BUILDDATE
echo "BUILDMAJORVERSION: ${BUILDMAJORVERSION}"
echo "BUILDMINORVERSION: ${BUILDMINORVERSION}"
echo "BUILDPATCHVERSION: ${BUILDPATCHVERSION}"
echo "BUILDBRANCH: ${BUILDBRANCH}"
echo "BUILDCOMMITSHA: ${BUILDCOMMITSHA}"
echo "BUILDSHORTCOMMITSHA: ${BUILDSHORTCOMMITSHA}"
echo "BUILDDATE: ${BUILDDATE}"
echo "BUILDPLATFORM: ${BUILDPLATFORM}"
{
echo "BUILDMAJORVERSION=$BUILDMAJORVERSION"
echo "BUILDMINORVERSION=$BUILDMINORVERSION"
echo "BUILDPATCHVERSION=$BUILDPATCHVERSION"
} >> "${GITHUB_ENV}"
python cicd/python/build.py --verbose --build
- name: Test
if: success()
run: python cicd/python/build.py --verbose --test
- name: Mock Server Download
run: |
mvn \
org.apache.maven.plugins:maven-dependency-plugin:3.0.2:copy \
-Dartifact=org.mock-server:mockserver-netty:5.12.0:jar:shaded \
-DoutputDirectory=test/downloads
- name: Create certificates for robot tests
run: |
openssl req -x509 -keyout test/server/mtls/credentials/pg_server_key.pem -out test/server/mtls/credentials/pg_server_cert.pem -config test/server/mtls/openssl.cnf -days 365
openssl req -x509 -keyout test/server/mtls/credentials/pg_client_key.pem -out test/server/mtls/credentials/pg_client_cert.pem -config test/server/mtls/openssl.cnf -days 365
openssl req -x509 -keyout test/server/mtls/credentials/pg_rubbish_key.pem -out test/server/mtls/credentials/pg_rubbish_cert.pem -config test/server/mtls/openssl.cnf -days 365
- name: Run robot mocked functional tests
if: success()
run: |
python cicd/python/build.py --robot-test
- name: Output from mocked functional tests
if: always()
run: |
cat ./test/robot/functional/output.xml
- name: Run robot integration tests
if: env.AZURE_CLIENT_SECRET != '' && startsWith(steps.git_ref_parse.outputs.SOURCE_TAG, 'build-release')
env:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_INTEGRATION_TESTING_SUB_ID: ${{ secrets.AZURE_INTEGRATION_TESTING_SUB_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
run: |
python cicd/python/build.py --robot-test-integration
- name: Prepare Test DB
if: success()
run: cp test/db/db.sqlite test/db/tmp/python-tests-tmp-db.sqlite
- name: Test Script
if: success()
run: python3 "${TESTSCRIPT}"
env:
TESTSCRIPT: ${{env.TESTSCRIPT}}
- name: Upload Artifact
uses: actions/upload-artifact@v4.3.1
if: success()
with:
name: stackql_darwin_amd64
path: build/stackql
macosarmbuild:
name: MacOS ARM Build
runs-on: macos-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4.1.1
- name: Setup Python
uses: actions/setup-python@v5.0.0
with:
cache: pip
python-version: '3.11'
- name: Set up Go 1.x
uses: actions/setup-go@v5.0.0
with:
go-version: ^1.19
check-latest: true
cache: true
id: go
- name: Get dependencies
run: |
git config --global "url.https://${GH_ACCESS_TOKEN}@github.com/.insteadOf" https://github.com/
go get -v -t -d ./...
env:
CGO_ENABLED: 1
GH_ACCESS_TOKEN: ${{env.GH_ACCESS_TOKEN}}
GOPRIVATE: ${{env.GOPRIVATE}}
- name: Generate Build Flags and Build
env:
BUILDCOMMITSHA: ${{github.sha}}
BUILDBRANCH: ${{github.ref}}
BUILDPLATFORM: "darwin_arm64"
BUILDPATCHVERSION: ${{github.run_number}}
CGO_ENABLED: 1
run: |
source cicd/version.txt
export BUILDMAJORVERSION="$MajorVersion"
export BUILDMINORVERSION="$MinorVersion"
if [[ ! "$BUILDBRANCH" == "*develop" ]]
then
# shellcheck disable=2269
export BUILDPATCHVERSION="${BUILDPATCHVERSION}"
fi
BUILDSHORTCOMMITSHA="$(echo "$BUILDCOMMITSHA" | cut -c 1-7)"
export BUILDSHORTCOMMITSHA
BUILDDATE="$(date)"
export BUILDDATE
echo "BUILDMAJORVERSION: ${BUILDMAJORVERSION}"
echo "BUILDMINORVERSION: ${BUILDMINORVERSION}"
echo "BUILDPATCHVERSION: ${BUILDPATCHVERSION}"
echo "BUILDBRANCH: ${BUILDBRANCH}"
echo "BUILDCOMMITSHA: ${BUILDCOMMITSHA}"
echo "BUILDSHORTCOMMITSHA: ${BUILDSHORTCOMMITSHA}"
echo "BUILDDATE: ${BUILDDATE}"
echo "BUILDPLATFORM: ${BUILDPLATFORM}"
{
echo "BUILDMAJORVERSION=$BUILDMAJORVERSION"
echo "BUILDMINORVERSION=$BUILDMINORVERSION"
echo "BUILDPATCHVERSION=$BUILDPATCHVERSION"
} >> "${GITHUB_ENV}"
export GOOS="darwin"
export GOARCH="arm64"
python cicd/python/build.py --verbose --build
- name: Upload Artifact
uses: actions/upload-artifact@v4.3.1
if: success()
with:
name: stackql_darwin_arm64
path: build/stackql
dockerbuild:
name: Docker Build
runs-on: ubuntu-latest-m
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4.1.1
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Setup Python
uses: actions/setup-python@v5.0.0
with:
cache: pip
python-version: '3.11'
- name: Git Ref Parse
id: git_ref_parse
run: |
{
echo "SOURCE_NAME=${GITHUB_REF#refs/*/}"
echo "SOURCE_BRANCH=${GITHUB_REF#refs/heads/}"
echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}"
} >> "${GITHUB_STATE}"
- name: Install psql
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends \
postgresql-client \
ca-certificates \
openssl
- name: Install Python dependencies
run: |
pip3 install -r cicd/requirements.txt
- name: Extract Build Info and Persist
env:
BUILDCOMMITSHA: ${{github.sha}}
BUILDBRANCH: ${{github.ref}}
BUILDPLATFORM: ${{runner.os}}
BUILDPATCHVERSION: ${{github.run_number}}
run: |
source cicd/version.txt
BUILDMAJORVERSION=${MajorVersion}
BUILDMINORVERSION=${MinorVersion}
if [[ ! "$BUILDBRANCH" == "*develop" ]]; then
# shellcheck disable=2269
BUILDPATCHVERSION="${BUILDPATCHVERSION}"
fi
BUILDSHORTCOMMITSHA="$(echo "${BUILDCOMMITSHA}" | cut -c 1-7)"
BUILDDATE="$(date)"
export BUILDDATE
echo "BUILDMAJORVERSION: ${BUILDMAJORVERSION}"
echo "BUILDMINORVERSION: ${BUILDMINORVERSION}"
echo "BUILDPATCHVERSION: ${BUILDPATCHVERSION}"
echo "BUILDBRANCH: ${BUILDBRANCH}"
echo "BUILDCOMMITSHA: ${BUILDCOMMITSHA}"
echo "BUILDSHORTCOMMITSHA: ${BUILDSHORTCOMMITSHA}"
echo "BUILDDATE: ${BUILDDATE}"
echo "BUILDPLATFORM: ${BUILDPLATFORM}"
{
echo "BUILDMAJORVERSION=$BUILDMAJORVERSION"
echo "BUILDMINORVERSION=$BUILDMINORVERSION"
echo "BUILDPATCHVERSION=$BUILDPATCHVERSION"
} >> "${GITHUB_ENV}"
- name: Generate rewritten registry for simulations
run: |
python3 test/python/registry-rewrite.py --replacement-host=host.docker.internal
- name: Pull Docker base images for cache purposes
run: |
docker pull golang:1.18.4-bullseye
docker pull ubuntu:22.04
- name: Pull Docker image for cache purposes
run: |
docker pull stackql/stackql:latest || echo 'could not pull image for cache purposes'
- name: Create certificates for robot tests
run: |
openssl req -x509 -keyout test/server/mtls/credentials/pg_server_key.pem -out test/server/mtls/credentials/pg_server_cert.pem -config test/server/mtls/openssl.cnf -days 365
openssl req -x509 -keyout test/server/mtls/credentials/pg_client_key.pem -out test/server/mtls/credentials/pg_client_cert.pem -config test/server/mtls/openssl.cnf -days 365
openssl req -x509 -keyout test/server/mtls/credentials/pg_rubbish_key.pem -out test/server/mtls/credentials/pg_rubbish_cert.pem -config test/server/mtls/openssl.cnf -days 365
openssl req -x509 -keyout cicd/vol/srv/credentials/pg_server_key.pem -out cicd/vol/srv/credentials/pg_server_cert.pem -config test/server/mtls/openssl.cnf -days 365
openssl req -x509 -keyout cicd/vol/srv/credentials/pg_client_key.pem -out cicd/vol/srv/credentials/pg_client_cert.pem -config test/server/mtls/openssl.cnf -days 365
openssl req -x509 -keyout cicd/vol/srv/credentials/pg_rubbish_key.pem -out cicd/vol/srv/credentials/pg_rubbish_cert.pem -config test/server/mtls/openssl.cnf -days 365
- name: Build image
run: |
docker compose -f docker-compose-credentials.yml build credentialsgen
docker compose build mockserver
- name: Build Stackql image with buildx
uses: docker/build-push-action@v5
with:
context: .
build-args: |
BUILDMAJORVERSION=${{env.BUILDMAJORVERSION}}
BUILDMINORVERSION=${{env.BUILDMINORVERSION}}
BUILDPATCHVERSION=${{env.BUILDPATCHVERSION}}
push: false
target: app
load: true
tags: stackql/stackql:${{github.sha}},stackql/stackql:v${{env.BUILDMAJORVERSION}}.${{env.BUILDMINORVERSION}}.${{env.BUILDPATCHVERSION}},stackql/stackql:latest
- name: Mock Server Download
run: |
mvn \
org.apache.maven.plugins:maven-dependency-plugin:3.0.2:copy \
-Dartifact=org.mock-server:mockserver-netty:5.12.0:jar:shaded \
-DoutputDirectory=test/downloads
- name: Debug info
run: |
echo "psql version info: $(psql --version)"
echo ""
echo "docker-compose version info: $(docker-compose -version)"
echo ""
echo "robot version info: $(robot --version)"
echo ""
echo "#### ps -ef output ####"
echo ""
ps -ef
echo ""
echo "### ###"
echo ""
echo "#### docker version output ####"
echo ""
docker version
echo ""
echo "### ###"
echo ""
echo "#### lsb_release output ####"
echo ""
lsb_release || echo "lsb_release not present"
echo ""
echo "### ###"
echo ""
echo "#### env output ####"
echo ""
env
echo ""
echo "### ###"
echo ""
- name: Run robot mocked functional tests
if: success()
timeout-minutes: 20
run: |
python cicd/python/build.py --robot-test --config='{ "variables": { "EXECUTION_PLATFORM": "docker" } }'
- name: Run POSTGRES BACKEND robot mocked functional tests
if: success()
timeout-minutes: 20
run: |
python cicd/python/build.py --robot-test --config='{ "variables": { "EXECUTION_PLATFORM": "docker", "SHOULD_RUN_DOCKER_EXTERNAL_TESTS": true, "SQL_BACKEND": "postgres_tcp" } }'
- name: Output from mocked functional tests
if: always()
run: |
cat ./test/robot/functional/output.xml
- name: Run robot integration tests
if: env.AZURE_CLIENT_SECRET != '' && startsWith(steps.git_ref_parse.outputs.SOURCE_TAG, 'build-release')
env:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_INTEGRATION_TESTING_SUB_ID: ${{ secrets.AZURE_INTEGRATION_TESTING_SUB_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
run: |
python cicd/python/build.py --robot-test-integration --config='{ "variables": { "EXECUTION_PLATFORM": "docker" } }'
- name: Login to Docker Hub
if: ${{ ( success() && github.ref_type == 'branch' && github.ref_name == 'main' && github.repository == 'stackql/stackql' && github.event_name == 'push' ) || ( success() && github.ref_type == 'tag' && startsWith(github.ref_name, 'build-release') ) }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push stackql image to Docker Hub
if: ${{ ( success() && github.ref_type == 'branch' && github.ref_name == 'main' && github.repository == 'stackql/stackql' && github.event_name == 'push' ) || ( success() && github.ref_type == 'tag' && startsWith(github.ref_name, 'build-release') ) }}
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/arm64,linux/amd64
build-args: |
BUILDMAJORVERSION=${{env.BUILDMAJORVERSION}}
BUILDMINORVERSION=${{env.BUILDMINORVERSION}}
BUILDPATCHVERSION=${{env.BUILDPATCHVERSION}}
RUN_INTEGRATION_TESTS=0
push: true
target: app
tags: stackql/stackql:${{github.sha}},stackql/stackql:v${{env.BUILDMAJORVERSION}}.${{env.BUILDMINORVERSION}}.${{env.BUILDPATCHVERSION}},stackql/stackql:latest