forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 0
277 lines (252 loc) · 9.03 KB
/
build.yml
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
name: CI
on:
push:
pull_request_target:
permissions:
contents: read
packages: write
env:
DOCKER_DRIVER: overlay2
jobs:
build-image:
name: Build Image
runs-on: ubuntu-20.04
outputs:
image-tag: ${{ steps.prepare.outputs.image-tag }}
repo-name: ${{ steps.prepare.outputs.repo-name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Prepare
id: prepare
run: |
BRANCH_NAME=$(echo "${GITHUB_REF##*/}" | tr '[:upper:]' '[:lower:]')
REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "image-tag=${BRANCH_NAME}" >> $GITHUB_OUTPUT
echo "repo-name=${REPO_NAME}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ./contrib/containers/ci
file: ./contrib/containers/ci/Dockerfile
push: true
tags: |
ghcr.io/${{ steps.prepare.outputs.repo-name }}/dashcore-ci-runner:${{ steps.prepare.outputs.image-tag }}
ghcr.io/${{ steps.prepare.outputs.repo-name }}/dashcore-ci-runner:latest
cache-from: type=registry,ref=ghcr.io/${{ steps.prepare.outputs.repo-name }}/dashcore-ci-runner:latest
cache-to: type=inline
build-depends:
name: Build Dependencies
needs: build-image
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- build_target: arm-linux
host: arm-linux-gnueabihf
dep_opts: ""
- build_target: win64
host: x86_64-w64-mingw32
dep_opts: ""
- build_target: linux64
host: x86_64-pc-linux-gnu
dep_opts: "DEBUG=1"
- build_target: linux64_tsan
host: x86_64-pc-linux-gnu
dep_opts: ""
- build_target: linux64_ubsan
host: x86_64-pc-linux-gnu
dep_opts: ""
- build_target: linux64_fuzz
host: x86_64-pc-linux-gnu
dep_opts: ""
- build_target: linux64_cxx20
host: x86_64-pc-linux-gnu
dep_opts: ""
- build_target: linux64_sqlite
host: x86_64-pc-linux-gnu
dep_opts: ""
- build_target: linux64_nowallet
host: x86_64-pc-linux-gnu
dep_opts: "NO_WALLET=1"
- build_target: linux64_multiprocess
host: x86_64-pc-linux-gnu
dep_opts: "MULTIPROCESS=1"
- build_target: mac
host: x86_64-apple-darwin
dep_opts: ""
container:
image: ghcr.io/${{ needs.build-image.outputs.repo-name }}/dashcore-ci-runner:${{ needs.build-image.outputs.image-tag }}
options: --user root
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Prepare MacOS SDK
if: matrix.host == 'x86_64-apple-darwin'
run: |
mkdir -p depends/SDKs
mkdir -p depends/sdk-sources
OSX_SDK_BASENAME="Xcode-12.2-12B45b-extracted-SDK-with-libcxx-headers.tar.gz"
OSX_SDK_PATH="depends/sdk-sources/${OSX_SDK_BASENAME}"
if [ ! -f "$OSX_SDK_PATH" ]; then
echo "Downloading MacOS SDK"
curl --location --fail "https://bitcoincore.org/depends-sources/sdks/${OSX_SDK_BASENAME}" -o "$OSX_SDK_PATH"
fi
if [ -f "$OSX_SDK_PATH" ]; then
echo "Extracting MacOS SDK"
tar -C depends/SDKs -xf "$OSX_SDK_PATH"
fi
- name: Cache depends sources
uses: actions/cache@v4
with:
path: |
depends/sources
depends/sdk-sources
depends/SDKs
key: depends-sources-${{ hashFiles('depends/packages/*') }}
restore-keys: |
depends-sources-
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
depends/${{ matrix.host }}
key: ${{ runner.os }}-depends-${{ matrix.build_target }}-${{ hashFiles('depends/packages/*') }}-${{ matrix.dep_opts }}
restore-keys: |
${{ runner.os }}-depends-${{ matrix.build_target }}-${{ hashFiles('depends/packages/*') }}
${{ runner.os }}-depends-${{ matrix.build_target }}
- name: Build dependencies
run: make -j$(nproc) -C depends HOST=${{ matrix.host }} ${{ matrix.dep_opts }}
build:
name: Build
needs: [build-image, build-depends]
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- build_target: arm-linux
host: arm-linux-gnueabihf
- build_target: win64
host: x86_64-w64-mingw32
- build_target: linux64
host: x86_64-pc-linux-gnu
- build_target: linux64_tsan
host: x86_64-pc-linux-gnu
- build_target: linux64_ubsan
host: x86_64-pc-linux-gnu
- build_target: linux64_fuzz
host: x86_64-pc-linux-gnu
- build_target: linux64_cxx20
host: x86_64-pc-linux-gnu
- build_target: linux64_sqlite
host: x86_64-pc-linux-gnu
- build_target: linux64_nowallet
host: x86_64-pc-linux-gnu
- build_target: linux64_multiprocess
host: x86_64-pc-linux-gnu
- build_target: mac
host: x86_64-apple-darwin
container:
image: ghcr.io/${{ needs.build-image.outputs.repo-name }}/dashcore-ci-runner:${{ needs.build-image.outputs.image-tag }}
options: --user root
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Restore Cache dependencies
uses: actions/cache/restore@v4
with:
path: |
depends/${{ matrix.host }}
depends/sdk-sources
depends/SDKs
key: ${{ runner.os }}-depends-${{ matrix.build_target }}-${{ hashFiles('depends/packages/*') }}-${{ matrix.dep_opts }}
restore-keys: |
${{ runner.os }}-depends-${{ matrix.build_target }}-${{ hashFiles('depends/packages/*') }}
${{ runner.os }}-depends-${{ matrix.build_target }}
- name: Determine PR Base SHA
id: vars
run: |
echo "PR_BASE_SHA=${{ github.event.pull_request.base.sha || '' }}" >> $GITHUB_OUTPUT
- name: CCache
uses: actions/cache@v4
with:
path: |
/cache
key: ${{ runner.os }}-${{ matrix.build_target }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ matrix.build_target }}-${{ github.sha }}
${{ runner.os }}-${{ matrix.build_target }}-${{ steps.vars.outputs.PR_BASE_SHA }}
${{ runner.os }}-${{ matrix.build_target }}
- name: Build source and run unit tests
run: |
git config --global --add safe.directory "$PWD"
CCACHE_SIZE="400M"
CACHE_DIR="/cache"
mkdir /output
BASE_OUTDIR="/output"
BUILD_TARGET="${{ matrix.build_target }}"
source ./ci/dash/matrix.sh
./ci/dash/build_src.sh
./ci/dash/test_unittests.sh
shell: bash
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts-${{ matrix.build_target }}
path: |
/output
test:
name: Test
needs: [build]
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- build_target: linux64
- build_target: linux64_sqlite
- build_target: linux64_tsan
- build_target: linux64_ubsan
- build_target: linux64_multiprocess
container:
image: ghcr.io/${{ needs.build-image.outputs.repo-name }}/dashcore-ci-runner:${{ needs.build-image.outputs.image-tag }}
options: --user root
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts-${{ matrix.build_target }}
path: /output
- name: Run Integration Tests
run: |
git config --global --add safe.directory "$PWD"
BUILD_TARGET="${{ matrix.build_target }}"
source ./ci/dash/matrix.sh
./ci/dash/test_integrationtests.sh --extended --exclude feature_pruning,feature_dbcrash
shell: bash
- name: Upload Test Logs
uses: actions/upload-artifact@v4
with:
name: test-logs-${{ matrix.build_target }}
path: |
testlogs