-
-
Notifications
You must be signed in to change notification settings - Fork 0
2028 lines (1798 loc) · 75.8 KB
/
build.yml
File metadata and controls
2028 lines (1798 loc) · 75.8 KB
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: Build
on:
push:
branches:
- main
- develop
- version*
tags:
- build*
paths-ignore:
- "**/*.md"
- "docs/**"
- "licenses/**"
- "test/python/markdown_testing/**"
- ".github/workflows/scenario.yaml"
pull_request:
branches:
- main
- develop
- version*
paths-ignore:
- "**/*.md"
- "docs/**"
- "examples/**"
- "licenses/**"
- "test/python/markdown_testing/**"
- ".github/workflows/scenario.yaml"
env:
GOTESTCMD: "go test -timeout 1200s --tags \"sqlite_stackql\" -v ./..."
TESTSCRIPT: "test/deprecated/python/main.py"
GOPRIVATE: github.com/stackql/*
GH_ACCESS_TOKEN: ${{ secrets.ACTIONS_PRIVATE_PACKAGE_SECRET }}
PLANCACHEENABLED: "false"
CI_IS_EXPRESS: ${{ github.ref_type == 'tag' && contains(github.ref_name, 'express') && 'true' || 'false' }}
STACKQL_IMAGE_NAME: ${{ vars.STACKQL_IMAGE_NAME != '' && vars.STACKQL_IMAGE_NAME || (github.repository == 'stackql/stackql' || github.repository == 'stackql/stackql-devel') && github.repository || 'stackql/stackql' }}
IS_FORK_PR: ${{ ((github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name != github.repository)) && 'true' || 'false' }}
jobs:
test_python_package_build:
# id: test_python_package_build
name: Test Python Package Build
runs-on: ubuntu-22.04
timeout-minutes: ${{ vars.DEFAULT_JOB_TIMEOUT_MIN == '' && 120 || vars.DEFAULT_JOB_TIMEOUT_MIN }}
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.12'
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 1.8.3
virtualenvs-create: true
virtualenvs-in-project: false
virtualenvs-path: ~/my-custom-path
installer-parallel: true
- name: Build package
run: |
cicd/util/01-build-robot-lib.sh
- name: Upload python package artifact
uses: actions/upload-artifact@v4.3.1
with:
name: python-package-dist-folder
path: test/dist
winbuild:
name: Windows Build
runs-on: windows-latest
timeout-minutes: ${{ vars.DEFAULT_JOB_TIMEOUT_MIN == '' && 120 || vars.DEFAULT_JOB_TIMEOUT_MIN }}
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.25.3'
check-latest: true
cache: true
id: go
- name: Setup Python
uses: actions/setup-python@v5.0.0
with:
cache: pip
python-version: '3.12'
- name: Cache Chocolatey packages
id: cache-choco
uses: actions/cache@v4
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: ${{ vars.DEFAULT_STEP_TIMEOUT_MIN == '' && 20 || vars.DEFAULT_STEP_TIMEOUT_MIN }}
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 openssl
uses: crazy-max/ghaction-chocolatey@v3.0.0
timeout-minutes: ${{ vars.DEFAULT_LONG_STEP_TIMEOUT_MIN == '' && 40 || vars.DEFAULT_LONG_STEP_TIMEOUT_MIN }}
with:
args: "install --force openssl --version 3.1.1"
- name: Choco install packages
uses: crazy-max/ghaction-chocolatey@v3.0.0
timeout-minutes: ${{ vars.DEFAULT_LONG_STEP_TIMEOUT_MIN == '' && 40 || vars.DEFAULT_LONG_STEP_TIMEOUT_MIN }}
with:
args: "install --force postgresql13 sqlite"
- name: Install Python dependencies
run: |
pip3 install -r cicd/requirements.txt
- name: Generate rewritten registry for simulations
run: |
python3 test\python\stackql_test_tooling\registry_rewrite.py --srcdir "$pwd\test\registry\src" --destdir "$pwd\test\registry-mocked\src"
- 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}}
GOOS: windows
GOARCH: amd64
GOMINGWID: 'x86_64-w64-mingw32'
run: |
# Explicitly prioritize the correct MinGW in the PATH
$mingwPath = "C:\mingw64"
if (-not (Test-Path -Path $mingwPath)) {
# Fallback to the chocolatey path, which we know exists
$mingwPath = "C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64"
}
# Use Resolve-Path to get the guaranteed absolute path
# Now that we've ensured $mingwPath isn't empty, Resolve-Path will succeed.
$mingwPath = Resolve-Path $mingwPath
$env:Path = "$mingwPath\bin;" + $env:Path
# Set CC and CXX with the fully resolved absolute path
$env:CC = "$mingwPath\bin\x86_64-w64-mingw32-gcc"
$env:CXX = "$mingwPath\bin\x86_64-w64-mingw32-g++"
echo "Current PATH:"
echo $env:PATH
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
# This creates a PowerShell function to intercept the 'go build' command
# and inject the static linker flags.
# The function calls the actual go.exe with the added arguments.
$originalGoPath = (Get-Command go.exe).Path
function go {
& $originalGoPath @args -ldflags "-linkmode external -extldflags '-static -s -w'"
}
python cicd/python/build.py --verbose --build
python cicd/python/build.py --verbose --build-mcp-client
ls ".\build"
function Copy-FileIfExists {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, HelpMessage = "The relative or absolute path of the file to be copied.")]
[string]$SourcePath,
[Parameter(Mandatory = $true, HelpMessage = "The relative or absolute path of the destination directory or file.")]
[string]$Destination
)
if (Test-Path -Path $SourcePath -PathType Leaf) {
# Check if the destination directory exists and create it if not
$destinationDir = Split-Path -Path $Destination -Parent
if (-not (Test-Path -Path $destinationDir)) {
Write-Verbose "Creating destination directory: $destinationDir"
New-Item -ItemType Directory -Path $destinationDir | Out-Null
}
# Copy the file
Write-Host "Copying '$SourcePath' to '$Destination'..."
Copy-Item -Path $SourcePath -Destination $Destination -Force -Verbose
Write-Host "Copy complete."
}
else {
Write-Warning "Source file not found: $SourcePath"
}
}
$sourcePath = ".\build\stackql"
$destinationPath = ".\build\stackql.exe"
Copy-FileIfExists -SourcePath $sourcePath -Destination $destinationPath
$mcpSourcePath = ".\build\stackql_mcp_client"
$mcpDestinationPath = ".\build\stackql_mcp_client.exe"
Copy-FileIfExists -SourcePath $mcpSourcePath -Destination $mcpDestinationPath
ls ".\build"
build\stackql.exe --help
- name: Test
if: success()
run: python cicd/python/build.py --verbose --test
- 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
env:
PSQL_EXE: C:\Program Files\PostgreSQL\13\bin\psql
SQLITE_EXE: C:\ProgramData\chocolatey\lib\SQLite\tools\sqlite3.exe
PYTHONPATH: '${{ env.PYTHONPATH }};${{ github.workspace }}\test\python'
run: |
python cicd/python/build.py --robot-test
- name: Output from mocked functional tests
if: always()
run: |
cat ./test/robot/reports/output.xml || echo "no functional test output present"
- name: Run robot integration tests
if: env.AZURE_CLIENT_SECRET != '' && startsWith(env.STATE_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 }}
PYTHONPATH: '${{ env.PYTHONPATH }};${{ github.workspace }}\test\python'
run: | #Ideally there wiuld be forced kill of flaks here but dont know how to do that in windows
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/deprecated/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-22.04
timeout-minutes: ${{ vars.DEFAULT_JOB_TIMEOUT_MIN == '' && 120 || vars.DEFAULT_JOB_TIMEOUT_MIN }}
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.25.3'
check-latest: true
cache: true
id: go
- name: Check go sum coherence
run: |
cp go.sum go.sum.bkp
sumDiff="$(diff go.sum go.sum.bkp)" || true;
if [ "$sumDiff" = "" ]; then
echo "go.sum check passed"
else
echo "go.sum is inconsistent, might be time to run 'go mod tidy' and commit";
exit 1;
fi
- name: Setup Python
uses: actions/setup-python@v5.0.0
with:
cache: pip
python-version: '3.12'
- 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/stackql_test_tooling/registry_rewrite.py --srcdir "$(pwd)/test/registry/src" --destdir "$(pwd)/test/registry-mocked/src"
- 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: Build MCP client
env:
BUILDCOMMITSHA: ${{github.sha}}
BUILDBRANCH: ${{github.ref}}
BUILDPLATFORM: ${{runner.os}}
BUILDPATCHVERSION: ${{github.run_number}}
CGO_ENABLED: 1
run: |
python cicd/python/build.py --verbose --build-mcp-client
- 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 "sqlite_stackql" --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: Upload Artifact
uses: actions/upload-artifact@v4.3.1
if: success()
with:
name: stackql_linux_amd64
path: build/stackql
- name: Upload Artifact
uses: actions/upload-artifact@v4.3.1
if: success()
with:
name: stackql_mcp_client_linux_amd64
path: build/stackql_mcp_client
- name: prepare deb boilerplate
run: |
mkdir -p .debpkg/usr/bin
cp -p build/stackql .debpkg/usr/bin/
- uses: jiro4989/build-deb-action@v3
name: build deb package
with:
package: stackql
package_root: .debpkg
maintainer: stackql
version: ${{env.BUILDMAJORVERSION}}.${{env.BUILDMINORVERSION}}.${{env.BUILDPATCHVERSION}}
arch: 'amd64'
# depends: 'libc6 (>= 2.2.1), git'
desc: 'stackql treats the internet as a relational database'
homepage: 'https://stackql.io'
- name: Upload deb Artifact
uses: actions/upload-artifact@v4.3.1
if: success()
with:
name: amd64-artifact-deb
path: |
./*.deb
linuxtest:
name: Linux Test
needs:
- linuxbuild
- test_python_package_build
runs-on: ubuntu-22.04
strategy:
matrix:
registry:
- test/registry-mocked
- test/registry
timeout-minutes: ${{ vars.DEFAULT_JOB_TIMEOUT_MIN == '' && 120 || vars.DEFAULT_JOB_TIMEOUT_MIN }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4.1.1
- name: Download Artifact
uses: actions/download-artifact@v4.1.2
with:
name: stackql_linux_amd64
path: build
- name: Download Artifact
uses: actions/download-artifact@v4.1.2
with:
name: stackql_mcp_client_linux_amd64
path: build
- name: Download deb Artifact
uses: actions/download-artifact@v4.1.2
with:
name: amd64-artifact-deb
path: .
- name: Check archive presence
run: |
ls -al .
- name: Stackql permissions
run: |
sudo chmod a+rwx build/stackql
sudo chmod a+rwx build/stackql_mcp_client
ls -al build/stackql
ls -al build/stackql_mcp_client
ls -al .
- name: Set up Go 1.x
uses: actions/setup-go@v5.0.0
with:
go-version: '1.25.3'
check-latest: true
cache: true
id: go
- name: Setup Python
uses: actions/setup-python@v5.0.0
with:
cache: pip
python-version: '3.12'
- name: Download python package dist folder
uses: actions/download-artifact@v4.1.2
with:
name: python-package-dist-folder
path: test/dist
- name: Install python testing package
run: |
echo "Inspecting python package"
for file in test/dist/*.whl; do
pip3 install "$file" --force-reinstall
done
- 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: Generate Version Env Vars
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}"
if [ "${{ matrix.registry }}" = "test/registry" ]; then
python3 test/python/stackql_test_tooling/tcp_lb.py --generate-hosts-entries | sudo tee -a /etc/hosts
python3 test/python/stackql_test_tooling/tcp_lb.py --generate-nginx-lb > test/tcp/reverse-proxy/nginx/dynamic-sni-proxy.conf
fi
- name: Install testing dependencies
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends postgresql-client
if [ "${{ matrix.registry }}" = "test/registry" ]; then
sudo apt-get install -y curl gnupg2 ca-certificates lsb-release ubuntu-keyring
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/ubuntu $(lsb_release -cs) nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
sudo apt-get update
sudo apt-get install nginx
sudo nginx -c "$(pwd)/test/tcp/reverse-proxy/nginx/dynamic-sni-proxy.conf"
fi
- name: Install Python dependencies
run: |
pip3 install -r cicd/requirements.txt
- id: install-aws-cli
uses: unfor19/install-aws-cli-action@v1
with:
version: 2 # default
verbose: false # default
arch: amd64 # allowed values: amd64, x86, x64, arm, arm64
- 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 traffic light robot integration tests
if: ((startsWith(github.ref_name, 'build-traffic-lights') && github.ref_type == 'tag') || (github.repository == 'stackql/stackql' && github.event_name == 'push' && github.ref == 'refs/heads/main')) && matrix.registry == 'test/registry'
env:
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
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 }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GODEBUG: netdns=go
run: |
## positive control with aws cli
foundAwsBucketCiontents="$(aws s3 ls s3://stackql-trial-bucket-02 --region ap-southeast-2)"
echo "Found aws s3 bucket contents: $foundAwsBucketCiontents"
if [ "$foundAwsBucketCiontents" == "" ]; then
echo "ℹ️ AWS CLI access to S3 bucket failed"
else
echo "ℹ️ AWS CLI access to S3 bucket succeeded"
fi
echo "## Stray flask apps to be killed before robot tests ##"
pgrep -f flask | xargs kill -9 || true
echo "## End ##"
if python cicd/python/build.py --robot-test-traffic-lights-integration; then
echo "✅ Traffic light robot integration tests **all** passed"
else
rv="$?"
echo "🟡 **some** traffic light robot integration tests failed code = $rv"
fi
{
echo "TRAFFIC_LIGHTS_COMPLETED=true"
} >> "$GITHUB_ENV"
- name: Output from traffic lights integration tests
if: env.TRAFFIC_LIGHTS_COMPLETED == 'true'
run: |
cat ./test/robot/reports-integration-traffic-lights/output.xml || true
- name: Output from traffic lights tmp dir
if: env.TRAFFIC_LIGHTS_COMPLETED == 'true'
run: |
cat ./test/robot/integration-traffic-lights/tmp/* || true
- name: Generate rewritten registry for simulations
if: ${{ matrix.registry != 'test/registry' }}
run: |
python3 test/python/stackql_test_tooling/registry_rewrite.py --srcdir "$(pwd)/test/registry/src" --destdir "$(pwd)/test/registry-mocked/src"
- 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
env:
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
if: success()
run: |
if [ "${{ matrix.registry }}" = "test/registry" ]; then
robot \
--variable 'SUNDRY_CONFIG:{"registry_path": "test/registry"}' \
--variable SHOULD_RUN_DOCKER_EXTERNAL_TESTS:true \
--include tls_proxied \
-d test/robot/reports \
test/robot/functional
else
python cicd/python/build.py --robot-test --config='{ "variables": { "SHOULD_RUN_DOCKER_EXTERNAL_TESTS": "true" } }'
fi
- name: Output from mocked functional tests
if: always()
run: |
cat ./test/robot/reports/output.xml
- name: Run robot mocked functional tests with aggressive concurrency
if: success() && matrix.registry != 'test/registry'
run: |
echo "## Stray flask apps to be killed before robot tests ##"
pgrep -f flask | xargs kill -9 || true
echo "## End ##"
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() && matrix.registry != 'test/registry'
run: |
cat ./test/robot/reports/output.xml
- name: Run robot integration tests
if: env.AZURE_CLIENT_SECRET != '' && startsWith(env.STATE_SOURCE_TAG, 'build-release') && matrix.registry != 'test/registry'
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: |
echo "## Stray flask apps to be killed before robot tests ##"
pgrep -f flask | xargs kill -9 || true
echo "## End ##"
python cicd/python/build.py --robot-test-integration
- name: Prepare Test DB
if: success() && matrix.registry != 'test/registry'
run: cp test/db/db.sqlite test/db/tmp/python-tests-tmp-db.sqlite
- name: Test Script
if: success() && matrix.registry != 'test/registry'
run: python3 "${TESTSCRIPT}"
env:
TESTSCRIPT: ${{env.TESTSCRIPT}}
- name: install and test deb package
if: matrix.registry != 'test/registry'
env:
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
IS_SKIP_MCP_TEST: 'true'
run: |
mkdir -p deb_test
cp stackql_${{env.BUILDMAJORVERSION}}.${{env.BUILDMINORVERSION}}.${{env.BUILDPATCHVERSION}}_amd64.deb deb_test/
sudo dpkg -i ./deb_test/stackql_${{env.BUILDMAJORVERSION}}.${{env.BUILDMINORVERSION}}.${{env.BUILDPATCHVERSION}}_amd64.deb
sudo apt-get install -f
echo "## Stray flask apps to be killed before robot tests ##"
pgrep -f flask | xargs kill -9 || true
echo "## End ##"
python cicd/python/build.py --robot-test --config='{ "variables": { "SHOULD_RUN_DOCKER_EXTERNAL_TESTS": "true", "CONCURRENCY_LIMIT": -1, "USE_STACKQL_PREINSTALLED": "true" } }'
stackqlLocation="$(which stackql 2>&1 | head -n 1)"
stackqlVersion="$(stackql --version 2>&1 | head -n 1)"
echo "stackql location: ${stackqlLocation}"
echo "stackql version: ${stackqlVersion}"
- name: Output from mocked deb package functional tests
if: always() && matrix.registry != 'test/registry'
env:
PYTHONPATH: '${{ env.PYTHONPATH }}:${{ github.workspace }}/test/python'
run: |
cat ./test/robot/reports/output.xml
linuxarmbuild:
name: Linux arm64 Build
runs-on: arm-ubuntu-22-04-runner-one
timeout-minutes: ${{ vars.DEFAULT_JOB_TIMEOUT_MIN == '' && 120 || vars.DEFAULT_JOB_TIMEOUT_MIN }}
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.25.3'
check-latest: true
cache: true
id: go
- name: Setup Python
uses: actions/setup-python@v5.0.0
with:
cache: pip
python-version: '3.12'
- 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: Install psql
run: |
sudo apt-get update
sudo apt-get install --yes build-essential
sudo apt-get install --yes --no-install-recommends postgresql-client
gccVersion="$(gcc --version 2>&1 | head -n 1)"
echo "gcc version: ${gccVersion}"
- name: Install Python dependencies
run: |
pip3 install -r cicd/requirements.txt
- name: Generate rewritten registry for simulations
run: |
python3 test/python/stackql_test_tooling/registry_rewrite.py --srcdir "$(pwd)/test/registry/src" --destdir "$(pwd)/test/registry-mocked/src"
- 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: Build MCP client
env:
BUILDCOMMITSHA: ${{github.sha}}
BUILDBRANCH: ${{github.ref}}
BUILDPLATFORM: ${{runner.os}}
BUILDPATCHVERSION: ${{github.run_number}}
CGO_ENABLED: 1
run: |
python cicd/python/build.py --verbose --build-mcp-client
- 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 "sqlite_stackql" --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: Create certificates for robot tests
run: |