-
Notifications
You must be signed in to change notification settings - Fork 115
258 lines (237 loc) · 8.46 KB
/
run-network-tests.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
name: run-network-tests
on:
pull_request:
types: [opened, synchronize]
workflow_dispatch:
push:
jobs:
tests_build_ubuntu:
name: Ubuntu Checks
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: checks
run: |
yarn build
tests_build_osx:
name: MacOS Checks
runs-on: macos-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: checks
run: |
yarn build
build_images:
name: Build joystream/node
needs: tests_build_ubuntu
runs-on: ubuntu-latest
outputs:
use_artifact: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz
runtime: ${{ steps.compute_shasum.outputs.shasum }}
steps:
- name: Make some space
shell: bash
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- id: compute_shasum
name: Compute runtime code shasum
env:
RUNTIME_PROFILE: 'TESTING'
run: |
export RUNTIME_CODE_SHASUM=`scripts/runtime-code-shasum.sh`
echo "::set-output name=shasum::${RUNTIME_CODE_SHASUM}"
- name: Setup cache directory
run: mkdir ~/docker-images
- name: Cache docker images
uses: actions/cache@v3
env:
cache-name: joystream-node-docker-1
with:
path: ~/docker-images
key: ${{ env.cache-name }}-${{ steps.compute_shasum.outputs.shasum }}
- name: Check if we have cached image
continue-on-error: true
run: |
if [ -f ~/docker-images/joystream-node-docker-image.tar.gz ]; then
docker load --input ~/docker-images/joystream-node-docker-image.tar.gz
cp ~/docker-images/joystream-node-docker-image.tar.gz .
fi
- name: Check if we have pre-built image on Dockerhub
continue-on-error: true
run: |
if ! [ -f joystream-node-docker-image.tar.gz ]; then
docker pull joystream/node:${{ steps.compute_shasum.outputs.shasum }}
docker save --output joystream-node-docker-image.tar joystream/node:${{ steps.compute_shasum.outputs.shasum }}
gzip joystream-node-docker-image.tar
cp joystream-node-docker-image.tar.gz ~/docker-images/
fi
- name: Check we now have an image
id: check_files
uses: andstor/file-existence-action@v1
with:
files: 'joystream-node-docker-image.tar.gz'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # v1.7
id: builder1
if: steps.check_files.outputs.files_exists == 'false'
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-tests
if: steps.check_files.outputs.files_exists == 'false'
- name: Build
uses: docker/build-push-action@v3
with:
context: .
file: joystream-node.Dockerfile
platforms: linux/amd64
build-args: |
CARGO_FEATURES=testing-runtime
CODE_SHASUM=${{ steps.compute_shasum.outputs.shasum }}
push: false
tags: joystream/node:${{ steps.compute_shasum.outputs.shasum }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
builder: ${{ steps.builder1.outputs.name }}
load: true
if: steps.check_files.outputs.files_exists == 'false'
- name: Save joystream/node image to cache
run: |
docker save --output joystream-node-docker-image.tar joystream/node:${{ steps.compute_shasum.outputs.shasum }}
gzip joystream-node-docker-image.tar
cp joystream-node-docker-image.tar.gz ~/docker-images/
if: steps.check_files.outputs.files_exists == 'false'
- name: Save joystream/node image to Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz
path: joystream-node-docker-image.tar.gz
run_test_scenarios:
name: Tests
needs: build_images
runs-on: ubuntu-latest
strategy:
matrix:
scenario: ['full', 'setupNewChain', 'setupNewChainMultiStorage', 'bonding', 'storageSync']
include:
- scenario: 'full'
no_storage: 'false'
- scenario: 'setupNewChain'
no_storage: 'true'
- scenario: 'setupNewChainMultiStorage'
no_storage: 'true'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Get artifacts
uses: actions/download-artifact@v3
with:
name: ${{ needs.build_images.outputs.use_artifact }}
- name: Install artifacts
run: |
docker load --input joystream-node-docker-image.tar.gz
docker images
- name: Install packages and dependencies
run: |
yarn build
- name: Ensure tests are runnable
run: yarn workspace network-tests build
- name: Execute network tests
run: |
export RUNTIME=${{ needs.build_images.outputs.runtime }}
export NO_STORAGE=${{ matrix.no_storage }}
tests/network-tests/run-tests.sh ${{ matrix.scenario }}
runtime_upgrade:
name: Runtime Upgrade from production runtime
needs: build_images
runs-on: ubuntu-latest
# Disabling until we find a workaround
# as it is no longer practical to start the node
# while importing huge state from production network in genesis block.
# if: github.ref != 'refs/heads/master'
if: false
steps:
# Checkout master branch
- name: check out master repo
uses: actions/checkout@v3
with:
repository: Joystream/joystream
ref: master
- name: pull base runtime image
id: pull_base_image
env:
RUNTIME_PROFILE: 'TESTING'
run: |
export RUNTIME=`scripts/runtime-code-shasum.sh`
echo "::set-output name=shasum::${RUNTIME}"
docker pull joystream/node:$RUNTIME
docker images
# Get new runtime built for this workflow (target runtime)
# tagged in local repo as joystream/node:latest
- name: Get artifacts
uses: actions/download-artifact@v3
with:
name: ${{ needs.build_images.outputs.use_artifact }}
- name: Install artifacts
run: |
docker load --input joystream-node-docker-image.tar.gz
docker images
# Checkout workflow's branch/tag/commit
- name: checkout workflow branch
uses: actions/checkout@v3
# Look only for changes that would indicate possible change in runtime version
# This is not the best way to check. Ideally the script "run-runtime-upgrade-tests.sh" should
# look for the change of `spec_version`, and exit gracefully.
- name: Check for runtime version change
uses: technote-space/get-diff-action@v3
with:
PREFIX_FILTER: |
runtime
runtime-modules
SUFFIX_FILTER: |
.rs
- name: setup node
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Install packages and dependencies
if: env.GIT_DIFF
run: |
yarn build
- name: Ensure tests are runnable
if: env.GIT_DIFF
run: yarn workspace network-tests build
- name: Execute network tests
if: env.GIT_DIFF
env:
TARGET_RUNTIME: ${{ needs.build_images.outputs.runtime }}
RUNTIME: ${{ steps.pull_base_image.outputs.shasum }}
run: |
export HOME=${PWD}
mkdir -p ${HOME}/.local/share/joystream-cli
yarn joystream-cli api:setUri ws://localhost:9944
tests/network-tests/run-runtime-upgrade-tests.sh