-
Notifications
You must be signed in to change notification settings - Fork 4
212 lines (177 loc) · 6.1 KB
/
deploy-testnets.yml
File metadata and controls
212 lines (177 loc) · 6.1 KB
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
name: Deploy testnets
on:
push:
branches:
- "**"
permissions:
contents: read
concurrency:
group: deploy-testnets-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
discover-matrix:
name: Discover testnet matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.build-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Determine pnpm store path
id: pnpm-store
shell: bash
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV
- name: Cache pnpm store
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-node-20-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-20-pnpm-store-
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-20-node_modules-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-20-node_modules-
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: |
pnpm install --frozen-lockfile --ignore-scripts
- id: build-matrix
name: Build matrix from Catapult networks (testnets only)
shell: bash
env:
RPC_BUILDER_KEY: ${{ secrets.RPC_BUILDER_KEY }}
run: |
set -euo pipefail
CHAIN_IDS=$(pnpm exec catapult list networks --simple-chain-ids --only-testnets)
MATRIX_ITEMS=()
while IFS= read -r CHAIN_ID; do
[[ -z "${CHAIN_ID}" ]] && continue
NETWORK_NAME=$(pnpm exec catapult utils chain-id-to-name "${CHAIN_ID}")
NETWORK_NAME_ESCAPED=${NETWORK_NAME//\"/\\\"}
MATRIX_ITEMS+=("{\"chainId\": ${CHAIN_ID}, \"networkName\": \"${NETWORK_NAME_ESCAPED}\"}")
done <<< "${CHAIN_IDS}"
if [[ ${#MATRIX_ITEMS[@]} -eq 0 ]]; then
echo "No testnets discovered" >&2
echo "matrix={\"include\":[]}" >> "$GITHUB_OUTPUT"
exit 0
fi
printf -v MATRIX_JSON '{"include":[%s]}' "$(IFS=,; echo "${MATRIX_ITEMS[*]}")"
echo "Discovered matrix: ${MATRIX_JSON}"
echo "matrix=${MATRIX_JSON}" >> "$GITHUB_OUTPUT"
deploy:
name: "Deploy to ${{ matrix.networkName }} (${{ matrix.chainId }})"
needs: discover-matrix
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
max-parallel: 2
matrix: ${{ fromJSON(needs.discover-matrix.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Determine pnpm store path
id: pnpm-store
shell: bash
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV
- name: Cache pnpm store
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-node-20-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-20-pnpm-store-
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-20-node_modules-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-20-node_modules-
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: |
pnpm install --frozen-lockfile --ignore-scripts
- name: Run Catapult
env:
NETWORK_NAME: ${{ matrix.networkName }}
CHAIN_ID: ${{ matrix.chainId }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
RPC_BUILDER_KEY: ${{ secrets.RPC_BUILDER_KEY }}
run: |
set -euo pipefail
./node_modules/.bin/catapult run -vvv -n "${CHAIN_ID}" --ignore-verify-errors
- name: Upload outputs artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: catapult-outputs-${{ matrix.networkName }}-${{ matrix.chainId }}
path: outputs/**
if-no-files-found: ignore
dry-run:
name: Catapult dry-run
if: ${{ always() }}
needs:
- discover-matrix
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Determine pnpm store path
id: pnpm-store
shell: bash
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV
- name: Cache pnpm store
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-node-20-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-20-pnpm-store-
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-20-node_modules-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-20-node_modules-
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: |
pnpm install --frozen-lockfile --ignore-scripts
- name: Run Catapult dry-run
run: |
set -euo pipefail
RPC_BUILDER_KEY=test ./node_modules/.bin/catapult dry-run -vvv