-
Notifications
You must be signed in to change notification settings - Fork 341
364 lines (362 loc) · 17.6 KB
/
beekeeper.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
name: Beekeeper
on:
repository_dispatch:
types: [trigger-beekeeper, beekeeper]
pull_request:
branches:
- "**"
env:
K3S_VERSION: "v1.21.14+k3s1"
REPLICA: 3
RUN_TYPE: "PR RUN"
SETUP_CONTRACT_IMAGE_TAG: "0.9.8"
BEELOCAL_BRANCH: "main"
BEEKEEPER_BRANCH: "master"
BEEKEEPER_METRICS_ENABLED: false
REACHABILITY_OVERRIDE_PUBLIC: true
BATCHFACTOR_OVERRIDE_PUBLIC: 2
TIMEOUT: 10m
BUCKET_NAME: swarm-beekeeper-artifacts
AWS_ACCESS_KEY_ID: ${{ secrets.DO_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DO_AWS_SECRET_ACCESS_KEY }}
AWS_EC2_METADATA_DISABLED: true
AWS_ENDPOINT: fra1.digitaloceanspaces.com
VERTAG: ${GITHUB_RUN_ID}
jobs:
init:
name: Init
runs-on: ubuntu-latest
outputs:
msg: ${{ steps.commit.outputs.msg }}
steps:
- name: Checkout
uses: actions/checkout@v3
if: github.event.action != 'beekeeper'
with:
fetch-depth: 0
- name: Checkout
uses: actions/checkout@v3
if: github.event.action == 'beekeeper'
with:
fetch-depth: 0
ref: ${{ github.event.client_payload.ref }}
- name: Setup Go
uses: actions/setup-go@v3
with:
cache: true
go-version-file: go.mod
- name: Get Commit Message
id: commit
run: |
MSG=$(git log --format=%B -n 1 ${{github.event.after}})
echo "msg=${MSG}" >> $GITHUB_OUTPUT
- name: Build - 0
run: |
make binary
mv dist/bee bee-0
- name: Apply patches and build - 1
run: |
# patch pkg/postage/postagecontract/contract.go .github/patches/postagecontract.patch
# patch pkg/postage/service.go .github/patches/postageservice.patch
make binary
mv dist/bee bee-1
- name: Apply patches and build - 2
run: |
# patch pkg/postage/batchstore/reserve.go .github/patches/postagereserve_gc.patch
make binary
mv dist/bee bee-2
- name: Install beekeeper
run: |
export PATH=$(pwd):$PATH
timeout ${TIMEOUT} make beekeeper BEEKEEPER_INSTALL_DIR=$(pwd)
mv ~/.beekeeper.yaml .beekeeper.yaml
mv ~/.beekeeper/local.yaml local.yaml
- uses: actions/upload-artifact@v3
with:
name: temp-artifacts
path: |
Dockerfile.goreleaser
Makefile
bee-0
bee-1
bee-2
beekeeper
local.yaml
.beekeeper.yaml
.github/bin/beekeeper_artifacts.sh
retention-days: 5
beekeeper:
name: Integration tests
runs-on: ubuntu-latest
needs: [init]
steps:
- name: Cache
uses: actions/cache@v3
with:
path: |
/tmp/k3s-${{ env.K3S_VERSION }}-v3
key: k3s-${{ env.K3S_VERSION }}-v3
- name: "Download Artifact"
uses: actions/download-artifact@v3
with:
name: temp-artifacts
- name: Unpack artifacts
run: |
chmod +x bee-1 beekeeper .github/bin/beekeeper_artifacts.sh
mv .beekeeper.yaml ~/.beekeeper.yaml
mkdir ~/.beekeeper && mv local.yaml ~/.beekeeper/local.yaml
mv bee-1 bee
sudo mv beekeeper /usr/local/bin/beekeeper
- name: Prepare local cluster
run: |
timeout ${TIMEOUT} make beelocal OPTS='ci skip-vet' ACTION=prepare
- name: Set kube config
run: |
mkdir -p ~/.kube
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
- name: Set local cluster
run: |
timeout ${TIMEOUT} make deploylocal BEEKEEPER_CLUSTER=local-dns
- name: Test staking
id: stake
run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks ci-stake
- name: Test pingpong
id: pingpong
run: timeout ${TIMEOUT} bash -c 'until beekeeper check --cluster-name local-dns --checks ci-pingpong; do echo "waiting for pingpong..."; sleep .3; done'
- name: Test fullconnectivity
id: fullconnectivity
run: timeout ${TIMEOUT} bash -c 'until beekeeper check --cluster-name local-dns --checks=ci-full-connectivity; do echo "waiting for full connectivity..."; sleep .3; done'
- name: Test settlements
id: settlements
run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks=ci-settlements
- name: Sleep for time allowance to replenish
run: sleep 2
- name: Test pss
id: pss
run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks=ci-pss
- name: Test soc
id: soc
run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks=ci-soc
- name: Test pushsync (chunks)
id: pushsync-chunks-1
run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks=ci-pushsync-chunks
- name: Test pushsync (light mode chunks)
id: pushsync-chunks-2
run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks=ci-pushsync-light-chunks
- name: Test retrieval
id: retrieval
run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks=ci-retrieval
- name: Test manifest
id: manifest
run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks=ci-manifest
- name: Test content availability
id: content-availability
run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks=ci-content-availability
- name: Test authenticate
id: authenticate
run: timeout ${TIMEOUT} bash -c 'until beekeeper check --cluster-name local-dns --checks ci-authenticate; do echo "waiting for auth..."; sleep .3; done'
- name: Test postage stamps
id: postage-stamps
run: timeout ${TIMEOUT} beekeeper check --cluster-name local-dns --checks ci-postage
- name: Collect debug artifacts
if: failure()
run: |
bash .github/bin/beekeeper_artifacts.sh local-dns
export FAILED='no-test'
if ${{ steps.pingpong.outcome=='failure' }}; then FAILED=pingpong; fi
if ${{ steps.fullconnectivity.outcome=='failure' }}; then FAILED=fullconnectivity; fi
if ${{ steps.settlements.outcome=='failure' }}; then FAILED=settlements; fi
if ${{ steps.pss.outcome=='failure' }}; then FAILED=pss; fi
if ${{ steps.soc.outcome=='failure' }}; then FAILED=soc; fi
if ${{ steps.pushsync-chunks-1.outcome=='failure' }}; then FAILED=pushsync-chunks-1; fi
if ${{ steps.pushsync-chunks-2.outcome=='failure' }}; then FAILED=pushsync-chunks-2; fi
if ${{ steps.retrieval.outcome=='failure' }}; then FAILED=retrieval; fi
if ${{ steps.manifest.outcome=='failure' }}; then FAILED=manifest; fi
if ${{ steps.content-availability.outcome=='failure' }}; then FAILED=content-availability; fi
curl -sSf -X POST -H "Content-Type: application/json" -d "{\"text\": \"**${RUN_TYPE}** Beekeeper Error\nBranch: \`${{ github.head_ref }}\`\nUser: @${{ github.event.pull_request.user.login }}\nDebugging artifacts: [click](https://$BUCKET_NAME.$AWS_ENDPOINT/artifacts_$VERTAG.tar.gz)\nStep failed: \`${FAILED}\`\"}" https://beehive.ethswarm.org/hooks/${{ secrets.TUNSHELL_KEY }}
echo "Failed test: ${FAILED}"
- name: Create tunshell session for debug
if: failure() && contains(needs.init.outputs.msg, '[debug]')
run: |
KEYS=$(curl -sSf -X POST https://eu.relay.tunshell.com/api/sessions)
curl -sSf -X POST -H "Content-Type: application/json" -d "{\"text\": \"**Integration tests** Beekeeper Debug\nBranch: \`${{ github.head_ref }}\`\nUser: @${{ github.event.pull_request.user.login }}\nDebug shell: \`sh <(curl -sSf https://lets.tunshell.com/init.sh) L $(echo $KEYS | jq -r .peer2_key) \${TUNSHELL_SECRET} eu.relay.tunshell.com\`\"}" https://beehive.ethswarm.org/hooks/${{ secrets.TUNSHELL_KEY }}
echo "Connect to github actions node using"
echo "sh <(curl -sSf https://lets.tunshell.com/init.sh) L $(echo $KEYS | jq -r .peer2_key) \${TUNSHELL_SECRET} eu.relay.tunshell.com"
curl -sSf https://lets.tunshell.com/init.sh | sh /dev/stdin T $(echo $KEYS | jq -r .peer1_key) ${{ secrets.TUNSHELL_SECRET }} eu.relay.tunshell.com
- uses: actions/upload-artifact@v3
if: failure()
with:
name: debug-dump
path: dump/
beekeeper-clef:
name: Integration tests (clef enabled)
runs-on: ubuntu-latest
needs: [init]
steps:
- name: Cache
uses: actions/cache@v3
with:
path: |
/tmp/k3s-${{ env.K3S_VERSION }}-v3
key: k3s-${{ env.K3S_VERSION }}-v3
- name: "Download Artifact"
uses: actions/download-artifact@v3
with:
name: temp-artifacts
- name: Unpack artifacts
run: |
chmod +x bee-1 beekeeper
mv .beekeeper.yaml ~/.beekeeper.yaml
mkdir ~/.beekeeper && mv local.yaml ~/.beekeeper/local.yaml
mv bee-1 bee
sudo mv beekeeper /usr/local/bin/beekeeper
- name: Prepare testing cluster (Node connection and clef enabled)
run: |
timeout ${TIMEOUT} make beelocal OPTS='ci skip-vet' ACTION=prepare
- name: Set kube config
run: |
mkdir -p ~/.kube
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
- name: Set local cluster
run: |
timeout ${TIMEOUT} make deploylocal BEEKEEPER_CLUSTER=local-clef
- name: Test pingpong
id: pingpong
run: timeout ${TIMEOUT} bash -c 'until beekeeper check --cluster-name local-clef --checks ci-pingpong; do echo "waiting for pingpong..."; sleep .3; done'
- name: Test fullconnectivity
id: fullconnectivity
run: timeout ${TIMEOUT} bash -c 'until beekeeper check --cluster-name local-clef --checks=ci-full-connectivity; do echo "waiting for full connectivity..."; sleep .3; done'
- name: Test settlements
id: settlements
run: timeout ${TIMEOUT} beekeeper check --cluster-name local-clef --checks=ci-settlements-clef
- name: Debug workflow if failed
if: failure()
run: |
bash .github/bin/beekeeper_artifacts.sh local-clef
export FAILED='no-test'
if ${{ steps.pingpong.outcome=='failure' }}; then FAILED=pingpong; fi
if ${{ steps.fullconnectivity.outcome=='failure' }}; then FAILED=fullconnectivity; fi
if ${{ steps.settlements.outcome=='failure' }}; then FAILED=settlements; fi
curl -sSf -X POST -H "Content-Type: application/json" -d "{\"text\": \"**${RUN_TYPE}** Beekeeper Error\nBranch: \`${{ github.head_ref }}\`\nUser: @${{ github.event.pull_request.user.login }}\nDebugging artifacts: [click](https://$BUCKET_NAME.$AWS_ENDPOINT/artifacts_$VERTAG.tar.gz)\nStep failed: \`${FAILED}\`\"}" https://beehive.ethswarm.org/hooks/${{ secrets.TUNSHELL_KEY }}
echo "\nFailed test: ${FAILED}"
- name: Create tunshell session for debug
if: failure() && contains(needs.init.outputs.msg, '[debug]')
run: |
KEYS=$(curl -sSf -X POST https://eu.relay.tunshell.com/api/sessions)
curl -sSf -X POST -H "Content-Type: application/json" -d "{\"text\": \"**Integration tests (clef enabled)** Beekeeper Debug\nBranch: \`${{ github.head_ref }}\`\nUser: @${{ github.event.pull_request.user.login }}\nDebug shell: \`sh <(curl -sSf https://lets.tunshell.com/init.sh) L $(echo $KEYS | jq -r .peer2_key) \${TUNSHELL_SECRET} eu.relay.tunshell.com\`\"}" https://beehive.ethswarm.org/hooks/${{ secrets.TUNSHELL_KEY }}
echo "Connect to github actions node using"
echo "sh <(curl -sSf https://lets.tunshell.com/init.sh) L $(echo $KEYS | jq -r .peer2_key) \${TUNSHELL_SECRET} eu.relay.tunshell.com"
curl -sSf https://lets.tunshell.com/init.sh | sh /dev/stdin T $(echo $KEYS | jq -r .peer1_key) ${{ secrets.TUNSHELL_SECRET }} eu.relay.tunshell.com
- uses: actions/upload-artifact@v3
if: failure()
with:
name: debug-dump
path: dump/
beekeeper-si:
name: Integration tests (storage incentives)
needs: [init]
runs-on: ubuntu-latest
steps:
- name: Cache
uses: actions/cache@v3
with:
path: |
/tmp/k3s-${{ env.K3S_VERSION }}-v3
key: k3s-${{ env.K3S_VERSION }}-v3
- name: "Download Artifact"
uses: actions/download-artifact@v3
with:
name: temp-artifacts
- name: Unpack artifacts
run: |
chmod +x bee-2 beekeeper
mv .beekeeper.yaml ~/.beekeeper.yaml
mkdir ~/.beekeeper && mv local.yaml ~/.beekeeper/local.yaml
mv bee-2 bee
sudo mv beekeeper /usr/local/bin/beekeeper
- name: Prepare testing cluster (storage incentives setup)
run: |
timeout ${TIMEOUT} make beelocal OPTS='ci skip-vet' ACTION=prepare
- name: Set kube config
run: |
mkdir -p ~/.kube
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
- name: Set testing cluster (storage incentives setup)
run: |
timeout ${TIMEOUT} make deploylocal BEEKEEPER_CLUSTER=local-gc
- name: Test pingpong
id: pingpong
run: timeout ${TIMEOUT} bash -c 'until beekeeper check --cluster-name local-gc --checks ci-pingpong; do echo "waiting for pingpong..."; sleep .3; done'
# GC test requires custom patches which no longer work with the contract
# - name: Test gc
# id: gc-chunk
# run: timeout ${TIMEOUT} beekeeper check --cluster-name local-gc --checks=ci-gc
- name: Debug workflow if failed
if: failure()
run: |
bash .github/bin/beekeeper_artifacts.sh local-gc
export FAILED='no-test'
if ${{ steps.pingpong.outcome=='failure' }}; then FAILED=pingpong; fi
if ${{ steps.gc-chunk.outcome=='failure' }}; then FAILED=gc-chunk; fi
curl -sSf -X POST -H "Content-Type: application/json" -d "{\"text\": \"**${RUN_TYPE}** Beekeeper Error\nBranch: \`${{ github.head_ref }}\`\nUser: @${{ github.event.pull_request.user.login }}\nDebugging artifacts: [click](https://$BUCKET_NAME.$AWS_ENDPOINT/artifacts_$VERTAG.tar.gz)\nStep failed: \`${FAILED}\`\"}" https://beehive.ethswarm.org/hooks/${{ secrets.TUNSHELL_KEY }}
echo "Failed test: ${FAILED}"
- name: Create tunshell session for debug
if: failure() && contains(needs.init.outputs.msg, '[debug]')
run: |
KEYS=$(curl -sSf -X POST https://eu.relay.tunshell.com/api/sessions)
curl -sSf -X POST -H "Content-Type: application/json" -d "{\"text\": \"**Integration tests (storage incentives)** Beekeeper Debug\nBranch: \`${{ github.head_ref }}\`\nUser: @${{ github.event.pull_request.user.login }}\nDebug shell: \`sh <(curl -sSf https://lets.tunshell.com/init.sh) L $(echo $KEYS | jq -r .peer2_key) \${TUNSHELL_SECRET} eu.relay.tunshell.com\`\"}" https://beehive.ethswarm.org/hooks/${{ secrets.TUNSHELL_KEY }}
echo "Connect to github actions node using"
echo "sh <(curl -sSf https://lets.tunshell.com/init.sh) L $(echo $KEYS | jq -r .peer2_key) \${TUNSHELL_SECRET} eu.relay.tunshell.com"
curl -sSf https://lets.tunshell.com/init.sh | sh /dev/stdin T $(echo $KEYS | jq -r .peer1_key) ${{ secrets.TUNSHELL_SECRET }} eu.relay.tunshell.com
- uses: actions/upload-artifact@v3
if: failure()
with:
name: debug-dump
path: dump/
retag:
name: Retag and Trigger ArgoCD
env:
TIMEOUT: 10m
needs: [beekeeper, beekeeper-si, beekeeper-clef]
runs-on: ubuntu-latest
steps:
- name: "Download Artifact"
uses: actions/download-artifact@v3
with:
name: temp-artifacts
- name: Unpack artifacts
run: |
chmod +x bee-0
mv bee-0 bee
- name: Build image
run: |
timeout ${TIMEOUT} make beelocal ACTION=build OPTS='ci skip-vet skip-push'
- name: Retag Docker image and push
if: github.ref == 'refs/heads/master' && github.event.action != 'beekeeper' && success()
run: |
docker tag k3d-registry.localhost:5000/ethersphere/bee:latest ethersphere/bee:latest
docker tag k3d-registry.localhost:5000/ethersphere/bee:latest quay.io/ethersphere/bee:latest
printf ${{ secrets.DOCKERHUB_PASSWORD }} | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
printf ${{ secrets.QUAY_PASSWORD }} | docker login --username ${{ secrets.QUAY_USERNAME }} quay.io --password-stdin
docker push ethersphere/bee:latest
docker push quay.io/ethersphere/bee:latest
echo RUN_TYPE="MERGE RUN" >> $GITHUB_ENV
- name: Trigger Bee Factory latest build
if: github.ref == 'refs/heads/master' && github.event.action != 'beekeeper' && success()
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.GHA_PAT_BASIC }}
repository: ethersphere/bee-factory
event-type: build-images
client-payload: '{"tag": "latest"}'
- name: Set IMAGE_DIGEST variable
if: github.ref == 'refs/heads/master' && github.event.action != 'beekeeper' && success()
run: echo "IMAGE_DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' ethersphere/bee:latest | cut -d'@' -f 2 | tr -d '\n')" >> $GITHUB_ENV
- name: Trigger ArgoCD
if: github.ref == 'refs/heads/master' && github.event.action != 'beekeeper' && success()
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.GHA_PAT_BASIC }}
repository: ethersphere/bee-argo
event-type: trigger-argo
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "digest": "${{ env.IMAGE_DIGEST }}"}'