-
Notifications
You must be signed in to change notification settings - Fork 209
405 lines (394 loc) · 15.5 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
on:
workflow_call:
secrets:
DOCKERHUB_USERNAME:
required: false
DOCKERHUB_TOKEN:
required: false
inputs:
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
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'
core_supports_enable_soroban_diagnostic_events:
description: 'Indicator whether stellar-core supports the ENABLE_SOROBAN_DIAGNOSTIC_EVENTS config'
type: 'string'
default: 'false'
core_build_runner_type:
description: 'The GitHub Runner instance type to build stellar-core on'
type: 'string'
default: 'ubuntu-latest'
go_ref:
description: 'Git ref for the stellar/go repo (stellar-horizon, stellar-friendbot)'
type: 'string'
required: true
xdr_ref:
description: 'Git ref for the stellar/rs-stellar-xdr repo'
type: 'string'
required: false
soroban_tools_ref:
description: 'Git ref for the stellar/soroban-tools repo (soroban-rpc)'
type: 'string'
required: true
soroban_rpc_build_runner_type:
description: 'The GitHub Runner instance type to build soroban-rpc on'
type: 'string'
default: 'ubuntu-latest'
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:
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
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) }}
GO_REPO_BRANCH: ${{ inputs.go_ref }}
SOROBAN_TOOLS_REPO_BRANCH: ${{ inputs.soroban_tools_ref }}
CORE_REPO: ${{ inputs.core_repo }}
CORE_REPO_REF: ${{ inputs.core_ref }}
XDR_REPO_REF: ${{ inputs.xdr_ref }}
jobs:
build-stellar-core:
runs-on: ${{ inputs.core_build_runner_type }}
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: steps.cache.outputs.cache-hit != 'true' && inputs.arch == 'arm64'
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18
with:
platforms: arm64
- if: steps.cache.outputs.cache-hit != 'true'
uses: docker/setup-buildx-action@5146db6c4d81fbfd508899f851bbb3883a96ff9f
- if: steps.cache.outputs.cache-hit != 'true'
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@v2
with:
name: image-stellar-core-${{ inputs.arch }}
path: /tmp/image
# don't use caches on horizon builds as the git ref for it can be a branch name that refers to
# different commits over time, cache key won't invalidate correctly.
build-stellar-horizon:
runs-on: ubuntu-latest
steps:
- name: Checkout Quickstart for Horizon docker file
uses: actions/checkout@v3
with:
ref: ${{ env.HEAD_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.GO_REPO_BRANCH }}" .
- name: Upload Stellar-Horizon Image
uses: actions/upload-artifact@v2
with:
name: image-stellar-horizon-${{ inputs.arch }}
path: /tmp/image
# don't use caches on friendbot builds as the git ref for it can be a branch name that refers to
# different commits over time, cache key won't invalidate correctly.
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.GO_REPO_BRANCH }}
- name: Upload Stellar-Friendbot Image
uses: actions/upload-artifact@v2
with:
name: image-stellar-friendbot-${{ inputs.arch }}
path: /tmp/image
build-stellar-soroban-rpc:
runs-on: ${{ inputs.soroban_rpc_build_runner_type }}
steps:
- id: cache
uses: actions/cache@v3
with:
path: /tmp/image
key: image-stellar-soroban-rpc-${{ inputs.arch }}-${{ env.SOROBAN_TOOLS_REPO_BRANCH }}
- if: steps.cache.outputs.cache-hit != 'true' && inputs.arch == 'arm64'
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18
with:
platforms: arm64
- if: steps.cache.outputs.cache-hit != 'true'
uses: docker/setup-buildx-action@5146db6c4d81fbfd508899f851bbb3883a96ff9f
- if: steps.cache.outputs.cache-hit != 'true'
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-tools.git#${{ env.SOROBAN_TOOLS_REPO_BRANCH }}
- name: Upload Stellar-Soroban-Rpc Image
uses: actions/upload-artifact@v2
with:
name: image-stellar-soroban-rpc-${{ inputs.arch }}
path: /tmp/image
build-rs-stellar-xdr:
runs-on: ubuntu-latest
steps:
- name: Checkout Quickstart for Horizon docker file
uses: actions/checkout@v3
with:
ref: ${{ env.HEAD_SHA }}
- id: cache
uses: actions/cache@v3
with:
path: /tmp/image
key: image-rs-stellar-xdr-${{ inputs.arch }}-${{ env.XDR_REPO_REF }}
- if: steps.cache.outputs.cache-hit != 'true' && inputs.arch == 'arm64'
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18
with:
platforms: arm64
- if: steps.cache.outputs.cache-hit != 'true'
uses: docker/setup-buildx-action@5146db6c4d81fbfd508899f851bbb3883a96ff9f
- if: steps.cache.outputs.cache-hit != 'true'
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@v2
with:
name: image-rs-stellar-xdr-${{ inputs.arch }}
path: /tmp/image
build:
needs: [build-stellar-core, build-stellar-horizon, build-rs-stellar-xdr, build-stellar-friendbot, build-stellar-soroban-rpc]
outputs:
image: ${{ steps.image.outputs.name }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.HEAD_SHA }}
- name: Download Stellar XDR
uses: actions/download-artifact@v2
with:
name: image-rs-stellar-xdr-${{ inputs.arch }}
path: /tmp/stellar-xdr
- name: Download Stellar-Core Image
uses: actions/download-artifact@v2
with:
name: image-stellar-core-${{ inputs.arch }}
path: /tmp/stellar-core
- name: Download Stellar-Horizon Image
uses: actions/download-artifact@v2
with:
name: image-stellar-horizon-${{ inputs.arch }}
path: /tmp/stellar-horizon
- name: Download Stellar-Friendbot Image
uses: actions/download-artifact@v2
with:
name: image-stellar-friendbot-${{ inputs.arch }}
path: /tmp/stellar-friendbot
- name: Download Stellar-Soroban-Rpc Image
uses: actions/download-artifact@v2
with:
name: image-stellar-soroban-rpc-${{ 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="${{ env.HEAD_SHA }}"
.
--build-arg REVISION="${{ env.HEAD_SHA }}"
--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 }}
--build-arg CORE_SUPPORTS_ENABLE_SOROBAN_DIAGNOSTIC_EVENTS=${{ inputs.core_supports_enable_soroban_diagnostic_events }}
- name: Save Quickstart Image
run: docker save $IMAGE -o /tmp/image
- name: Upload Quickstart Image
uses: actions/upload-artifact@v2
with:
name: image-${{ inputs.arch }}
path: /tmp/image
test:
needs: build
strategy:
matrix: ${{ fromJSON(inputs.test_matrix) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ env.HEAD_SHA }}
- name: Download Quickstart Image
uses: actions/download-artifact@v2
with:
name: image-${{ 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: Run Quickstart Image
run: docker run --platform linux/${{ inputs.arch }} --rm -d -p "8000:8000" -p "11626:11626" --name stellar $IMAGE --${{ matrix.network }} ${{ 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
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
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 ingesting test
if: ${{ 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.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 test
if: ${{ contains(matrix.options, '--enable-soroban-rpc') }}
run: |
docker logs stellar -f &
echo "supervisorctl tail -f soroban-rpc" | docker exec -i stellar sh &
go run test_soroban_rpc_up.go
push-pr:
# Push image to registry after build for pull requests from a local branch.
if: ${{ 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: ${{ env.HEAD_SHA }}
- id: push
uses: ./.github/actions/push
with:
head_sha: ${{ env.HEAD_SHA }}
artifact_name: image-${{ 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: ${{ 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: ${{ env.HEAD_SHA }}
- id: push
uses: ./.github/actions/push
with:
head_sha: ${{ env.HEAD_SHA }}
artifact_name: image-${{ 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 }}