Added windows cross compile builds & fixed build issues #469
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Pre-Release" | |
on: | |
push: | |
branches: ["main-dev"] | |
pull_request: | |
branches: ["main-dev"] | |
env: | |
BUILD_TYPE: Release | |
GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }} | |
PYTHON_VERSION: 3.11 | |
SWIFT_VERSION: 5.9 | |
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@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Run TinySemVer | |
uses: ashvardanian/[email protected] | |
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_VERSION_MAJOR (\d+) | |
update-minor-version-in: | | |
include/stringzilla/stringzilla.h:^#define STRINGZILLA_VERSION_MINOR (\d+) | |
update-patch-version-in: | | |
include/stringzilla/stringzilla.h:^#define STRINGZILLA_VERSION_PATCH (\d+) | |
dry-run: "true" | |
test_ubuntu_gcc: | |
name: Ubuntu (GCC 12) | |
runs-on: ubuntu-22.04 | |
env: | |
CC: gcc-12 | |
CXX: g++-12 | |
steps: | |
- uses: actions/checkout@v4 | |
# 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 libjemalloc-dev libomp-dev 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 "CPU Features:" | |
lscpu | |
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 stringzillite is built correctly | |
run: test -z "$(ldd build_artifacts/libstringzillite.so | grep '.so')" | |
- name: Test on Real World Data | |
run: | | |
build_artifacts/stringzilla_bench_search ${DATASET_PATH} # for substring search | |
build_artifacts/stringzilla_bench_token ${DATASET_PATH} # for hashing, equality comparisons, etc. | |
build_artifacts/stringzilla_bench_similarity ${DATASET_PATH} # for edit distances and alignment scores | |
build_artifacts/stringzilla_bench_sort ${DATASET_PATH} # for sorting arrays of strings | |
build_artifacts/stringzilla_bench_container ${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/[email protected] | |
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: Test Python | |
run: pytest scripts/test.py -s -x | |
# JavaScript | |
# - name: Set up Node.js | |
# uses: actions/setup-node | |
# with: | |
# node-version: 18 | |
# - name: Build and test JavaScript | |
# run: npm ci && npm test | |
# Rust | |
- name: Test Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
test_ubuntu_clang: | |
name: Ubuntu (Clang 16) | |
runs-on: ubuntu-22.04 | |
env: | |
CC: clang-16 | |
CXX: clang++-16 | |
steps: | |
- uses: actions/checkout@v4 | |
# 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 "CPU Features:" | |
lscpu | |
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 stringzillite is built correctly | |
run: test -z "$(ldd build_artifacts/libstringzillite.so | grep '.so')" | |
- name: Test on Real World Data | |
run: | | |
build_artifacts/stringzilla_bench_search ${DATASET_PATH} # for substring search | |
build_artifacts/stringzilla_bench_token ${DATASET_PATH} # for hashing, equality comparisons, etc. | |
build_artifacts/stringzilla_bench_similarity ${DATASET_PATH} # for edit distances and alignment scores | |
build_artifacts/stringzilla_bench_sort ${DATASET_PATH} # for sorting arrays of strings | |
build_artifacts/stringzilla_bench_container ${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/[email protected] | |
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: Test Python | |
run: pytest scripts/test.py -s -x | |
# Rust | |
- name: Test Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
# 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@v1 | |
# 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 --enable-test-discovery | |
# 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:5.9 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Test Swift | |
run: swift test | |
test_ubuntu_cross_compilation: | |
name: Clang Cross Compilation | |
runs-on: ubuntu-22.04 | |
env: | |
CC: clang-16 | |
CXX: clang++-16 | |
AR: llvm-ar | |
NM: llvm-nm | |
RANLIB: llvm-ranlib | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- arch: amd64 | |
target: x86_64-linux-gnu | |
- arch: arm64 | |
target: aarch64-linux-gnu | |
steps: | |
- uses: actions/checkout@v4 | |
# C/C++ | |
# We need to install the cross-compilation toolchain for ARM64 and ARMHF | |
# 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-get update | |
sudo apt-get install -y make build-essential crossbuild-essential-arm64 crossbuild-essential-armhf 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 \ | |
-DCMAKE_C_COMPILER_TARGET=${{ matrix.target }} \ | |
-DCMAKE_CXX_COMPILER_TARGET=${{ matrix.target }} \ | |
-DCMAKE_SYSTEM_NAME=Linux \ | |
-DCMAKE_SYSTEM_PROCESSOR=${{ matrix.arch }} \ | |
-DSTRINGZILLA_BUILD_SHARED=1 \ | |
-DSTRINGZILLA_BUILD_BENCHMARK=1 \ | |
-DSTRINGZILLA_BUILD_TEST=1 | |
cmake --build build_artifacts --config RelWithDebInfo | |
# We can't run the produced builds, but we can make sure they exist | |
- name: Test artifacts presense | |
run: | | |
test -e build_artifacts/libstringzillite.so | |
test -e build_artifacts/libstringzilla_shared.so | |
test -e build_artifacts/stringzilla_test_cpp20 | |
- name: Check stringzillite is built correctly | |
run: test -z "$(ldd build_artifacts/libstringzillite.so | grep '.so')" | |
test_macos: | |
name: MacOS | |
runs-on: macos-14 | |
steps: | |
- uses: actions/checkout@v4 | |
# C/C++ | |
- name: Install dependencies | |
run: | | |
brew update | |
brew install 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: Check stringzillite is built correctly | |
run: test -z "$(ldd build_artifacts/libstringzillite.so | grep '.so')" | |
- name: Test on Real World Data | |
run: | | |
build_artifacts/stringzilla_bench_search ${DATASET_PATH} # for substring search | |
build_artifacts/stringzilla_bench_token ${DATASET_PATH} # for hashing, equality comparisons, etc. | |
build_artifacts/stringzilla_bench_similarity ${DATASET_PATH} # for edit distances and alignment scores | |
build_artifacts/stringzilla_bench_sort ${DATASET_PATH} # for sorting arrays of strings | |
build_artifacts/stringzilla_bench_container ${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/[email protected] | |
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: pytest scripts/test.py -s -x | |
# Swift | |
- name: Set up Swift ${{ env.SWIFT_VERSION }} | |
uses: swift-actions/setup-swift@v1 | |
with: | |
swift-version: ${{ env.SWIFT_VERSION }} | |
- name: Build Swift | |
run: swift build | |
- name: Test Swift | |
run: swift test | |
# Rust | |
- name: Test Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
test_windows: | |
name: Windows | |
runs-on: windows-2022 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ilammy/msvc-dev-cmd@v1 | |
- 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 | |
echo: | |
echo "CPU Features:" | |
wmic cpu list /format:list | |
exit 1 | |
) | |
- name: Test C++ | |
run: .\build_artifacts\stringzilla_test_cpp20.exe | |
- name: Check stringzillite is built correctly | |
shell: cmd | |
run: dumpbin /nologo /dependents .\build_artifacts\stringzillite.dll | findstr /r "^[^a-z].*\.dll" && exit /b 1 || exit /b 0 | |
- name: Test on Real World Data | |
run: | | |
.\build_artifacts\stringzilla_bench_search.exe ${DATASET_PATH} # for substring search | |
.\build_artifacts\stringzilla_bench_token.exe ${DATASET_PATH} # for hashing, equality comparisons, etc. | |
.\build_artifacts\stringzilla_bench_similarity.exe ${DATASET_PATH} # for edit distances and alignment scores | |
.\build_artifacts\stringzilla_bench_sort.exe ${DATASET_PATH} # for sorting arrays of strings | |
.\build_artifacts\stringzilla_bench_container.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/[email protected] | |
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: Test Python | |
run: pytest scripts/test.py -s -x | |
test_windows_cross_compilation: | |
name: Windows Cross Compilation ${{ matrix.target }} | |
runs-on: windows-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- arch: x64 | |
target: x64 | |
- arch: x86 | |
target: x86 | |
- arch: amd64_arm64 | |
target: arm64 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ilammy/msvc-dev-cmd@v1 | |
with: | |
arch: ${{ matrix.arch }} | |
- name: Build C/C++ | |
shell: cmd | |
run: | | |
cmake -GNinja -B build_artifacts ^ | |
-DCMAKE_BUILD_TYPE=RelWithDebInfo ^ | |
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 ^ | |
-DSTRINGZILLA_BUILD_SHARED=1 ^ | |
-DSTRINGZILLA_BUILD_BENCHMARK=1 ^ | |
-DSTRINGZILLA_BUILD_TEST=1 | |
cmake --build build_artifacts --config RelWithDebInfo | |
# We can't run the produced builds, but we can make sure they exist | |
- name: Test artifacts presense | |
shell: cmd | |
run: | | |
type build_artifacts\stringzillite.dll >NUL | |
type build_artifacts\stringzilla_shared.dll >NUL | |
type build_artifacts\stringzilla_test_cpp20.exe >NUL | |
- name: Check stringzillite is built correctly | |
shell: cmd | |
run: dumpbin /nologo /dependents .\build_artifacts\stringzillite.dll | findstr /r "^[^a-z].*\.dll" && exit /b 1 || exit /b 0 | |
test_alpine: | |
name: Alpine Linux | |
runs-on: ubuntu-24.04 | |
container: | |
image: alpine:latest | |
options: --privileged # If needed for certain Docker operations | |
steps: | |
- uses: actions/checkout@v3 | |
# C/C++ | |
- name: Build C/C++ | |
run: | | |
apk add --update make cmake g++ gcc | |
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_cpp20 | |
- name: Check stringzillite is built correctly | |
run: test -z "$(ldd build_artifacts/libstringzillite.so | grep '.so' | grep '=>')" | |
# Python | |
- name: Build Python | |
run: | | |
apk add python3 py3-pip python3-dev | |
pip install --break-system-packages pytest pytest-repeat | |
pip install --break-system-packages . | |
- name: Test Python | |
run: pytest scripts/test.py -s -x | |
# Rust | |
- name: Test Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
override: true | |
build_wheels: | |
name: Build Python ${{ matrix.python-version }} for ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
needs: | |
[ | |
test_ubuntu_gcc, | |
test_ubuntu_clang, | |
test_macos, | |
test_windows, | |
test_alpine, | |
] | |
strategy: | |
matrix: | |
os: [ubuntu-24.04, macos-14, windows-2022] | |
python-version: ["36", "37", "38", "39", "310", "311", "312"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/[email protected] | |
with: | |
python-version: 3.x | |
# We only need QEMU for Linux builds | |
- name: Setup QEMU | |
if: matrix.os == 'ubuntu-24.04' | |
uses: docker/setup-qemu-action@v3 | |
- name: Install cibuildwheel | |
run: python -m pip install cibuildwheel | |
- name: Build wheels | |
run: cibuildwheel --output-dir wheelhouse | |
env: | |
CIBW_BUILD: cp${{ matrix.python-version }}-* |