Repository navigation
306 lines (264 loc) · 9.29 KB
/
Copy pathci.yml
File metadata and controls
306 lines (264 loc) · 9.29 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
name: CI
on:
pull_request:
push:
branches:
- '**'
tags-ignore:
- '**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Use bash everywhere so the same scripts run on the Windows runners too
defaults:
run:
shell: bash
jobs:
build-libbitcoinkernel:
name: Build libbitcoinkernel (${{ matrix.rid }})
runs-on: ${{ matrix.os }}
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
rid: linux-x64
libname: libbitcoinkernel.so
- os: macos-latest
rid: osx-x64
libname: libbitcoinkernel.dylib
# Bitcoin Core's vs2026 presets need the VS 2026 image
- os: windows-2025-vs2026
rid: win-x64
# MSVC builds bitcoinkernel.dll, which clashes with the managed
# BitcoinKernel.dll on case-insensitive file systems, so ship it with a lib prefix
buildname: bitcoinkernel.dll
libname: libbitcoinkernel.dll
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Read pinned Bitcoin Core commit
id: bitcoin
run: echo "commit=$(tr -d '[:space:]' < native/BITCOIN_COMMIT)" >> "$GITHUB_OUTPUT"
- name: Cache built library
id: cache
uses: actions/cache@v6.1.0
with:
path: kernel-out
key: libbitcoinkernel-${{ matrix.rid }}-${{ matrix.libname }}-${{ steps.bitcoin.outputs.commit }}
- name: Checkout Bitcoin Core
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/checkout@v7
with:
repository: bitcoin/bitcoin
ref: ${{ steps.bitcoin.outputs.commit }}
path: bitcoin
- name: Install build dependencies (Linux)
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ninja-build libboost-dev
- name: Install build dependencies (macOS)
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'macOS'
run: brew install ninja boost
- name: Build libbitcoinkernel (Linux/macOS)
if: steps.cache.outputs.cache-hit != 'true' && runner.os != 'Windows'
run: |
cmake -B bitcoin/build -S bitcoin -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_KERNEL_LIB=ON \
-DBUILD_KERNEL_TEST=ON \
-DBUILD_UTIL_CHAINSTATE=ON \
-DBUILD_BITCOIN_BIN=OFF \
-DBUILD_DAEMON=OFF \
-DBUILD_CLI=OFF \
-DBUILD_TX=OFF \
-DBUILD_UTIL=OFF \
-DBUILD_WALLET_TOOL=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_BENCH=OFF \
-DBUILD_FUZZ_BINARY=OFF \
-DENABLE_WALLET=OFF \
-DENABLE_IPC=OFF \
-DENABLE_EXTERNAL_SIGNER=OFF \
-DCMAKE_INSTALL_LIBDIR=lib
cmake --build bitcoin/build --target bitcoinkernel --parallel
- name: Build libbitcoinkernel (Windows)
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'Windows'
working-directory: bitcoin
run: |
# The presets locate the vcpkg toolchain through VCPKG_ROOT
export VCPKG_ROOT="${VCPKG_ROOT:-$VCPKG_INSTALLATION_ROOT}"
# Static triplet links the MSVC runtime into the DLL, so consumers
# don't need the Visual C++ redistributable installed
cmake -B build --preset=vs2026-static \
-DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON \
-DBUILD_GUI=OFF \
-DWITH_ZMQ=OFF \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_KERNEL_LIB=ON \
-DBUILD_BITCOIN_BIN=OFF \
-DBUILD_DAEMON=OFF \
-DBUILD_CLI=OFF \
-DBUILD_TX=OFF \
-DBUILD_UTIL=OFF \
-DBUILD_WALLET_TOOL=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_BENCH=OFF \
-DBUILD_FUZZ_BINARY=OFF \
-DENABLE_WALLET=OFF \
-DENABLE_IPC=OFF \
-DENABLE_EXTERNAL_SIGNER=OFF
cmake --build build --config Release --target bitcoinkernel --parallel
- name: Collect libbitcoinkernel
if: steps.cache.outputs.cache-hit != 'true'
run: |
mkdir -p kernel-out
BUILD_NAME='${{ matrix.buildname || matrix.libname }}'
LIB_PATH=$(find bitcoin/build \( -type f -o -type l \) -name "$BUILD_NAME" | head -n1)
if [ -z "$LIB_PATH" ]; then
echo "::error::$BUILD_NAME not found in build output:"
find bitcoin/build -name 'libbitcoinkernel*'
exit 1
fi
# Dereference symlinks so versioned libs end up as a single real file
cp -L "$LIB_PATH" kernel-out/${{ matrix.libname }}
- name: Upload library artifact
uses: actions/upload-artifact@v7
with:
name: libbitcoinkernel-${{ matrix.rid }}
path: kernel-out/${{ matrix.libname }}
if-no-files-found: error
build-and-test:
name: Build and Test
runs-on: ${{ matrix.os }}
needs: build-libbitcoinkernel
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
dotnet-version: ['10.0.x']
include:
- os: ubuntu-latest
rid: linux-x64
- os: macos-latest
rid: osx-x64
- os: windows-latest
rid: win-x64
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Download libbitcoinkernel
uses: actions/download-artifact@v8
with:
name: libbitcoinkernel-${{ matrix.rid }}
path: native/${{ matrix.rid }}
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test with dotnet
run: dotnet test --no-restore --report-xunit-trx --results-directory "TestResults-${{ matrix.os }}"
- name: Upload dotnet test results
uses: actions/upload-artifact@v7
with:
name: dotnet-results-${{ matrix.os }}
path: TestResults-${{ matrix.os }}
if: ${{ always() }}
lint:
name: Lint/Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Check formatting
run: dotnet format --verify-no-changes --verbosity diagnostic
security:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Checking for external vulnerabilites
run: |
dotnet list package --vulnerable --include-transitive 2>&1 | tee vuln.log
echo "Analyze dotnet list package..."
! grep -q -i "has the following vulnerable packages" vuln.log
conformance-tests:
name: Conformance Tests
runs-on: ${{ matrix.os }}
needs: build-and-test
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
platform: darwin_arm64
rid: osx-x64
archive: tar.gz
exe: ''
- os: ubuntu-latest
platform: linux_amd64
rid: linux-x64
archive: tar.gz
exe: ''
- os: windows-latest
platform: windows_amd64
rid: win-x64
archive: zip
exe: .exe
env:
TEST_VERSION: '0.0.4-alpha.pr17.1'
TEST_REPO: 'stringintech/kernel-bindings-tests'
TEST_DIR: '.conformance-tests'
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Download libbitcoinkernel
uses: actions/download-artifact@v8
with:
name: libbitcoinkernel-${{ matrix.rid }}
path: native/${{ matrix.rid }}
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.0.x'
- name: Build conformance handler
run: |
dotnet build tools/kernel-bindings-test-handler/kernel-bindings-test-handler.csproj -c Release
dotnet publish tools/kernel-bindings-test-handler/kernel-bindings-test-handler.csproj -c Release -o handler-bin
- name: Download test runner
run: |
mkdir -p ${{ env.TEST_DIR }}
ARCHIVE=${{ env.TEST_DIR }}/test-runner.${{ matrix.archive }}
DOWNLOAD_URL="https://github.com/${{ env.TEST_REPO }}/releases/download/v${{ env.TEST_VERSION }}/kernel-bindings-tests_${{ env.TEST_VERSION }}_${{ matrix.platform }}.${{ matrix.archive }}"
echo "Downloading from: $DOWNLOAD_URL"
curl --fail -L -o "$ARCHIVE" "$DOWNLOAD_URL"
if [ "${{ matrix.archive }}" = "zip" ]; then
# Git Bash's tar can't read zip files, the runner image ships 7-Zip
7z x -y -o${{ env.TEST_DIR }} "$ARCHIVE"
else
tar -xzf "$ARCHIVE" -C ${{ env.TEST_DIR }}
fi
chmod +x ${{ env.TEST_DIR }}/runner${{ matrix.exe }}
- name: Run conformance tests
run: |
${{ env.TEST_DIR }}/runner${{ matrix.exe }} --handler handler-bin/kernel-bindings-test-handler${{ matrix.exe }}