-
Notifications
You must be signed in to change notification settings - Fork 14
269 lines (235 loc) · 10.3 KB
/
ci.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
name: CI
on:
push:
branches:
- master
tags:
- '[0-9]+.[0-9]+.[0-9]+*'
pull_request:
branches: [ master ]
workflow_dispatch:
inputs:
verbose:
description: "Set --verbose to get verbose build output"
required: false
default: 'true'
env:
VERBOSE: ${{ github.events.input.verbose }}
# Cancel a currently running workflow from the same PR, branch or tag when a new workflow is
# triggered (ref https://stackoverflow.com/a/72408109)
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build_primary_binaries:
name: Primary build ${{ matrix.binary }} for ${{ matrix.rust-target }} on (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-22.04 ]
rust: [ stable ]
binary: [ release ]
env:
RUST_BACKTRACE: full
RUSTV: ${{ matrix.rust }}
TARGET: ${{ matrix.rust-target }}
RUST_BIN_DIR: target/${{ matrix.rust-target }}/debug
RELEASE_NAME: debug
steps:
- uses: actions/checkout@v4
- name: Install protoc
run: sudo apt-get install protobuf-compiler
- name: Print env
run: |
echo "RUST_BIN_DIR = ${{ env.RUST_BIN_DIR }} "
# With rustup's nice new toml format, we just need to run rustup show to install the toolchain
# https://github.com/actions-rs/toolchain/issues/126#issuecomment-782989659
- name: Setup Rust toolchain
run: rustup show
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.os }}-${{ env.RUST_BIN_DIR }}-${{ matrix.binary }}
- name: Release
if: ${{ matrix.binary == 'release' }}
run: cargo build --locked --release
# Upload artifacts
- name: Upload encointer-collator
uses: actions/upload-artifact@v4
with:
name: encointer-collator-${{ github.sha }}
path: target/release/encointer-collator
cargo-toml-fmt:
runs-on: ubuntu-22.04
container: "tamasfe/taplo:0.7.0-alpine"
steps:
- uses: actions/checkout@v4
- name: Run Taplo fmt
run: taplo fmt --check
- name: Fail-fast; cancel other jobs
if: failure()
uses: andymckay/[email protected]
create_artifacts:
needs: [ build_primary_binaries ]
runs-on: ubuntu-22.04
env:
CHAIN_SPEC: ${{ matrix.chain }}-${{ matrix.config }}
strategy:
fail-fast: false
matrix:
chain: [ encointer ]
config: [ rococo, westend, kusama ]
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: encointer-collator-${{ github.sha }}
- name: 'Create binaries for artifacts'
# The build-spec cmd does not create a deterministic key order in the produced json. Hence, we sort the keys
# before we use it to deterministically create the state.
run: |
chmod +x ./encointer-collator
./encointer-collator build-spec --chain ${{ env.CHAIN_SPEC }} --disable-default-bootnode --raw > ${{ env.CHAIN_SPEC }}-unsorted.json
jq --sort-keys . ${{ env.CHAIN_SPEC }}-unsorted.json > ${{ env.CHAIN_SPEC }}.json
./encointer-collator export-genesis-state --chain ${{ env.CHAIN_SPEC }}.json > ${{ env.CHAIN_SPEC }}.json.state
./encointer-collator export-genesis-state --chain ${{ env.CHAIN_SPEC }} > ${{ env.CHAIN_SPEC }}.state
- name: Compute file metadata
id: vars
run: |
sha256sum ${{ env.CHAIN_SPEC }}.state >> checksums.txt
sha256sum ${{ env.CHAIN_SPEC }}.json >> checksums.txt
sha256sum ${{ env.CHAIN_SPEC }}.json.state >> checksums.txt
- name: Upload ${{ env.CHAIN_SPEC }} Files
uses: actions/upload-artifact@v4
with:
name: ${{ env.CHAIN_SPEC }}-genesis-spec-${{ github.sha }}
path: |
checksums.txt
${{ env.CHAIN_SPEC }}.state
${{ env.CHAIN_SPEC }}.json
${{ env.CHAIN_SPEC }}.json.state
integration-test:
# name: ${{ matrix.test }}
name: integration-test
runs-on: ubuntu-22.04
needs: build_primary_binaries
strategy:
fail-fast: false
matrix:
include:
- test: bootstrap_demo_community.py --signer //Alice -w collective --batch-size 7 --waiting-blocks 5 --is-parachain --test cc-fee-payment
# Don't start phase/faucet. It is not needed and there might be occasional nonce collisions with Alice.
needs_phase_and_faucet: false
- test: bootstrap_demo_community.py --signer //Alice -w collective --batch-size 7 --waiting-blocks 5 --is-parachain --test faucet
needs_phase_and_faucet: false
# Fixme #232: Script does not support purging a community for the parachain, as root is required.
# - test: bootstrap_demo_community.py --signer //Alice -w collective --batch-size 7 --waiting-blocks 5 --is-parachain --test reputation-caching
# needs_phase_and_faucet: false
- test: bootstrap_demo_community.py --signer //Alice -w collective --batch-size 7 --waiting-blocks 5 --is-parachain --test endorsement
needs_phase_and_faucet: false
- test: bootstrap_demo_community.py --signer //Alice -w collective --batch-size 7 --waiting-blocks 5 --is-parachain --test unregister-and-upgrade-registration
needs_phase_and_faucet: false
# Fixme #232: Democracy params are runtime constants we cannot change, hence the democracy cycle takes too long to execute for the CI.
# - test: bootstrap_demo_community.py --signer //Alice -w collective --batch-size 7 --waiting-blocks 5 --is-parachain --test democracy
# needs_phase_and_faucet: false
# Fixme #232: Consistently fails at some random point due to:
# 1. wrong phase in the beginning (phase.py switches phase due to long idle times as we wait for a few blocks).
# 2. due to a nonce collision with Alice in phase/faucet.
# - test: bot-community-test -f http://host.docker.internal:5000/api -w collective --batch-size 7 --waiting-blocks 3
# needs_phase_and_faucet: true
env:
ZOMBIENET_VERSION: v1.3.116
POLKADOT_VERSION: polkadot-stable2412
ENCOINTER_CLIENT_DOCKER_TAG: 1.16.2
steps:
- uses: actions/checkout@v4
- name: Create testing directories
run: mkdir -p zombienet-tests/bin
- name: Setup zombienet binaries
run: |
mkdir -p zombienet-tests/bin
cd zombienet-tests/bin
wget -q "https://github.com/paritytech/zombienet/releases/download/${{ env.ZOMBIENET_VERSION }}/zombienet-linux-x64"
chmod +x zombienet-linux-x64
./zombienet-linux-x64 setup polkadot -y || :
./zombienet-linux-x64 version
- name: Get Omni-Node
run: |
cd zombienet-tests/bin
wget -q "https://github.com/paritytech/polkadot-sdk/releases/download/${{ env.POLKADOT_VERSION }}/polkadot-omni-node"
chmod +x polkadot-omni-node
./polkadot-omni-node --version
- name: Download Encointer Collator
uses: actions/download-artifact@v4
with:
name: encointer-collator-${{ github.sha }}
# for debugging the integration tests, we can just download an image from a previous run
# name: encointer-collator-859e7ba3e64e971a91b1174a4d9423bb854be9d9
# github-token: ${{ github.token }}
# run-id: 12904591738
- name: fix permissions of artifacts and move to test directory
run: |
chmod +x encointer-collator
cp encointer-collator zombienet-tests/bin
- name: Start zombienet-setup and sleep until the parachain produces blocks (approx 100 seconds)
run: |
zombienet-tests/bin/zombienet-linux-x64 spawn --provider native zombienet/github-actions-setup.toml &
echo "setup zombienet, sleep for 100 secs until parachain produces blocks"
sleep 90
- name: start faucet service
if: ${{ matrix.needs_phase_and_faucet }}
run: |
docker run -p 5000:5000 \
--add-host host.docker.internal:host-gateway \
encointer/encointer-client-notee:${{ env.ENCOINTER_CLIENT_DOCKER_TAG }} faucet.py \
-u ws://host.docker.internal \
--port 9944 &
- name: start phase accelerator service
if: ${{ matrix.needs_phase_and_faucet }}
# 5 idle blocks needed, which is more than the solochain because fewer extrinsics fit into a block
run: |
docker run \
--add-host host.docker.internal:host-gateway \
encointer/encointer-client-notee:${{ env.ENCOINTER_CLIENT_DOCKER_TAG }} phase.py \
-u ws://host.docker.internal \
--port 9944 --idle-blocks 5 &
- name: Test ${{ matrix.test }}
run: |
docker run \
--add-host host.docker.internal:host-gateway \
encointer/encointer-client-notee:${{ env.ENCOINTER_CLIENT_DOCKER_TAG }} ${{ matrix.test }} \
-u ws://host.docker.internal \
--port 9944 \
release:
name: Draft Release
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: [ create_artifacts, build_primary_binaries ]
outputs:
release_url: ${{ steps.create-release.outputs.html_url }}
asset_upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
- name: Download Encointer Collator
uses: actions/download-artifact@v4
with:
name: encointer-collator-${{ github.sha }}
- name: Create required package.json
run: test -f package.json || echo '{}' >package.json
- name: Changelog
uses: scottbrenner/generate-changelog-action@master
id: Changelog
- name: Display structure of downloaded files
run: ls -R
working-directory: .
- name: Release
id: create-release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: |
${{ steps.Changelog.outputs.changelog }}
draft: true
files: |
encointer-collator