Skip to content

Merge branch 'master' of github.com:simdhash/clhash #7

Merge branch 'master' of github.com:simdhash/clhash

Merge branch 'master' of github.com:simdhash/clhash #7

Workflow file for this run

name: CI
on:
push:
branches: [master, main]
pull_request:
branches: [master, main]
jobs:
# ---------------------------------------------------------------------------
# Linux x86_64, Linux ARM64, and macOS ARM64. The arch matters because the
# x86 build path goes through PCLMULQDQ/SSE intrinsics while the ARM path
# goes through the NEON shim + PMULL, and we want both exercised.
# ---------------------------------------------------------------------------
unix:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest # Linux x86_64
- ubuntu-24.04-arm # Linux ARM64 (free for public repos)
- macos-latest # macOS ARM64 (Apple Silicon)
steps:
- uses: actions/checkout@v4
- name: Compiler / arch info
run: |
uname -a
cc --version
c++ --version
# ----- Makefile build -----
- name: Build (Makefile)
run: make
- name: Run binaries (Makefile artefacts)
run: |
./unit
./cppunit
./example
./cppexample
# ----- CMake build + CTest -----
- name: Configure (CMake)
run: cmake -S . -B build
- name: Build (CMake)
run: cmake --build build -j
- name: Test (CTest)
run: ctest --test-dir build --output-on-failure
- name: Run examples (CMake artefacts)
run: |
./build/example
./build/cppexample
# ----- Install + downstream find_package() -----
- name: Install into a temporary prefix
run: cmake --install build --prefix "${{ runner.temp }}/clhash-install"
- name: Consume the installed package from a fresh project
run: |
mkdir -p "${{ runner.temp }}/consumer"
cd "${{ runner.temp }}/consumer"
cat > CMakeLists.txt <<'EOF'
cmake_minimum_required(VERSION 3.16)
project(consumer C)
find_package(clhash 1.0 REQUIRED)
add_executable(consumer consumer.c)
target_link_libraries(consumer PRIVATE clhash::clhash)
EOF
cat > consumer.c <<'EOF'
#include <stdio.h>
#include "clhash.h"
int main(void) {
void *k = get_random_key_for_clhash(1, 2);
uint64_t h = clhash(k, "hello", 5);
printf("hash=0x%016llx\n", (unsigned long long)h);
free(k);
return 0;
}
EOF
cmake -S . -B build -DCMAKE_PREFIX_PATH="${{ runner.temp }}/clhash-install"
cmake --build build
./build/consumer
# ----- CLHASH_BITMIX flavour: build-only smoke test -----
# The known-answer vectors in tests/unit.c are derived from the default
# (non-BITMIX) hash, so enabling BITMIX makes that test diverge by
# design. We just verify it still compiles cleanly.
- name: CMake build with CLHASH_BITMIX
run: |
cmake -S . -B build-bitmix -DCLHASH_ENABLE_BITMIX=ON
cmake --build build-bitmix -j
# ---------------------------------------------------------------------------
# Windows with Visual Studio (MSVC). The Makefile is GCC/Clang-oriented and
# is not exercised here; we drive everything through CMake's Visual Studio
# generator, which is the supported way to build clhash on Windows.
# ---------------------------------------------------------------------------
windows:
name: windows-latest (Visual Studio)
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Configure (CMake, Visual Studio generator)
run: cmake -S . -B build -A x64
- name: Build (Release)
run: cmake --build build --config Release -j
- name: Test (CTest, Release)
run: ctest --test-dir build -C Release --output-on-failure
- name: Install into a temporary prefix
run: cmake --install build --config Release --prefix "${{ runner.temp }}/clhash-install"
- name: Consume the installed package from a fresh project
shell: pwsh
run: |
$consumer = "${{ runner.temp }}/consumer"
New-Item -ItemType Directory -Force -Path $consumer | Out-Null
@'
cmake_minimum_required(VERSION 3.16)
project(consumer C)
find_package(clhash 1.0 REQUIRED)
add_executable(consumer consumer.c)
target_link_libraries(consumer PRIVATE clhash::clhash)
'@ | Set-Content "$consumer/CMakeLists.txt"
@'
#include <stdio.h>
#include "clhash.h"
int main(void) {
void *k = get_random_key_for_clhash(1, 2);
unsigned long long h = (unsigned long long)clhash(k, "hello", 5);
printf("hash=0x%016llx\n", h);
free(k);
return 0;
}
'@ | Set-Content "$consumer/consumer.c"
cmake -S $consumer -B "$consumer/build" -A x64 -DCMAKE_PREFIX_PATH="${{ runner.temp }}/clhash-install"
cmake --build "$consumer/build" --config Release
& "$consumer/build/Release/consumer.exe"