-
Notifications
You must be signed in to change notification settings - Fork 467
362 lines (338 loc) · 16.4 KB
/
run-a-single-node-from-branch.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
name: "Run a node with selected configuration"
on:
workflow_dispatch:
inputs:
network:
description: "Select a network on which You want to run a node"
default: "mainnet"
required: true
type: choice
options:
- mainnet
- gnosis
- sepolia
- chiado
- holesky
- op-mainnet
- op-sepolia
- base-mainnet
- base-sepolia
- energyweb
- volta
cl_client:
description: "Select Consensus Layer Client to run node against (for Volta or Energyweb just set any - it will be omitted)"
default: ""
required: true
type: choice
options:
- lighthouse
- lodestar
- prysm
- teku
- nimbus
- nimbus_ws
cl_custom_image:
description: "In case of need to run non-default cl image (different than actually supported by Sedge) put it in there"
default: ""
required: false
config:
description: "Select a config file which will be selected for tests."
default: "default.json"
required: true
type: choice
options:
- default.json
- archiveSync.json
- fastSync.json
- fullSync.json
- fuzzer.json
non_validator_mode:
description: "If checked, node will be started in NonValidator mode (OldBodies and OldReceipts will not be synced)"
default: true
type: boolean
additional_nethermind_flags:
description: 'Provide any additional flags to the Nethermind L1 node in space-separated format. Example: "JsonRpc.Enabled=false Sync.SnapSync=false".'
default: ""
required: false
additional_cl_flags:
description: 'Provide any additional flags to the CL client in space-separated format. Example: "clflag1=1 clflag2=2".'
default: ""
required: false
additional_options:
description: "A Json property which allows to customize node even more"
default: '{"timeout":"24", "default_dockerfile":"Dockerfile", "default_dockerfile_build_type":"release", "ssh_keys":"", "allowed_ips":"", "custom_machine_type": ""}'
additional_optimism_options:
description: "Extra options to configure optimism node"
default: '{"l1_nethermind_image":"", "op_node_image":"", "op_el_extra_flags":"", "op_cl_extra_flags":"", "layer1_el_endpoint":"", "layer1_cl_endpoint":""}'
convert_to_paprika:
description: "If checked, will attempt to convert node to paprika schema using 'paprika' branch."
default: false
type: boolean
workflow_call:
inputs:
smoke_tests_ref:
description: "Ref of the smoke tests repository to be used for smoke tests"
default: "main"
required: false
type: string
nethermind_repo_ref:
description: "Ref of the nethermind repo in case it is needed to be changed"
default: ""
required: false
type: string
custom_run_id:
description: "Run ID used for artifacts save"
default: ""
required: false
type: string
network:
description: "Select a network on which You want to run a node"
default: "mainnet"
required: false
type: string
cl_client:
description: "Select Consensus Layer Client to run node against"
default: "lighthouse"
required: false
type: string
cl_custom_image:
description: "In case of need to run non-default cl image (different than actually supported by Sedge) put it in there"
default: ""
required: false
type: string
config:
description: "Select a config file which will be selected for tests."
default: "default.json"
required: false
type: string
non_validator_mode:
description: "If checked, node will be started in NonValidator mode (OldBodies and oldReceipts will not be synced)"
default: true
type: boolean
additional_nethermind_flags:
type: string
description: 'Provide any additional flags to the Nethermind in space-separated format. Example: "JsonRpc.Enabled=false Sync.SnapSync=false".'
default: ""
required: false
additional_cl_flags:
type: string
description: 'Provide any additional flags to the CL client in space-separated format. Example: "clflag1=1 clflag2=2".'
default: ""
required: false
additional_options:
type: string
description: "A Json property which allows to customize node even more"
default: '{"timeout":"24", "default_dockerfile":"Dockerfile", "default_dockerfile_build_type":"release", "ssh_keys":"", "allowed_ips":"", "custom_machine_type": ""}'
required: false
additional_optimism_options:
type: string
description: "Extra options to configure optimism node"
default: '{"l1_nethermind_image":"", "op_node_image":"", "op_el_extra_flags":"", "op_cl_extra_flags":"", "layer1_el_endpoint":"", "layer1_cl_endpoint":""}'
required: false
convert_to_paprika:
description: "If checked, will attempt to convert node to paprika schema using 'paprika' branch."
default: false
type: boolean
outputs:
base_tag:
description: ""
value: ${{ jobs.create_docker_image.outputs.base_tag }}
run_id:
description: ""
value: ${{ jobs.trigger_node_and_vm_creation.outputs.run_id }}
rpc_url:
description: ""
value: ${{ jobs.trigger_node_and_vm_creation.outputs.rpc_url }}
jobs:
create_docker_image:
runs-on: ubuntu-latest
outputs:
base_tag: ${{ steps.set-base-tag.outputs.base_tag }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Authenticate App
id: gh-app
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Prepare docker tag
id: prepare_ref
run: |
REF_NAME=${{ inputs.nethermind_repo_ref || github.ref }}
CLEAN_REF=$(echo "${REF_NAME/refs\/heads\//}" | sed 's/[^a-zA-Z0-9._-]/-/g')
echo "CLEAN_REF=$CLEAN_REF" >> $GITHUB_ENV
- name: Set BASE_TAG
id: set-base-tag
env:
GITHUB_USERNAME: ${{ github.actor }}
run: |
BASE_TAG="${GITHUB_USERNAME:0:1}$(shuf -i 1000-9999 -n 1)"
echo "BASE_TAG=$BASE_TAG" >> $GITHUB_ENV
echo "base_tag=$BASE_TAG" >> $GITHUB_OUTPUT
- name: Creating a node with NodeName="DevNode-${{ github.actor }}-${{ env.BASE_TAG }}-${{ env.CLEAN_REF }}-${{ inputs.network }}-${{ inputs.cl_client }}"
run: echo "NodeName='DevNode-${{ github.actor }}-${{ env.BASE_TAG }}-${{ env.CLEAN_REF }}-${{ inputs.network }}-${{ inputs.cl_client }}'"
- name: Extract dockerfile from additional_options
id: extract_dockerfile
run: |
echo "dockerfile=$(echo '${{ inputs.additional_options }}' | jq -r .default_dockerfile)" >> $GITHUB_OUTPUT
echo "build-config=$(echo '${{ inputs.additional_options }}' | jq -r .default_dockerfile_build_type | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Set Repo and Org Variables
run: |
echo "ORG_NAME=${{ github.repository_owner }}" >> $GITHUB_ENV
echo "REPO_NAME=${{ github.event.repository.name }}" >> $GITHUB_ENV
- name: Check if master branch and default additional_options
id: check_conditions
run: |
ref="${{ inputs.nethermind_repo_ref || github.ref }}"
if [ -z "$ref" ]; then
ref="${{ github.ref }}"
fi
# Append "refs/heads/" prefix if it's not already there
if [[ $ref != refs/heads/* ]]; then
ref="refs/heads/$ref"
fi
if
[[ "$ref" == "refs/heads/master" || $ref == refs/heads/release* || "$ref" == "refs/heads/paprika" ]] &&
[[ "${{ steps.extract_dockerfile.outputs.dockerfile }}" == "Dockerfile" ]] &&
[[ "${{ steps.extract_dockerfile.outputs.build-config }}" == "release" ]]; then
echo "skip_docker_build=true" >> $GITHUB_OUTPUT
else
echo "skip_docker_build=false" >> $GITHUB_OUTPUT
fi
- name: Trigger Docker Build Action with Cleaned Ref
if: steps.check_conditions.outputs.skip_docker_build != 'true'
uses: benc-uk/workflow-dispatch@v1
env:
ADDITIONAL_OPTIONS: ${{ inputs.additional_options }}
with:
workflow: publish-docker.yml
ref: "${{ inputs.nethermind_repo_ref || github.ref }}"
token: "${{ steps.gh-app.outputs.token }}"
inputs: '{
"tag": "${{ env.CLEAN_REF }}",
"dockerfile": "${{ steps.extract_dockerfile.outputs.dockerfile }}",
"build-config": "${{ steps.extract_dockerfile.outputs.build-config }}"
}'
- name: Wait for Docker Build Action to complete
if: steps.check_conditions.outputs.skip_docker_build != 'true'
env:
GITHUB_TOKEN: ${{ steps.gh-app.outputs.token }}
WORKFLOW_ID: "publish-docker.yml"
MAX_WAIT_MINUTES: "5"
INTERVAL: "5"
TIMEOUT: '20'
ORG_NAME: ${{ env.ORG_NAME }}
REPO_NAME: ${{ env.REPO_NAME }}
REF: ${{ inputs.nethermind_repo_ref || github.ref }}
run: |
chmod +x scripts/wait-for-workflow-completed.sh
./scripts/wait-for-workflow-completed.sh
working-directory: ${{ github.workspace }}
trigger_node_and_vm_creation:
needs: create_docker_image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Authenticate App
id: gh-app
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
repositories: "nethermind,post-merge-smoke-tests"
- name: Prepare docker tag
id: prepare_ref
run: |
REF_NAME=${{ inputs.nethermind_repo_ref || github.ref }}
CLEAN_REF=$(echo "${REF_NAME/refs\/heads\//}" | sed 's/[^a-zA-Z0-9._-]/-/g')
echo "CLEAN_REF=$CLEAN_REF" >> $GITHUB_ENV
- name: Extract Variables
id: extract_variables
run: |
echo "BASE_TAG=${{ needs.create_docker_image.outputs.base_tag }}" >> $GITHUB_ENV
echo "timeout=$(echo '${{ inputs.additional_options }}' | jq -r .timeout)" >> $GITHUB_OUTPUT
echo "ssh_keys=$(echo '${{ inputs.additional_options }}' | jq -r .ssh_keys)" >> $GITHUB_OUTPUT
echo "allowed_ips=$(echo '${{ inputs.additional_options }}' | jq -r .allowed_ips)" >> $GITHUB_OUTPUT
echo "custom_machine_type=$(echo '${{ inputs.additional_options }}' | jq -r .custom_machine_type)" >> $GITHUB_OUTPUT
echo "l1_nethermind_image=$(echo '${{ inputs.additional_optimism_options }}' | jq -r .l1_nethermind_image)" >> $GITHUB_OUTPUT
echo "op_node_image=$(echo '${{ inputs.additional_optimism_options }}' | jq -r .op_node_image)" >> $GITHUB_OUTPUT
echo "op_el_extra_flags=$(echo '${{ inputs.additional_optimism_options }}' | jq -r .op_el_extra_flags)" >> $GITHUB_OUTPUT
echo "op_cl_extra_flags=$(echo '${{ inputs.additional_optimism_options }}' | jq -r .op_cl_extra_flags)" >> $GITHUB_OUTPUT
echo "layer1_el_endpoint=$(echo '${{ inputs.additional_optimism_options }}' | jq -r .layer1_el_endpoint)" >> $GITHUB_OUTPUT
echo "layer1_cl_endpoint=$(echo '${{ inputs.additional_optimism_options }}' | jq -r .layer1_cl_endpoint)" >> $GITHUB_OUTPUT
if [[ ${{ inputs.network }} == base-* ]] || [[ ${{ inputs.network }} == op-* ]]; then
echo "Forcing NON_VALIDATOR_MODE=false for OP chains"
echo "NON_VALIDATOR_MODE=false" >> $GITHUB_OUTPUT
else
echo "NON_VALIDATOR_MODE=${{ inputs.non_validator_mode }}" >> $GITHUB_OUTPUT
fi
- name: Trigger Node creation Repo Action
uses: benc-uk/workflow-dispatch@v1
with:
workflow: run-single-node.yml
repo: NethermindEth/post-merge-smoke-tests
ref: "main"
token: "${{ steps.gh-app.outputs.token }}"
inputs: '{
"github_username": "${{ github.actor }}",
"base_tag": "${{ env.BASE_TAG }}",
"config_file": "${{ inputs.config }}",
"nethermind_branch": "${{ env.CLEAN_REF }}",
"network": "${{ inputs.network }}",
"cl_client": "${{ inputs.cl_client }}",
"additional_options": "{\"cl_custom_image\":\"${{ inputs.cl_custom_image }}\", \"timeout\":\"${{ steps.extract_variables.outputs.timeout }}\", \"non_validator_mode\":${{ steps.extract_variables.outputs.NON_VALIDATOR_MODE }}, \"additional_nethermind_flags\":\"${{ inputs.additional_nethermind_flags }}\", \"additional_cl_flags\":\"${{ inputs.additional_cl_flags }}\", \"ssh_keys\":\"${{ steps.extract_variables.outputs.ssh_keys }}\", \"allowed_ips\":\"${{ steps.extract_variables.outputs.allowed_ips }}\", \"custom_machine_type\":\"${{ steps.extract_variables.outputs.custom_machine_type }}\", \"convert_to_paprika\": \"${{ inputs.convert_to_paprika }}\"}",
"additional_optimism_options": "{\"l1_nethermind_image\":\"${{ steps.extract_variables.outputs.l1_nethermind_image}}\", \"op_node_image\":\"${{ steps.extract_variables.outputs.op_node_image}}\", \"op_el_extra_flags\":\"${{ steps.extract_variables.outputs.op_el_extra_flags}}\", \"op_cl_extra_flags\":\"${{ steps.extract_variables.outputs.op_cl_extra_flags}}\", \"layer1_el_endpoint\":\"${{ steps.extract_variables.outputs.layer1_el_endpoint}}\", \"layer1_cl_endpoint\":\"${{ steps.extract_variables.outputs.layer1_cl_endpoint}}\"}"
}'
- name: Wait for creation of node
env:
GITHUB_TOKEN: ${{ steps.gh-app.outputs.token }}
WORKFLOW_ID: "run-single-node.yml"
MAX_WAIT_MINUTES: "5"
INTERVAL: "5"
TIMEOUT: "20"
ORG_NAME: "NethermindEth"
REPO_NAME: "post-merge-smoke-tests"
NAME_FILTER: ${{ env.BASE_TAG }}
REF: "main"
run: |
chmod +x scripts/wait-for-workflow-completed.sh
./scripts/wait-for-workflow-completed.sh | tee script-output.txt
run_id=$(grep -oP 'Run ID: \K\d+' script-output.txt)
echo "Run ID extracted is: $run_id"
echo "RUN_ID=$run_id" >> $GITHUB_ENV
working-directory: ${{ github.workspace }}
- name: Download machine specs artifact
run: |
ARTIFACT_ID=$(curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ steps.gh-app.outputs.token }}" https://api.github.com/repos/NethermindEth/post-merge-smoke-tests/actions/runs/${{ env.RUN_ID }}/artifacts | jq '.artifacts[0].id')
curl -L -H "Accept: application/vnd.github.v3+json" -H "Authorization: token ${{ steps.gh-app.outputs.token }}" -o artifact.zip https://api.github.com/repos/NethermindEth/post-merge-smoke-tests/actions/artifacts/$ARTIFACT_ID/zip
unzip artifact.zip -d ./downloaded-artifacts/
- name: Display machine specs content
run: |
FILE=$(ls downloaded-artifacts/machine-details | head -n 1)
echo "<details>" >> $GITHUB_STEP_SUMMARY
echo "<summary>Details of node from branch: ${{ env.CLEAN_REF }}</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat "downloaded-artifacts/machine-details/$FILE" >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
cat "downloaded-artifacts/machine-details/$FILE" | tee spec-output.txt
rpc_url=$(grep -oP '\s{2,3}RPC URL: \K.+' spec-output.txt)
echo "RPC URL extracted is: $rpc_url"
echo "RPC_URL=$rpc_url" >> $GITHUB_ENV
- name: Save RPC URL to file
if: inputs.custom_run_id != ''
run: |
workflow_id=${{ inputs.custom_run_id }}
echo "${{ env.RPC_URL }}" > rpc_url%${{ env.CLEAN_REF }}%${{ inputs.custom_run_id }}.txt
- name: Upload RPC URL
uses: actions/upload-artifact@v4
if: inputs.custom_run_id != ''
with:
name: rpc-url___${{ env.CLEAN_REF }}___${{ inputs.custom_run_id }}
path: rpc_url%${{ env.CLEAN_REF }}%${{ inputs.custom_run_id }}.txt