-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaction.yml
335 lines (303 loc) · 12.5 KB
/
action.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
name: Autonomi Local Testnet
description: Administer local testnets using the testnet binary
inputs:
action:
description: Start or stop a local testnet
required: true
build:
description: Build the node manager from source. Useful for testing.
type: boolean
default: false
enable-evm-testnet:
description: Enable the EVM testnet
type: boolean
default: false
join:
description: If set, any nodes that are launched will join an existing testnet.
type: boolean
default: false
log_file_prefix:
description: The prefix given to the log files that are uploaded. Logs are not uploaded if value not set.
node-count:
description: The number of nodes for the testnet. Defaults to 25.
type: number
default: 25
node-manager-branch:
description: Use with the build argument to specify the branch to build
default: main
node-manager-repo-owner:
description: Use with the build argument to specify the repository to use
default: maidsafe
node-path:
description: The location of the node binary
owner:
description: >
Assign each node this owner. This argument and `owner-prefix` are mutually exclusive.
owner-prefix:
description: >
Each node will be assigned an individual owner, based on this prefix.
This argument and `owner-prefix` are mutually exclusive.
platform:
description: The platform the action is running on
required: true
rewards-address:
description: The node reward address
default: "0x03B770D9cD32077cC0bF330c13C114a87643B124"
set-ant-peers:
description: There are some cases where setting ANT_PEERS must be skipped
type: boolean
default: true
sn-log:
description: The log level for the node processes
default: "v"
runs:
using: "composite"
steps:
#
# Setup
#
- name: install jq and ripgrep ubuntu
if: inputs.platform == 'ubuntu-latest'
shell: bash
run: sudo apt-get -y install jq ripgrep
- name: install jq and ripgrep mac
if: inputs.platform == 'macos-latest'
shell: bash
run: brew install jq ripgrep
- name: install jq and ripgrep windows
if: inputs.platform == 'windows-latest'
shell: pwsh
run: choco install jq ripgrep
- name: install foundary
if: inputs.enable-evm-testnet == 'true'
shell: bash
run: curl -L https://foundry.paradigm.xyz | bash
- name: move foundry bins to path (linux)
if: inputs.enable-evm-testnet == 'true' && inputs.platform == 'ubuntu-latest'
shell: bash
run: sudo mv /home/runner/.config/.foundry/bin/* /usr/local/bin
- name: move foundry bins to path (macos)
if: inputs.enable-evm-testnet == 'true' && inputs.platform == 'macos-latest'
shell: bash
run: sudo mv /Users/runner/.foundry/bin/* /usr/local/bin
- name: move foundry bins to path (windows)
if: inputs.enable-evm-testnet == 'true' && inputs.platform == 'windows-latest'
shell: pwsh
run: Copy-Item -Path C:\Users\runneradmin\.foundry\bin\* -Destination C:\Users\runneradmin\AppData\Local\Microsoft\WindowsApps
- name: run foundry
if: inputs.enable-evm-testnet == 'true'
shell: bash
run: foundryup
- name: move anvil and other bins to path (linux)
if: inputs.enable-evm-testnet == 'true' && inputs.platform == 'ubuntu-latest'
shell: bash
run: sudo mv /home/runner/.config/.foundry/bin/* /usr/local/bin
- name: move anvil and other bins to path (macos)
if: inputs.enable-evm-testnet == 'true' && inputs.platform == 'macos-latest'
shell: bash
run: sudo mv /Users/runner/.foundry/bin/* /usr/local/bin
- name: move anvil and other bins to path (windows)
if: inputs.enable-evm-testnet == 'true' && inputs.platform == 'windows-latest'
shell: pwsh
run: Copy-Item -Path C:\Users\runneradmin\.foundry\bin\* -Destination C:\Users\runneradmin\AppData\Local\Microsoft\WindowsApps
#
# Starting the Network
#
- name: install testnet (linux)
if: inputs.platform == 'ubuntu-latest' && inputs.action == 'start'
shell: bash
run: |
if [[ "${{ inputs.build }}" == "true" ]]; then
cargo build --release --bin antctl --features local
sudo mv target/release/antctl /usr/local/bin
if [[ "${{ inputs.enable-evm-testnet }}" == "true" ]]; then
cargo build --release --bin evm-testnet
sudo mv target/release/evm-testnet /usr/local/bin
fi
else
echo "Support for downloading the node manager will be implemented soon"
exit 1
fi
- name: install testnet (macOS)
if: inputs.platform == 'macos-latest' && inputs.action == 'start'
shell: bash
run: |
if [[ "${{ inputs.build }}" == "true" ]]; then
TEMP_DIR=$(mktemp -d)
cargo build --release --bin antctl --features local
sudo mv target/release/antctl /usr/local/bin
if [[ "${{ inputs.enable-evm-testnet }}" == "true" ]]; then
cargo build --release --bin evm-testnet
sudo mv target/release/evm-testnet /usr/local/bin
fi
else
echo "Support for downloading the node manager will be implemented soon"
exit 1
fi
- name: install testnet (windows)
if: inputs.platform == 'windows-latest' && inputs.action == 'start'
shell: pwsh
run: |
# This is a location that's on the Path variable on the GHA Windows machine.
$destination = "C:\Users\runneradmin\AppData\Local\Microsoft\WindowsApps"
if ("${{ inputs.build }}" -eq "true") {
cargo build --release --bin antctl --features local
Copy-Item .\target\release\antctl.exe -Destination $destination
if ("${{ inputs.enable-evm-testnet }}" -eq "true") {
cargo build --release --bin evm-testnet
Copy-Item .\target\release\evm-testnet.exe -Destination $destination
}
} else {
echo "Support for downloading the node manager will be implemented soon"
exit 1
}
- name: start evm testnet
if : inputs.action == 'start' && inputs.enable-evm-testnet == 'true'
shell: bash
run: |
evm-testnet &
- name: Set ANT_LOG (unix)
if: |
inputs.platform != 'windows-latest' &&
inputs.action == 'start' &&
inputs.sn-log != ''
shell: bash
run: |
echo "ANT_LOG=${{ inputs.sn-log }}" >> $GITHUB_ENV
- name: Set ANT_LOG (windows)
if: |
inputs.platform == 'windows-latest' &&
inputs.action == 'start' &&
inputs.sn-log != ''
shell: pwsh
run: |
Add-Content -Path $env:GITHUB_ENV -Value "ANT_LOG=${{ inputs.sn-log }}"
# Even though these two steps are the same, you seem required to specify a shell inside
# an action, which doesn't seem to be the case in the calling workflow.
- name: start local autonomi testnet (Linux/macOS)
if: inputs.platform != 'windows-latest' && inputs.action == 'start'
shell: bash
run: |
command="antctl "
if [[ "${{ inputs.join }}" == "true" ]]; then
command="$command local join "
else
command="$command local run "
fi
command="$command --count ${{ inputs.node-count }} "
command="$command --node-path ${{ inputs.node-path }} "
# These arguments are mutually exclusive, but `antctl` will assert that at the
# beginning, so there's no need for us to do it here.
[[ -n "${{ inputs.owner }}" ]] && command="$command --owner ${{ inputs.owner }}"
[[ -n "${{ inputs.owner-prefix }}" ]] && command="$command --owner-prefix ${{ inputs.owner-prefix }}"
[[ "${{ inputs.enable-evm-testnet }}" == "true" ]] && command="$command --rewards-address ${{ inputs.rewards-address }}"
[[ "${{ inputs.enable-evm-testnet }}" == "true" ]] && command="$command evm-local"
echo "Will run antctl with: $command"
eval $command
- name: start local autonomi testnet (Windows)
if: inputs.platform == 'windows-latest' && inputs.action == 'start'
shell: pwsh
run: |
$command = "antctl "
if ("${{ inputs.join }}" -eq "true") {
$command += "local join "
} else {
$command += "local run "
}
$command += "--count ${{ inputs.node-count }} "
$command += "--node-path ${{ inputs.node-path }} "
if (-not [string]::IsNullOrEmpty("${{ inputs.owner }}")) {
$command += "--owner ${{ inputs.owner }} "
}
if (-not [string]::IsNullOrEmpty("${{ inputs.owner-prefix }}")) {
$command += "--owner-prefix ${{ inputs.owner-prefix }} "
}
if ("${{ inputs.enable-evm-testnet }}" -eq "true") {
$command += "--rewards-address ${{ inputs.rewards-address }} "
}
if ("${{ inputs.enable-evm-testnet }}" -eq "true") {
$command += "evm-local "
}
Write-Host "Will run antctl with: $command"
Invoke-Expression $command
- name: Set ANT_PEERS and EVM_NETWORK (Linux)
if: |
inputs.platform == 'ubuntu-latest' &&
inputs.action == 'start' &&
inputs.set-ant-peers == 'true'
shell: bash
run: |
manager_registry_path="/home/runner/.local/share/autonomi/local_node_registry.json"
listen_addr=$(jq -r '.nodes[0].listen_addr[0]' $manager_registry_path)
echo "listen_addr: $listen_addr"
echo "ANT_PEERS=$listen_addr" >> $GITHUB_ENV
echo "EVM_NETWORK=local" >> $GITHUB_ENV
- name: Set ANT_PEERS and EVM_NETWORK (macOS)
if: |
inputs.platform == 'macos-latest' &&
inputs.action == 'start' &&
inputs.set-ant-peers == 'true'
shell: bash
run: |
manager_registry_path="/Users/runner/Library/Application Support/autonomi/local_node_registry.json"
listen_addr=$(jq -r '.nodes[0].listen_addr[0]' "$manager_registry_path")
echo "listen_addr: $listen_addr"
echo "ANT_PEERS=$listen_addr" >> $GITHUB_ENV
echo "EVM_NETWORK=local" >> $GITHUB_ENV
- name: Set ANT_PEERS and EVM_NETWORK (windows)
if: |
inputs.platform == 'windows-latest' &&
inputs.action == 'start' &&
inputs.set-ant-peers == 'true'
shell: pwsh
run: |
$manager_registry_path = "C:\Users\runneradmin\AppData\Roaming\autonomi\local_node_registry.json"
$listen_addr = jq -r '.nodes[0].listen_addr[0]' $manager_registry_path
Write-Host "listen_addr: $listen_addr"
Add-Content -Path $env:GITHUB_ENV -Value "ANT_PEERS=$listen_addr"
Add-Content -Path $env:GITHUB_ENV -Value "EVM_NETWORK=local"
#
# Stopping the Network
#
- name: Kill evm testnet (Linux/macOS)
if: inputs.platform != 'windows-latest' && inputs.action == 'stop'
shell: bash
run: pkill -f evm-testnet || true
- name: Kill evm testnet (Windows)
if: inputs.platform == 'windows-latest' && inputs.action == 'stop'
shell: pwsh
run: Stop-Process -Name evm-testnet -ErrorAction SilentlyContinue
- name: Kill all nodes (unix)
if: inputs.platform != 'windows-latest' && inputs.action == 'stop'
shell: bash
run: antctl local kill --keep-directories
- name: Kill all nodes (windows)
if: inputs.platform == 'windows-latest' && inputs.action == 'stop'
shell: pwsh
run: antctl local kill --keep-directories
- name: Upload log files (Linux)
if: inputs.platform == 'ubuntu-latest' && inputs.action == 'stop' && inputs.log_file_prefix != ''
env:
ROOT_DIR: "/home/runner/.local/share/autonomi"
uses: actions/upload-artifact@main
with:
compression-level: 9
name: ${{inputs.log_file_prefix}}_${{inputs.platform}}
path: |
~/.local/share/autonomi/**/*.log*
- name: Upload log files (macOs)
if: inputs.platform == 'macos-latest' && inputs.action == 'stop' && inputs.log_file_prefix != ''
uses: actions/upload-artifact@main
with:
compression-level: 9
name: ${{inputs.log_file_prefix}}_${{inputs.platform}}
path: |
/Users/runner/Library/Application Support/autonomi/**/*.log*
- name: Upload log files (Windows)
if: inputs.platform == 'windows-latest' && inputs.action == 'stop' && inputs.log_file_prefix != ''
uses: actions/upload-artifact@main
with:
compression-level: 9
name: ${{inputs.log_file_prefix}}_${{inputs.platform}}
path: |
C:\Users\runneradmin\AppData\Roaming\autonomi\**\*.log*