-
Notifications
You must be signed in to change notification settings - Fork 205
494 lines (480 loc) · 18.1 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
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
on:
workflow_call:
secrets:
DOCKERHUB_USERNAME:
required: false
DOCKERHUB_TOKEN:
required: false
inputs:
sha:
description: 'Sha to build'
type: 'string'
required: true
arch:
description: 'Architecture to build the image for (amd64, arm64)'
type: 'string'
required: true
tag:
description: 'Tag to use on the image name'
type: 'string'
required: true
protocol_version_default:
description: 'Default protocol version to use on local networks'
type: 'number'
required: true
core_repo:
description: 'Git repo for stellar-core'
type: 'string'
default: 'https://github.com/stellar/stellar-core.git'
core_ref:
description: 'Git ref for the stellar-core repo'
type: 'string'
required: true
core_configure_flags:
description: 'CONFIGURE_FLAGS used when building stellar-core'
type: 'string'
default: '--disable-tests'
horizon_ref:
description: 'Git ref for the stellar/go repo (horizon)'
type: 'string'
required: true
xdr_ref:
description: 'Git ref for the stellar/rs-stellar-xdr repo'
type: 'string'
required: false
soroban_rpc_ref:
description: 'Git ref for the stellar/soroban-rpc repo (soroban-rpc)'
type: 'string'
required: true
friendbot_ref:
description: 'Git ref for the stellar/go repo (friendbot)'
type: 'string'
required: true
test_matrix:
description: 'JSON matrix for the test job'
type: 'string'
required: true
outputs:
image:
description: 'Image pushed as a result of this build'
value: ${{ jobs.build.outputs.image }}
env:
IMAGE: ${{ format('{0}/{1}:{2}', secrets.DOCKERHUB_TOKEN && 'docker.io' || 'ghcr.io', github.repository, github.event_name == 'pull_request' && format('pr{0}-{1}', github.event.pull_request.number, inputs.tag) || inputs.tag) }}
HORIZON_REPO_REF: ${{ inputs.horizon_ref }}
FRIENDBOT_REPO_REF: ${{ inputs.friendbot_ref }}
SOROBAN_RPC_REPO_BRANCH: ${{ inputs.soroban_rpc_ref }}
CORE_REPO: ${{ inputs.core_repo }}
CORE_REPO_REF: ${{ inputs.core_ref }}
XDR_REPO_REF: ${{ inputs.xdr_ref }}
jobs:
load-stellar-core-from-cache:
runs-on: ubuntu-latest
outputs:
cache-hit: ${{ steps.cache.outputs.cache-hit }}
steps:
- id: cache
uses: actions/cache@v3
with:
path: /tmp/image
key: image-stellar-core-${{ inputs.arch }}-${{ env.CORE_REPO_REF }}-${{ inputs.core_configure_flags }}
- name: Upload Stellar-Core Image
if: steps.cache.outputs.cache-hit == 'true'
uses: actions/upload-artifact@v4
with:
name: image-stellar-core-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/image
build-stellar-core:
needs: [load-stellar-core-from-cache]
if: ${{ needs.load-stellar-core-from-cache.outputs.cache-hit != 'true' }}
runs-on: ${{ inputs.arch == 'arm64' && 'ubuntu-jammy-4-cores-arm64' || 'ubuntu-latest' }}
steps:
- id: cache
uses: actions/cache@v3
with:
path: /tmp/image
key: image-stellar-core-${{ inputs.arch }}-${{ env.CORE_REPO_REF }}-${{ inputs.core_configure_flags }}
- if: inputs.arch == 'arm64'
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18
with:
platforms: arm64
- uses: docker/setup-buildx-action@5146db6c4d81fbfd508899f851bbb3883a96ff9f
- name: Build Stellar-Core Image
run: >
docker buildx build --platform linux/${{ inputs.arch }}
-f docker/Dockerfile.testing -t stellar-core:${{ inputs.arch }}
-o type=docker,dest=/tmp/image
${{ env.CORE_REPO }}#${{ env.CORE_REPO_REF }}
--build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=true
--build-arg CONFIGURE_FLAGS='${{ inputs.core_configure_flags }}'
- name: Upload Stellar-Core Image
uses: actions/upload-artifact@v4
with:
name: image-stellar-core-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/image
build-stellar-horizon:
runs-on: ubuntu-latest
steps:
- name: Checkout Quickstart for Horizon docker file
uses: actions/checkout@v3
with:
ref: ${{ inputs.sha }}
- if: inputs.arch == 'arm64'
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18
with:
platforms: arm64
- name: Setup buildx
uses: docker/setup-buildx-action@5146db6c4d81fbfd508899f851bbb3883a96ff9f
- name: Build Stellar-Horizon Image
run: >
docker buildx build --platform linux/${{ inputs.arch }}
-f Dockerfile.horizon --target builder
-t stellar-horizon:${{ inputs.arch }} -o type=docker,dest=/tmp/image
--build-arg REF="${{ env.HORIZON_REPO_REF }}" .
- name: Upload Stellar-Horizon Image
uses: actions/upload-artifact@v4
with:
name: image-stellar-horizon-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/image
build-stellar-friendbot:
runs-on: ubuntu-latest
steps:
- if: inputs.arch == 'arm64'
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18
with:
platforms: arm64
- name: Setup buildx
uses: docker/setup-buildx-action@5146db6c4d81fbfd508899f851bbb3883a96ff9f
- name: Build Stellar-Friendbot Image
run: >
docker buildx build --platform linux/${{ inputs.arch }}
-f services/friendbot/docker/Dockerfile -t stellar-friendbot:${{ inputs.arch }}
-o type=docker,dest=/tmp/image
--build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=true
https://github.com/stellar/go.git#${{ env.FRIENDBOT_REPO_REF }}
- name: Upload Stellar-Friendbot Image
uses: actions/upload-artifact@v4
with:
name: image-stellar-friendbot-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/image
load-stellar-soroban-rpc-from-cache:
runs-on: ubuntu-latest
outputs:
cache-hit: ${{ steps.cache.outputs.cache-hit }}
steps:
- id: cache
uses: actions/cache@v3
with:
path: /tmp/image
key: image-stellar-soroban-rpc-${{ inputs.arch }}-${{ env.SOROBAN_RPC_REPO_BRANCH }}
- name: Upload Stellar-Core Image
if: steps.cache.outputs.cache-hit == 'true'
uses: actions/upload-artifact@v4
with:
name: image-stellar-soroban-rpc-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/image
build-stellar-soroban-rpc:
needs: [load-stellar-soroban-rpc-from-cache]
if: ${{ needs.load-stellar-soroban-rpc-from-cache.outputs.cache-hit != 'true' }}
runs-on: ${{ inputs.arch == 'arm64' && 'ubuntu-jammy-4-cores-arm64' || 'ubuntu-latest' }}
steps:
- id: cache
uses: actions/cache@v3
with:
path: /tmp/image
key: image-stellar-soroban-rpc-${{ inputs.arch }}-${{ env.SOROBAN_RPC_REPO_BRANCH }}
- if: inputs.arch == 'arm64'
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18
with:
platforms: arm64
- uses: docker/setup-buildx-action@5146db6c4d81fbfd508899f851bbb3883a96ff9f
- name: Build Stellar-Soroban-Rpc Image
run: >
docker buildx build --platform linux/${{ inputs.arch }}
-f cmd/soroban-rpc/docker/Dockerfile --target build
-t stellar-soroban-rpc:${{ inputs.arch }}
-o type=docker,dest=/tmp/image
--build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=true
https://github.com/stellar/soroban-rpc.git#${{ env.SOROBAN_RPC_REPO_BRANCH }}
- name: Upload Stellar-Soroban-Rpc Image
uses: actions/upload-artifact@v4
with:
name: image-stellar-soroban-rpc-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/image
load-rs-stellar-xdr-from-cache:
runs-on: ubuntu-latest
outputs:
cache-hit: ${{ steps.cache.outputs.cache-hit }}
steps:
- id: cache
uses: actions/cache@v3
with:
path: /tmp/image
key: image-rs-stellar-xdr-${{ inputs.arch }}-${{ env.XDR_REPO_REF }}
- name: Upload Stellar-Core Image
if: steps.cache.outputs.cache-hit == 'true'
uses: actions/upload-artifact@v4
with:
name: image-rs-stellar-xdr-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/image
build-rs-stellar-xdr:
needs: [load-rs-stellar-xdr-from-cache]
if: ${{ needs.load-rs-stellar-xdr-from-cache.outputs.cache-hit != 'true' }}
runs-on: ${{ inputs.arch == 'arm64' && 'ubuntu-jammy-4-cores-arm64' || 'ubuntu-latest' }}
steps:
- name: Checkout Quickstart for Horizon docker file
uses: actions/checkout@v3
with:
ref: ${{ inputs.sha }}
- id: cache
uses: actions/cache@v3
with:
path: /tmp/image
key: image-rs-stellar-xdr-${{ inputs.arch }}-${{ env.XDR_REPO_REF }}
- if: inputs.arch == 'arm64'
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18
with:
platforms: arm64
- uses: docker/setup-buildx-action@5146db6c4d81fbfd508899f851bbb3883a96ff9f
- name: Build Stellar-Rs-Xdr Image
run: >
docker buildx build --platform linux/${{ inputs.arch }}
-f Dockerfile.xdr --target builder
-t stellar-rs-xdr:${{ inputs.arch }}
-o type=docker,dest=/tmp/image
--build-arg REPO=https://github.com/stellar/rs-stellar-xdr.git
--build-arg REF="${{ env.XDR_REPO_REF }}" .
- name: Upload Stellar-Rs-Xdr Image
uses: actions/upload-artifact@v4
with:
name: image-rs-stellar-xdr-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/image
build:
needs: [build-stellar-core, build-stellar-horizon, build-rs-stellar-xdr, build-stellar-friendbot, build-stellar-soroban-rpc]
if: always()
outputs:
image: ${{ steps.image.outputs.name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.sha }}
- name: Download Stellar XDR
uses: actions/download-artifact@v4
with:
name: image-rs-stellar-xdr-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/stellar-xdr
- name: Download Stellar-Core Image
uses: actions/download-artifact@v4
with:
name: image-stellar-core-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/stellar-core
- name: Download Stellar-Horizon Image
uses: actions/download-artifact@v4
with:
name: image-stellar-horizon-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/stellar-horizon
- name: Download Stellar-Friendbot Image
uses: actions/download-artifact@v4
with:
name: image-stellar-friendbot-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/stellar-friendbot
- name: Download Stellar-Soroban-Rpc Image
uses: actions/download-artifact@v4
with:
name: image-stellar-soroban-rpc-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/stellar-soroban-rpc
- name: Load Stellar-Core Image
run: docker load -i /tmp/stellar-core/image
- name: Load Stellar-Horizon Image
run: docker load -i /tmp/stellar-horizon/image
- name: Load Stellar-Friendbot Image
run: docker load -i /tmp/stellar-friendbot/image
- name: Load Stellar-Soroban-Rpc Image
run: docker load -i /tmp/stellar-soroban-rpc/image
- name: Load Stellar-Rs-Xdr Image
run: docker load -i /tmp/stellar-xdr/image
- if: inputs.arch == 'arm64'
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18
with:
platforms: arm64
- id: image
name: Image Name
run: echo "name=$IMAGE" >> $GITHUB_OUTPUT
- name: Pull Base Image
run: docker pull --platform linux/${{ inputs.arch }} ubuntu:22.04
# Docker buildx cannot be used to build the dev quickstart image because
# buildx does not yet support importing existing images, like the core and
# horizon images above, into a buildx builder's cache. Buildx would be
# preferred because it can output a smaller image file faster than docker
# save can. Once buildx supports it we can update.
# https://github.com/docker/buildx/issues/847
- name: Build Quickstart Image
run: >
docker build
--platform linux/${{ inputs.arch }}
-f Dockerfile
-t $IMAGE
--label org.opencontainers.image.revision="${{ inputs.sha }}"
.
--build-arg REVISION="${{ inputs.sha }}"
--build-arg PROTOCOL_VERSION_DEFAULT="${{ inputs.protocol_version_default }}"
--build-arg STELLAR_XDR_IMAGE_REF=stellar-rs-xdr:${{ inputs.arch }}
--build-arg STELLAR_CORE_IMAGE_REF=stellar-core:${{ inputs.arch }}
--build-arg HORIZON_IMAGE_REF=stellar-horizon:${{ inputs.arch }}
--build-arg FRIENDBOT_IMAGE_REF=stellar-friendbot:${{ inputs.arch }}
--build-arg SOROBAN_RPC_IMAGE_REF=stellar-soroban-rpc:${{ inputs.arch }}
- name: Save Quickstart Image
run: docker save $IMAGE -o /tmp/image
- name: Upload Quickstart Image
uses: actions/upload-artifact@v4
with:
name: image-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/image
test:
needs: build
if: always()
strategy:
matrix: ${{ fromJSON(inputs.test_matrix) }}
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ inputs.sha }}
- name: Download Quickstart Image
uses: actions/download-artifact@v4
with:
name: image-${{ inputs.tag }}-${{ inputs.arch }}
path: /tmp/
- name: Load Quickstart Image
run: docker load -i /tmp/image
- if: inputs.arch == 'arm64'
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18
with:
platforms: arm64
- name: Prepare Logs Directory
run: mkdir -p logs
- name: Run Quickstart Image
run: >
docker run
--platform linux/${{ inputs.arch }}
--rm
-d
-p
"8000:8000"
-p "11626:11626"
-v "$PWD/logs":/var/log/supervisor
--name stellar
$IMAGE
--${{ matrix.network }}
--enable ${{ matrix.core }},${{ matrix.horizon }},${{ matrix.rpc }}
${{ matrix.options }}
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ^1
- name: Sleep until supervisor is up
run: sleep 10
- name: Run core test
if: ${{ matrix.core }}
run: |
docker logs stellar -f &
echo "supervisorctl tail -f stellar-core" | docker exec -i stellar sh &
go run test_core.go
curl http://localhost:11626/info
- name: Run horizon up test
if: ${{ matrix.horizon }}
run: |
docker logs stellar -f &
echo "supervisorctl tail -f horizon" | docker exec -i stellar sh &
go run test_horizon_up.go
curl http://localhost:8000
- name: Run horizon core up test
if: ${{ matrix.horizon && matrix.network != 'pubnet' }}
run: |
docker logs stellar -f &
echo "supervisorctl tail -f horizon" | docker exec -i stellar sh &
go run test_horizon_core_up.go
curl http://localhost:8000
- name: Run horizon ingesting test
if: ${{ matrix.horizon && matrix.network != 'pubnet' }}
run: |
docker logs stellar -f &
echo "supervisorctl tail -f stellar-core" | docker exec -i stellar sh &
echo "supervisorctl tail -f horizon" | docker exec -i stellar sh &
go run test_horizon_ingesting.go
curl http://localhost:8000
- name: Run friendbot test
if: ${{ matrix.horizon && matrix.network == 'local' }}
run: |
docker logs stellar -f &
echo "supervisorctl tail -f friendbot" | docker exec -i stellar sh &
echo "supervisorctl tail -f horizon" | docker exec -i stellar sh &
go run test_friendbot.go
- name: Run soroban rpc up test
if: ${{ matrix.rpc }}
run: |
docker logs stellar -f &
echo "supervisorctl tail -f soroban-rpc" | docker exec -i stellar sh &
go run test_soroban_rpc_up.go
- name: Run soroban rpc healthy test
if: ${{ matrix.rpc && matrix.network != 'pubnet' }}
run: |
docker logs stellar -f &
echo "supervisorctl tail -f soroban-rpc" | docker exec -i stellar sh &
go run test_soroban_rpc_healthy.go
- name: Prepare Test Logs
if: always()
run: sudo chmod -R a+r logs
- name: Upload Test Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: logs-${{ inputs.tag }}-${{ inputs.arch }}-test-${{ strategy.job-index }}
path: logs
push-pr:
# Push image to registry after build for pull requests from a local branch.
if: ${{ always() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }}
needs: build
permissions:
packages: write
statuses: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ inputs.sha }}
- id: push
uses: ./.github/actions/push
with:
head_sha: ${{ inputs.sha }}
artifact_name: image-${{ inputs.tag }}-${{ inputs.arch }}
artifact_image_file: image
arch: ${{ inputs.arch }}
image: ${{ env.IMAGE }}
registry: ${{ secrets.DOCKERHUB_TOKEN && 'docker.io' || 'ghcr.io' }}
username: ${{ secrets.DOCKERHUB_USERNAME || github.actor }}
password: ${{ secrets.DOCKERHUB_TOKEN || github.token }}
push-release:
# Push image to registry after test for master.
if: ${{ always() && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
needs: [build, test]
permissions:
packages: write
statuses: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ inputs.sha }}
- id: push
uses: ./.github/actions/push
with:
head_sha: ${{ inputs.sha }}
artifact_name: image-${{ inputs.tag }}-${{ inputs.arch }}
artifact_image_file: image
arch: ${{ inputs.arch }}
image: ${{ env.IMAGE }}
registry: ${{ secrets.DOCKERHUB_TOKEN && 'docker.io' || 'ghcr.io' }}
username: ${{ secrets.DOCKERHUB_USERNAME || github.actor }}
password: ${{ secrets.DOCKERHUB_TOKEN || github.token }}