-
Notifications
You must be signed in to change notification settings - Fork 28
147 lines (129 loc) · 5.1 KB
/
Copy pathci.yml
File metadata and controls
147 lines (129 loc) · 5.1 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
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"