-
Notifications
You must be signed in to change notification settings - Fork 131
1065 lines (971 loc) · 49.6 KB
/
Copy pathprerelease.yml
File metadata and controls
1065 lines (971 loc) · 49.6 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: "Pre-Release"
on:
push:
branches: ["main*"]
pull_request:
branches: ["main*"]
env:
BUILD_TYPE: Release
GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
PYTHON_VERSION: 3.13
SWIFT_VERSION: 6.2
PYTHONUTF8: 1
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
jobs:
versioning:
name: Update Version
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true
persist-credentials: false
- name: Run TinySemVer
uses: ashvardanian/tinysemver@v3.0.1
with:
verbose: "true"
version-file: "VERSION"
update-version-in: |
Cargo.toml:^version = "(\d+\.\d+\.\d+)"
package.json:"version": "(\d+\.\d+\.\d+)"
CMakeLists.txt:VERSION (\d+\.\d+\.\d+)
update-major-version-in: |
include/stringzilla/stringzilla.h:^#define STRINGZILLA_H_VERSION_MAJOR (\d+)
update-minor-version-in: |
include/stringzilla/stringzilla.h:^#define STRINGZILLA_H_VERSION_MINOR (\d+)
update-patch-version-in: |
include/stringzilla/stringzilla.h:^#define STRINGZILLA_H_VERSION_PATCH (\d+)
dry-run: "true"
test_ubuntu_gcc:
name: Ubuntu GCC 12 - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-22.04-arm]
env:
CC: gcc-12
CXX: g++-12
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Log hardware capabilities
run: |
echo "────────────────────────────────────────────────────────────────"
echo "Hardware Capabilities"
echo "────────────────────────────────────────────────────────────────"
lscpu
echo ""
echo "CPU Info:"
grep -E "model name|flags" /proc/cpuinfo | head -5 || true
echo "────────────────────────────────────────────────────────────────"
# C/C++
# If the compilation fails, we want to log the compilation commands in addition to
# the standard output.
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y cmake build-essential gcc-12 g++-12
- name: Build C/C++
run: |
cmake -B build_artifacts \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DSTRINGZILLA_BUILD_BENCHMARK=1 \
-DSTRINGZILLA_BUILD_TEST=1
cmake --build build_artifacts --config RelWithDebInfo > build_artifacts/logs.txt 2>&1 || {
echo "Compilation failed. Here are the logs:"
cat build_artifacts/logs.txt
echo "The original compilation commands:"
cat build_artifacts/compile_commands.json
echo "GCC Version:"
gcc-12 --version
echo "G++ Version:"
g++-12 --version
exit 1
}
- name: Test C++
run: build_artifacts/stringzilla_test_cpp20
- name: Check stringzilla_bare is built correctly
run: test -z "$(ldd build_artifacts/libstringzilla_bare.so | grep '.so')"
- name: Build shared library for Go binding
run: |
cmake -B build_shared -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSTRINGZILLA_BUILD_SHARED=1
cmake --build build_shared --target stringzilla_shared --config RelWithDebInfo
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ">=1.24"
cache: false
- name: Test Go binding
working-directory: golang
env:
LD_LIBRARY_PATH: ${{ github.workspace }}/build_shared
run: go test -v -tags no_sha256 # Skip SHA tests for GCC
- name: Test on Real World Data
run: |
build_artifacts/stringzilla_bench_memory_cpp20 ${DATASET_PATH} # for string copies and fills
build_artifacts/stringzilla_bench_find_cpp20 ${DATASET_PATH} # for substring search
build_artifacts/stringzilla_bench_token_cpp20 ${DATASET_PATH} # for hashing, equality comparisons, etc.
build_artifacts/stringzilla_bench_sequence_cpp20 ${DATASET_PATH} # for sorting arrays of strings
build_artifacts/stringzilla_bench_container_cpp20 ${DATASET_PATH} # for STL containers with string keys
env:
DATASET_PATH: ./README.md
# Don't overload GitHub with our benchmarks.
# The results in such an unstable environment will be meaningless anyway.
if: 0
- name: Test Parallel Algorithms on Real World Data
run: |
build_artifacts/stringzillas_bench_similarities_cpp20 ${DATASET_PATH} # for edit distances and alignment scores
build_artifacts/stringzillas_bench_fingerprints_cpp20 ${DATASET_PATH} # for multi-needle search in many strings
env:
DATASET_PATH: ./README.md
# Don't overload GitHub with our benchmarks.
# The results in such an unstable environment will be meaningless anyway.
if: 0
# Python
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v6.2.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Build Python
run: |
python -m pip install --upgrade pip
pip install pytest pytest-repeat numpy pyarrow
python -m pip install .
- name: Log Python capabilities
run: |
python - << 'PY'
import platform
import stringzilla as sz
print("platform:", platform.platform())
print("machine:", platform.machine(), "processor:", platform.processor())
print("stringzilla.__capabilities__:", sz.__capabilities__)
PY
- name: Test Python
run: python -X faulthandler -m pytest test/ --ignore=test/stringzillas.py -s -vv --maxfail=1 --full-trace
# JavaScript
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 22
- name: Build and test JavaScript
run: npm install && npm test
# Rust
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Test Rust with dynamic dispatch
run: cargo test --release
- name: Test Rust with compile-time dispatch
run: cargo test --release --no-default-features --features std
test_ubuntu_clang:
name: Ubuntu Clang 16 - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-22.04-arm]
env:
CC: clang-16
CXX: clang++-16
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Log hardware capabilities
run: |
echo "────────────────────────────────────────────────────────────────"
echo "Hardware Capabilities"
echo "────────────────────────────────────────────────────────────────"
lscpu
echo ""
echo "CPU Info:"
grep -E "model name|flags" /proc/cpuinfo | head -5 || true
echo "────────────────────────────────────────────────────────────────"
# C/C++
# Clang 16 isn't available from default repos on Ubuntu 22.04, so we have to install it manually
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y cmake build-essential libjemalloc-dev
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 16
- name: Build C/C++
run: |
cmake -B build_artifacts \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DSTRINGZILLA_BUILD_BENCHMARK=1 \
-DSTRINGZILLA_BUILD_TEST=1
cmake --build build_artifacts --config RelWithDebInfo > build_artifacts/logs.txt 2>&1 || {
echo "Compilation failed. Here are the logs:"
cat build_artifacts/logs.txt
echo "The original compilation commands:"
cat build_artifacts/compile_commands.json
echo "Clang Version:"
clang-16 --version
echo "Clang++ Version:"
clang++-16 --version
exit 1
}
- name: Test C++
run: build_artifacts/stringzilla_test_cpp20
- name: Check stringzilla_bare is built correctly
run: test -z "$(ldd build_artifacts/libstringzilla_bare.so | grep '.so')"
- name: Build shared library for Go binding
run: |
cmake -B build_shared -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSTRINGZILLA_BUILD_SHARED=1
cmake --build build_shared --target stringzilla_shared --config RelWithDebInfo
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ">=1.24"
cache: false
- name: Test Go binding
working-directory: golang
env:
LD_LIBRARY_PATH: ${{ github.workspace }}/build_shared
run: go test -v
- name: Test on Real World Data
run: |
build_artifacts/stringzilla_bench_find_cpp20 ${DATASET_PATH} # for substring search
build_artifacts/stringzilla_bench_token_cpp20 ${DATASET_PATH} # for hashing, equality comparisons, etc.
build_artifacts/stringzilla_bench_sequence_cpp20 ${DATASET_PATH} # for sorting arrays of strings
build_artifacts/stringzilla_bench_container_cpp20 ${DATASET_PATH} # for STL containers with string keys
env:
DATASET_PATH: ./README.md
# Don't overload GitHub with our benchmarks.
# The results in such an unstable environment will be meaningless anyway.
if: 0
# Python
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v6.2.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Build Python
run: |
python -m pip install --upgrade pip
pip install pytest pytest-repeat numpy pyarrow
python -m pip install .
- name: Log Python capabilities
run: |
python - << 'PY'
import platform
import stringzilla as sz
print("platform:", platform.platform())
print("machine:", platform.machine(), "processor:", platform.processor())
print("stringzilla.__capabilities__:", sz.__capabilities__)
PY
- name: Test Python
run: python -X faulthandler -m pytest test/ --ignore=test/stringzillas.py -s -vv --maxfail=1 --full-trace
# Rust
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Test Rust with parallel engines
run: cargo test --release --features cpus
- name: Test Rust with compile-time dispatch
run: cargo test --release --no-default-features --features std
# Swift
# Fails due to: https://github.com/swift-actions/setup-swift/issues/591
# - name: Set up Swift ${{ env.SWIFT_VERSION }}
# uses: swift-actions/setup-swift@v2.4.0
# with:
# swift-version: ${{ env.SWIFT_VERSION }}
# - name: Build Swift
# run: swift build -c release --static-swift-stdlib
# - name: Test Swift
# run: swift test -c release
test_ubuntu_cpus:
name: Ubuntu StringZillas-CPUs
runs-on: ubuntu-22.04
env:
CC: gcc-12
CXX: g++-12
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Log hardware capabilities
run: |
echo "────────────────────────────────────────────────────────────────"
echo "Hardware Capabilities"
echo "────────────────────────────────────────────────────────────────"
lscpu
echo ""
echo "CPU Info:"
grep -E "model name|flags" /proc/cpuinfo | head -5 || true
echo "────────────────────────────────────────────────────────────────"
# C/C++
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y cmake build-essential gcc-12 g++-12
- name: Build C/C++
run: |
cmake -B build_artifacts \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DSTRINGZILLA_BUILD_BENCHMARK=1 \
-DSTRINGZILLA_BUILD_TEST=1
cmake --build build_artifacts --config RelWithDebInfo > build_artifacts/logs.txt 2>&1 || {
echo "Compilation failed. Here are the logs:"
cat build_artifacts/logs.txt
echo "The original compilation commands:"
cat build_artifacts/compile_commands.json
echo "GCC Version:"
gcc-12 --version
echo "G++ Version:"
g++-12 --version
exit 1
}
- name: Test C++
run: build_artifacts/stringzilla_test_cpp20
- name: Check stringzilla_bare is built correctly
run: test -z "$(ldd build_artifacts/libstringzilla_bare.so | grep '.so')"
# Python StringZillas-CPUs
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v6.2.0
with:
python-version: ${{ env.PYTHON_VERSION }}
# Ensure modern build backend is available for editable installs
- name: Build Python StringZillas-CPUs
run: |
python -m pip install --upgrade pip
pip install "setuptools>=64" wheel
pip install pytest pytest-repeat numpy pyarrow affine-gaps
SZ_TARGET=stringzilla pip install -e . --force-reinstall --no-build-isolation
SZ_TARGET=stringzillas-cpus pip install -e . --force-reinstall --no-build-isolation
- name: Log Python capabilities
run: |
python - << 'PY'
import platform
import stringzilla as sz
import stringzillas as szs
print("platform:", platform.platform())
print("machine:", platform.machine(), "processor:", platform.processor())
print("stringzilla.__capabilities__:", sz.__capabilities__)
print("stringzillas.__capabilities__:", szs.__capabilities__)
PY
- name: Test Python StringZillas-CPUs
run: python -X faulthandler -m pytest test/stringzillas.py test/doctests.py -s -vv --maxfail=1 --full-trace
test_ubuntu_cuda:
name: Ubuntu StringZillas-CUDA
runs-on: ubuntu-22.04
env:
CC: gcc-12
CXX: g++-12
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
# Install CUDA Toolkit
- name: Install CUDA Toolkit
uses: Jimver/cuda-toolkit@v0.2.35
with:
cuda: "12.9.1"
method: "network"
- name: Log hardware capabilities
run: |
echo "────────────────────────────────────────────────────────────────"
echo "Hardware Capabilities"
echo "────────────────────────────────────────────────────────────────"
lscpu
echo ""
echo "CPU Info:"
grep -E "model name|flags" /proc/cpuinfo | head -5 || true
echo ""
echo "GPU Info:"
nvcc --version 2>/dev/null || echo "nvcc not yet installed"
nvidia-smi 2>/dev/null || echo "nvidia-smi not yet available"
echo "────────────────────────────────────────────────────────────────"
# C/C++
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y cmake build-essential gcc-12 g++-12
- name: Build C/C++ with CUDA
run: |
# Note: Using Release build type instead of RelWithDebInfo
# Optimized debugging not supported in CUDA and results in PTXAS fatal errors
cmake -B build_artifacts \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DSTRINGZILLA_BUILD_BENCHMARK=1 \
-DSTRINGZILLA_BUILD_TEST=1
cmake --build build_artifacts --config Release > build_artifacts/logs.txt 2>&1 || {
echo "Compilation failed. Here are the logs:"
cat build_artifacts/logs.txt
echo "The original compilation commands:"
cat build_artifacts/compile_commands.json
echo "CUDA Version:"
nvcc --version
echo "GCC Version:"
gcc-12 --version
echo "G++ Version:"
g++-12 --version
exit 1
}
- name: Test C++
run: build_artifacts/stringzilla_test_cpp20
- name: Check stringzilla_bare is built correctly
run: test -z "$(ldd build_artifacts/libstringzilla_bare.so | grep '.so')"
# Python StringZillas-CUDA
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v6.2.0
with:
python-version: ${{ env.PYTHON_VERSION }}
# Ensure modern build backend is available for editable installs
- name: Build Python StringZillas-CUDA
run: |
python -m pip install --upgrade pip
pip install "setuptools>=64" wheel
pip install pytest pytest-repeat numpy pyarrow wheel affine-gaps
SZ_TARGET=stringzilla pip install -e . --force-reinstall --no-build-isolation
SZ_TARGET=stringzillas-cuda pip install -e . --force-reinstall --no-build-isolation
- name: Log Python capabilities
run: |
python - << 'PY'
import platform
import stringzilla as sz
import stringzillas as szs
print("platform:", platform.platform())
print("machine:", platform.machine(), "processor:", platform.processor())
print("stringzilla.__capabilities__:", sz.__capabilities__)
print("stringzillas.__capabilities__:", szs.__capabilities__)
PY
- name: Test Python StringZillas-CUDA
run: python -X faulthandler -m pytest test/stringzillas.py test/doctests.py -s -vv --maxfail=1 --full-trace
# Temporary workaround to run Swift tests on Linux
# Based on: https://github.com/swift-actions/setup-swift/issues/591#issuecomment-1685710678
test_ubuntu_swift:
name: Swift on Linux
runs-on: ubuntu-22.04
container: swift:latest
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Log hardware capabilities
run: |
echo "────────────────────────────────────────────────────────────────"
echo "Hardware Capabilities"
echo "────────────────────────────────────────────────────────────────"
lscpu || true
echo ""
echo "CPU Info:"
grep -E "model name|flags" /proc/cpuinfo | head -5 || true
echo "────────────────────────────────────────────────────────────────"
- name: Test Swift
run: swift test
test_ubuntu_dotnet:
name: C# on Linux
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install build tools
run: |
sudo apt update
sudo apt install -y cmake build-essential
- name: Build shared library
run: |
cmake -B build_shared -DCMAKE_BUILD_TYPE=Release -DSTRINGZILLA_BUILD_SHARED=1
cmake --build build_shared --target stringzilla_shared --config Release
# The runtime resolver probes runtimes/{rid}/native first; the shared target emits
# libstringzilla_shared.so, so copy it under the name the binding looks up.
- name: Stage native library
run: |
mkdir -p csharp/runtimes/linux-x64/native
cp -L build_shared/libstringzilla_shared.so csharp/runtimes/linux-x64/native/libstringzilla.so
- name: Set up .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
- name: Check formatting
run: |
dotnet format StringZilla.csproj --verify-no-changes
dotnet format csharp/StringZillaTests.csproj --verify-no-changes
- name: Test C#
run: dotnet test csharp/StringZillaTests.csproj -c Release --nologo
test_ubuntu_java:
name: Java on Linux
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install build tools
run: |
sudo apt update
sudo apt install -y cmake build-essential
- name: Build shared library
run: |
cmake -B build_shared -DCMAKE_BUILD_TYPE=Release -DSTRINGZILLA_BUILD_SHARED=1
cmake --build build_shared --target stringzilla_shared --config Release
# NativeLoader extracts /native/{os}-{arch}/libstringzilla.so from the classpath at runtime;
# Maven copies src/main/resources into target/classes before the tests run.
- name: Stage native library
run: |
mkdir -p java/src/main/resources/native/linux-x86_64
cp -L build_shared/libstringzilla_shared.so java/src/main/resources/native/linux-x86_64/libstringzilla.so
# JDK 23: finalized Foreign Function & Memory API (since 22) and Palantir Java Format (needs <= 23).
- name: Set up JDK
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "23"
cache: maven
- name: Check formatting
run: mvn -B spotless:check
- name: Test Java
run: mvn -B test
# Cross-compile the static test executables once per target architecture and publish them as artifacts. The
# actual execution under QEMU happens in `test_cross_qemu`, which fans the vector-length-agnostic RISC-V
# binary across several VLENs WITHOUT recompiling it.
test_cross_linux:
name: Cross Compile ${{ matrix.arch }} to ${{ matrix.target_arch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
arch: x86-64
target_arch: aarch64
target: aarch64-linux-gnu
target_processor: arm64
cflags: ""
file_id: aarch64 # substring `file` prints for this ELF
- os: ubuntu-24.04-arm
arch: aarch64
target_arch: x86-64
target: x86_64-linux-gnu
target_processor: amd64
cflags: ""
file_id: x86-64
- os: ubuntu-24.04
arch: x86-64
target_arch: riscv64
target: riscv64-linux-gnu
target_processor: riscv64
cflags: "-march=rv64gcv"
file_id: RISC-V # `file` prints "UCB RISC-V", not "riscv64"
env:
CC: clang-20
CXX: clang++-20
AR: llvm-ar-20
NM: llvm-nm-20
RANLIB: llvm-ranlib-20
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Log hardware capabilities
run: |
echo "────────────────────────────────────────────────────────────────"
echo "Cross-Compilation: ${{ matrix.arch }} → ${{ matrix.target_arch }}"
echo "────────────────────────────────────────────────────────────────"
lscpu
echo ""
echo "CPU Info:"
grep -E "model name|flags" /proc/cpuinfo | head -5 || true
echo "────────────────────────────────────────────────────────────────"
- name: Install cross-compilation toolchain
run: |
sudo apt-get update
sudo apt-get install -y make build-essential crossbuild-essential-${{ matrix.target_processor }}
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 20
- name: Build C/C++ for ${{ matrix.target_arch }}
run: |
# Static-link the test/benchmark executables so QEMU user-mode can run them without juggling the
# cross dynamic loader + sysroot library paths. `clang` drives the GNU linker directly and does not
# add `-lstdc++` on its own, so we point it at the cross libstdc++ and pull it in explicitly.
gcc_libdir=$(dirname "$(find /usr/lib/gcc-cross/${{ matrix.target }} -name 'libstdc++.a' 2>/dev/null | head -1)")
cmake -B build_artifacts \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DCMAKE_C_COMPILER_TARGET=${{ matrix.target }} \
-DCMAKE_CXX_COMPILER_TARGET=${{ matrix.target }} \
-DCMAKE_SYSTEM_NAME=Linux \
-DCMAKE_SYSTEM_PROCESSOR=${{ matrix.target_processor }} \
-DCMAKE_C_FLAGS="${{ matrix.cflags }}" \
-DCMAKE_CXX_FLAGS="${{ matrix.cflags }}" \
-DCMAKE_EXE_LINKER_FLAGS="-static -L${gcc_libdir} -lstdc++ -lm" \
-DSTRINGZILLA_BUILD_SHARED=1 \
-DSTRINGZILLA_BUILD_BENCHMARK=1 \
-DSTRINGZILLA_BUILD_TEST=1
cmake --build build_artifacts --config RelWithDebInfo
- name: Verify ${{ matrix.target_arch }} binaries
run: |
test -e build_artifacts/libstringzilla_bare.so
test -e build_artifacts/libstringzilla_shared.so
test -e build_artifacts/stringzilla_test_cpp20
file build_artifacts/stringzilla_test_cpp20 | grep -q "${{ matrix.file_id }}"
echo "✓ ${{ matrix.target_arch }} binaries built successfully"
- name: Upload ${{ matrix.target_arch }} test binaries
uses: actions/upload-artifact@v4
with:
name: cross-tests-${{ matrix.target_arch }}
path: build_artifacts/stringzilla*_test_*
if-no-files-found: error
retention-days: 1
# Run the cross-compiled (static) test binaries under QEMU user-mode. Build-and-verify alone never exercised
# the SIMD kernels. Each row is its own pass/fail status; RVV/SVE are vector-length-agnostic, so the RISC-V
# binary built once above is swept across VLEN 128/256/512 here (`-cpu rv64,v=true,vlen=N`) with no rebuild —
# a single width under-tests VLA code.
test_cross_qemu:
name: QEMU Tests ${{ matrix.target_arch }}${{ matrix.variant }}
needs: test_cross_linux
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
# ARM is vector-length-agnostic under SVE just like RISC-V, so the one binary is run NEON-only
# (`sve=off`, else dynamic dispatch always prefers SVE2 and NEON is never exercised) plus SVE at
# 128/256/512-bit (`sve-max-vq` = VL/128).
- target_arch: aarch64
qemu: qemu-aarch64-static
qemu_cpu: "max,sve=off"
variant: " @ neon"
- target_arch: aarch64
qemu: qemu-aarch64-static
qemu_cpu: "max,sve-max-vq=1"
variant: " @ sve=128"
- target_arch: aarch64
qemu: qemu-aarch64-static
qemu_cpu: "max,sve-max-vq=2"
variant: " @ sve=256"
- target_arch: aarch64
qemu: qemu-aarch64-static
qemu_cpu: "max,sve-max-vq=4"
variant: " @ sve=512"
- target_arch: x86-64
qemu: qemu-x86_64-static
qemu_cpu: max
variant: ""
- target_arch: riscv64
qemu: qemu-riscv64-static
qemu_cpu: "rv64,v=true,vlen=128"
variant: " @ vlen=128"
- target_arch: riscv64
qemu: qemu-riscv64-static
qemu_cpu: "rv64,v=true,vlen=256"
variant: " @ vlen=256"
- target_arch: riscv64
qemu: qemu-riscv64-static
qemu_cpu: "rv64,v=true,vlen=512"
variant: " @ vlen=512"
steps:
- name: Install QEMU user-mode
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Download ${{ matrix.target_arch }} test binaries
uses: actions/download-artifact@v4
with:
name: cross-tests-${{ matrix.target_arch }}
path: tests
- name: Run tests under QEMU for ${{ matrix.target_arch }}${{ matrix.variant }}
timeout-minutes: 150
env:
# User-mode emulation runs the fuzz loops 20-40x slower than native hardware; the full
# iteration budget needs over six hours per variant and the jobs die at the runner
# timeout without ever reaching the later test families. A scaled-down budget still
# sweeps every backend and vector length within the job limits.
SZ_TESTS_MULTIPLIER: "0.05"
run: |
set -euo pipefail
chmod +x tests/*
for test_binary in $(find tests -type f -name 'stringzilla*_test_*' | sort); do
echo "▶ ${{ matrix.qemu }} -cpu ${{ matrix.qemu_cpu }} ${test_binary}"
${{ matrix.qemu }} -cpu "${{ matrix.qemu_cpu }}" "${test_binary}"
done
test_wasm:
name: WebAssembly wasm32-wasip1
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install WASI SDK
run: |
WASI_VERSION_FULL=25.0
curl -sSL "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/wasi-sdk-${WASI_VERSION_FULL}-x86_64-linux.tar.gz" \
| tar xz -C "$HOME"
echo "WASI_SDK_PATH=$HOME/wasi-sdk-${WASI_VERSION_FULL}-x86_64-linux" >> "$GITHUB_ENV"
- name: Install Wasmtime
run: |
curl https://wasmtime.dev/install.sh -sSf | bash
echo "$HOME/.wasmtime/bin" >> "$GITHUB_PATH"
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasip1
# The C kernels need the WASI SDK clang + sysroot; `build.rs` passes `-msimd128` (+ probed
# `-mrelaxed-simd`). Tests run under Wasmtime via the `.cargo/config.toml` runner, single-threaded
# (wasm32-wasip1 has no threads).
- name: Test Rust with relaxed SIMD128
env:
CC_wasm32_wasip1: ${{ env.WASI_SDK_PATH }}/bin/clang
AR_wasm32_wasip1: ${{ env.WASI_SDK_PATH }}/bin/llvm-ar
CFLAGS_wasm32_wasip1: --sysroot=${{ env.WASI_SDK_PATH }}/share/wasi-sysroot
run: |
cargo build --target wasm32-wasip1
cargo test --release --target wasm32-wasip1 -- --test-threads=1
- name: Test Rust with baseline SIMD128
env:
CC_wasm32_wasip1: ${{ env.WASI_SDK_PATH }}/bin/clang
AR_wasm32_wasip1: ${{ env.WASI_SDK_PATH }}/bin/llvm-ar
CFLAGS_wasm32_wasip1: --sysroot=${{ env.WASI_SDK_PATH }}/share/wasi-sysroot
SZ_USE_V128RELAXED: "0"
run: cargo test --release --target wasm32-wasip1 -- --test-threads=1
test_macos:
name: MacOS
runs-on: macos-15
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Log hardware capabilities
run: |
echo "────────────────────────────────────────────────────────────────"
echo "Hardware Capabilities"
echo "────────────────────────────────────────────────────────────────"
sysctl -a | grep machdep.cpu || true
echo ""
echo "System Info:"
system_profiler SPHardwareDataType || true
echo "────────────────────────────────────────────────────────────────"
# C/C++
- name: Install dependencies
run: |
brew update
brew reinstall cmake
- name: Build C/C++
run: |
cmake -B build_artifacts \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
-DSTRINGZILLA_BUILD_BENCHMARK=1 \
-DSTRINGZILLA_BUILD_TEST=1
cmake --build build_artifacts --config RelWithDebInfo
- name: Test C++
run: build_artifacts/stringzilla_test_cpp17
- name: Test on Real World Data
run: |
build_artifacts/stringzilla_bench_find_cpp20 ${DATASET_PATH} # for substring search
build_artifacts/stringzilla_bench_token_cpp20 ${DATASET_PATH} # for hashing, equality comparisons, etc.
build_artifacts/stringzilla_bench_sequence_cpp20 ${DATASET_PATH} # for sorting arrays of strings
build_artifacts/stringzilla_bench_container_cpp20 ${DATASET_PATH} # for STL containers with string keys
env:
DATASET_PATH: ./README.md
# Don't overload GitHub with our benchmarks.
# The results in such an unstable environment will be meaningless anyway.
if: 0
# Python
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v6.2.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Build Python
run: |
python -m pip install --upgrade pip
pip install pytest pytest-repeat numpy pyarrow
python -m pip install .
env:
MACOSX_DEPLOYMENT_TARGET: "11.0"
- name: Test Python
run: python -X faulthandler -m pytest test/ --ignore=test/stringzillas.py -s -vv --maxfail=1 --full-trace
# Swift
- name: Set up Swift ${{ env.SWIFT_VERSION }}
uses: swift-actions/setup-swift@v2.4.0
with:
swift-version: ${{ env.SWIFT_VERSION }}
- name: Build Swift
run: swift build
- name: Test Swift
run: swift test
# Rust
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Test Rust with dynamic dispatch
run: cargo test --release
- name: Test Rust with compile-time dispatch
run: cargo test --release --no-default-features --features std
test_windows:
name: Windows - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
arch: x64
- os: windows-11-arm
arch: arm64
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- name: Log hardware capabilities
shell: powershell
run: |
Write-Host "────────────────────────────────────────────────────────────────"
Write-Host "Hardware Capabilities"
Write-Host "────────────────────────────────────────────────────────────────"
Get-CimInstance -ClassName Win32_Processor | Select-Object Name, NumberOfCores, NumberOfLogicalProcessors, MaxClockSpeed | Format-List
Write-Host "────────────────────────────────────────────────────────────────"
- name: Build C/C++
shell: cmd
run: |
cmake -GNinja -B build_artifacts ^
-DCMAKE_BUILD_TYPE=RelWithDebInfo ^
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 ^
-DSTRINGZILLA_BUILD_BENCHMARK=1 ^
-DSTRINGZILLA_BUILD_TEST=1
cmake --build build_artifacts --config RelWithDebInfo > build_artifacts/logs.txt 2>&1 || (
echo "Compilation failed. Here are the logs:"
type build_artifacts\logs.txt
echo "The original compilation commands:"
type build_artifacts\compile_commands.json
exit 1
)
- name: Test C++
run: .\build_artifacts\stringzilla_test_cpp20.exe
- name: Check stringzilla_bare is built correctly
shell: cmd
run: dumpbin /nologo /dependents .\build_artifacts\stringzilla_bare.dll | findstr /r "[a-zA-Z0-9]\.dll" | findstr /r /v "KERNEL32.dll stringzilla" && exit /b 1 || exit /b 0
- name: Test on Real World Data
run: |
.\build_artifacts\stringzilla_bench_find_cpp20.exe ${DATASET_PATH} # for substring search
.\build_artifacts\stringzilla_bench_token_cpp20.exe ${DATASET_PATH} # for hashing, equality comparisons, etc.
.\build_artifacts\stringzilla_bench_sequence_cpp20.exe ${DATASET_PATH} # for sorting arrays of strings
.\build_artifacts\stringzilla_bench_container_cpp20.exe ${DATASET_PATH} # for STL containers with string keys
env:
DATASET_PATH: ./README.md
# Don't overload GitHub with our benchmarks.
# The results in such an unstable environment will be meaningless anyway.
if: 0
# Python
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v6.2.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Build Python
run: |
python -m pip install --upgrade pip
pip install pytest pytest-repeat numpy
python -m pip install .
- name: Test Python
run: python -X faulthandler -m pytest test/ --ignore=test/stringzillas.py -s -vv --maxfail=1 --full-trace
# Rust
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Test Rust with dynamic dispatch
run: cargo test --release
- name: Build Rust with compile-time dispatch
run: cargo build --release --no-default-features --features std
test_alpine:
name: Alpine Linux
runs-on: ubuntu-24.04
container:
image: alpine:latest
options: --privileged # If needed for certain Docker operations
steps:
# bash and curl are required by dtolnay/rust-toolchain
- name: Install Git for checkout
run: |
apk add --no-cache git openssh ca-certificates bash curl
git --version
- name: Log Alpine and Git versions
run: |
echo "Alpine: $(cat /etc/alpine-release 2>/dev/null || echo 'unknown')"
git --version || echo "git not installed"
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Log hardware capabilities
run: |
echo "────────────────────────────────────────────────────────────────"
echo "Hardware Capabilities"
echo "────────────────────────────────────────────────────────────────"
lscpu || true
echo ""
echo "CPU Info:"
grep -E "model name|flags" /proc/cpuinfo | head -5 || true
echo "────────────────────────────────────────────────────────────────"
# C/C++