-
-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (147 loc) · 6.22 KB
/
Copy pathci.yml
File metadata and controls
165 lines (147 loc) · 6.22 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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Debug, Release]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Clone vcpkg
shell: bash
run: git clone --depth 1 https://github.com/microsoft/vcpkg.git "${{ runner.temp }}/vcpkg"
# The SlickQuant dependency libraries (slick-net, hyperliquid-cpp, ...) build
# their Release config with -march=native, so the binaries vcpkg produces are
# tuned to whatever CPU the runner that built them happened to have. Restoring
# such a cache onto a runner with a narrower instruction set makes the tests
# die with SIGILL on an AVX-512 opcode inside the dependency:
#
# Program received signal SIGILL
# => vmovdqu8 %xmm0,0x20(%rbx)
# in slick::net::Websocket<...>::Websocket(...)
# from hyperliquid::WebsocketManager::init(...)
#
# That is why the Linux Release job failed intermittently and passed on
# re-run: it depended on which CPU the cache came from. Key the cache on the
# runner's CPU features so a cache is only ever reused on compatible hardware.
- name: CPU signature for the vcpkg cache key
id: cpusig
shell: bash
run: |
if [ "$RUNNER_OS" = "Linux" ]; then
raw=$(grep -m1 '^flags' /proc/cpuinfo | cut -d: -f2 | tr ' ' '\n' \
| grep -E '^(sse4_[12]|avx|avx2|avx512[a-z0-9_]*|bmi[12]|fma)$' | sort -u | tr '\n' ',')
else
raw=$(wmic cpu get Name /value 2>/dev/null | tr -d '\r' | grep '=' || echo "windows-unknown")
fi
echo "CPU signature source: $raw"
echo "sig=$(printf '%s' "$raw" | sha256sum | cut -c1-16)" >> "$GITHUB_OUTPUT"
# No vcpkg.json manifest is committed in this repo by design (see CLAUDE.md), so
# dependencies are installed explicitly in classic mode below.
- name: Cache vcpkg
uses: actions/cache@v4
with:
path: |
${{ runner.temp }}/vcpkg/installed
${{ runner.temp }}/vcpkg/downloads
${{ runner.temp }}/vcpkg/packages
key: vcpkg-${{ runner.os }}-cpu${{ steps.cpusig.outputs.sig }}-${{ hashFiles('.github/workflows/ci.yml') }}
- name: Bootstrap vcpkg (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
& "${{ runner.temp }}\vcpkg\bootstrap-vcpkg.bat" -disableMetrics
- name: Bootstrap vcpkg (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
"${{ runner.temp }}/vcpkg/bootstrap-vcpkg.sh" -disableMetrics
- name: Install dependencies via vcpkg
shell: bash
run: |
"${{ runner.temp }}/vcpkg/vcpkg" install \
quickfix \
nlohmann-json \
jwt-cpp \
foonathan-memory \
boost-uuid \
gtest \
slick-logger \
slick-socket \
slick-object-pool \
coinbase-advanced-cpp \
slickquant-hyperliquid-cpp \
"uwebsockets[core,ssl,zlib]"
- name: Configure CMake
shell: bash
run: >
cmake -B build
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_TOOLCHAIN_FILE="${{ runner.temp }}/vcpkg/scripts/buildsystems/vcpkg.cmake"
- name: Build
run: cmake --build build --config ${{ matrix.build_type }} --parallel
- name: Run tests
working-directory: build
run: ctest -C ${{ matrix.build_type }} --output-on-failure
# The Linux Release job intermittently dies with SIGILL inside the tests that
# construct an Exchange or a gateway; ctest only reports "Exception: Illegal"
# with no location. Re-run the failures under gdb to capture where and on
# which thread, since the crash cannot be reproduced on Windows or in Debug.
- name: Capture backtrace on test failure (Linux)
if: failure() && runner.os == 'Linux'
working-directory: build
run: |
sudo apt-get update && sudo apt-get install -y gdb
ulimit -c unlimited
# Ask ctest which tests failed, then run each under gdb.
failed=$(ctest -C ${{ matrix.build_type }} -N --rerun-failed 2>/dev/null \
| sed -n 's/^ *Test *#[0-9]*: //p' | head -5)
if [ -z "$failed" ]; then
echo "ctest reported no rerun-failed list; falling back to the first exchange test"
failed="HyperliquidRestTest.PlaceOrder_BuyLimit_Gtc_ReturnsResting"
fi
for t in $failed; do
echo "::group::gdb backtrace for $t"
gdb -batch -return-child-result \
-ex "run" \
-ex "echo \n===== signal / faulting frame =====\n" \
-ex "bt" \
-ex "echo \n===== all threads =====\n" \
-ex "thread apply all bt" \
-ex "info registers rip" \
-ex "x/8i \$rip" \
--args ./tests/slick_sim_tests --gtest_filter="$t" || true
echo "::endgroup::"
done
# Release-config artifacts are uploaded here so release.yml can reuse this
# exact, already-tested build instead of recompiling from scratch on tag push.
- name: Stage release artifact (Windows)
if: matrix.build_type == 'Release' && runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path release-stage | Out-Null
$exe = Get-ChildItem -Path build -Recurse -Filter slick-sim.exe | Select-Object -First 1
Copy-Item $exe.FullName -Destination release-stage
Copy-Item "${{ runner.temp }}\vcpkg\installed\x64-windows\bin\*.dll" -Destination release-stage -ErrorAction SilentlyContinue
- name: Stage release artifact (Linux)
if: matrix.build_type == 'Release' && runner.os == 'Linux'
shell: bash
run: |
mkdir -p release-stage
find build -type f -name slick-sim -exec cp {} release-stage/ \;
cp "${{ runner.temp }}/vcpkg/installed/x64-linux/lib/"*.so* release-stage/ 2>/dev/null || true
- name: Upload release build artifact
if: matrix.build_type == 'Release'
uses: actions/upload-artifact@v4
with:
name: slick-sim-${{ runner.os }}-release
path: release-stage/*