Skip to content

Commit 36016d7

Browse files
A0-1619 New GH check for runtime metadata (#842)
* A0-1619 New GH check for runtime metadata * A0-1619 Removed interactive mode from the new runtime check. Fixed steps dependencies. * A0-1619 Attempt to fix workflows. * A0-1619 use pre-build subxt image * A0-1619 Fixed docker entrypoint. Regenerated runtime metadata as it was outdated. * A0-1619 Attempt 4 to fix workflows * A0-1619 Attempt 5 to fix workflows * A0-1619 Hopefully better attempt to the Dockerfile
1 parent 6943547 commit 36016d7

File tree

8 files changed

+81
-8
lines changed

8 files changed

+81
-8
lines changed

.github/actions/run-e2e-test/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ inputs:
1212
default: '4'
1313
test-case:
1414
description: 'Name of test to run.'
15-
required: true
15+
required: false
1616
randomized:
1717
description: 'Whether to use randomized test params.'
1818
required: false
@@ -69,15 +69,18 @@ runs:
6969
run: docker logs Node0 --follow &
7070

7171
- name: Download artifact with the test suite image
72+
if: inputs.test-case != ''
7273
uses: actions/download-artifact@v2
7374
with:
7475
name: aleph-e2e-client
7576

7677
- name: Load test suite docker image
78+
if: inputs.test-case != ''
7779
shell: bash
7880
run: docker load -i aleph-e2e-client.tar
7981

8082
- name: Run single e2e test
83+
if: inputs.test-case != ''
8184
shell: bash
8285
run: |
8386
ARGS=(

.github/workflows/e2e-tests-main-devnet.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,25 @@ jobs:
185185
if-no-files-found: error
186186
retention-days: 7
187187

188+
run-aleph-client-subxt-codegen-check:
189+
needs: [build-test-docker]
190+
name: Checks if runtime file in aleph-client is up-to-date
191+
runs-on: ubuntu-20.04
192+
steps:
193+
- name: Checkout source code
194+
uses: actions/checkout@v2
195+
196+
- name: Run one node in the background
197+
uses: ./.github/actions/run-e2e-test
198+
with:
199+
node-count: 1
200+
min-validator-count: 1
201+
202+
- name: check if runtime metadata matches
203+
run: |
204+
cd aleph-client
205+
docker pull public.ecr.aws/p6e8q1z1/subxt-client-integration:latest
206+
docker run --rm --network host --mount type=bind,source="$(pwd)/..",target=/subxt/aleph-node public.ecr.aws/p6e8q1z1/subxt-client-integration:latest
188207
189208
run-e2e-finalization-test:
190209
needs: [build-test-docker, build-test-client]

aleph-client/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**
2+
!docker/subxt-integration-entrypoint.sh

aleph-client/docker/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
This directory contains following files:
2+
### `subxt-integration.Dockerfile`
3+
This is not a main `aleph-client`, rather it is a helper Dockerfile to run on GH, which has `subxt` tool.
4+
5+
It requires:
6+
* an `aleph-node` chain to be run in the background (ie `127.0.0.1:9944` port must be opened),
7+
* access to `rustfmt.toml`,
8+
* access to current `aleph_zero.rs` file
9+
10+
The docker checks whether a `subxt`-generated runtime metadata is the same as from the current commit.
11+
12+
It needs to be run only from `aleph-client` directory and in network host mode:
13+
```bash
14+
docker run --network host --mount type=bind,source="$(pwd)/..",target=/subxt/aleph-node subxt:latest
15+
```
16+
17+
### `subxt-integration-entrypoint.sh`
18+
An entrypoint for above Dockerfile
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
3+
subxt codegen --derive Clone --derive Debug --derive Eq --derive PartialEq | rustfmt --edition=2021 --config-path aleph-node/rustfmt.toml > aleph_zero.rs
4+
diff -y -W 200 --suppress-common-lines aleph_zero.rs aleph-node/aleph-client/src/aleph_zero.rs
5+
diff_exit_code=$?
6+
if [[ ! $diff_exit_code -eq 0 ]]; then
7+
echo "Current runtime metadata is different than versioned in git!"
8+
echo "Run subxt codegen --derive Clone --derive Debug --derive Eq --derive PartialEq | rustfmt --edition=2021 >" \
9+
"src/aleph_zero.rs from aleph-client directory and commit to git."
10+
exit 1
11+
fi
12+
echo "Current runtime metadata and versioned in git matches."
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM rustlang/rust:nightly-slim
2+
3+
WORKDIR subxt
4+
5+
RUN cargo install subxt-cli
6+
RUN rustup component add rustfmt --toolchain nightly
7+
8+
COPY docker/subxt-integration-entrypoint.sh /subxt/subxt-integration-entrypoint.sh
9+
10+
RUN chmod +x /subxt/subxt-integration-entrypoint.sh
11+
RUN rustc --version
12+
13+
ENTRYPOINT ["./subxt-integration-entrypoint.sh"]

aleph-client/rustfmt.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
edition = "2021"
2+
use_field_init_shorthand = true
3+
reorder_modules = true
4+
5+
imports_granularity = "Crate"
6+
group_imports = "StdExternalCrate"
7+
reorder_imports = true

aleph-client/src/aleph_zero.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6409,10 +6409,9 @@ pub mod api {
64096409
"FinalityVersion",
64106410
vec![],
64116411
[
6412-
134u8, 19u8, 94u8, 247u8, 125u8, 18u8, 148u8, 160u8, 167u8, 235u8,
6413-
174u8, 4u8, 107u8, 69u8, 55u8, 187u8, 249u8, 13u8, 129u8, 99u8, 116u8,
6414-
158u8, 38u8, 29u8, 239u8, 112u8, 150u8, 92u8, 151u8, 197u8, 223u8,
6415-
30u8,
6412+
99u8, 158u8, 103u8, 180u8, 128u8, 32u8, 84u8, 110u8, 229u8, 2u8, 3u8,
6413+
114u8, 95u8, 125u8, 230u8, 210u8, 56u8, 85u8, 38u8, 136u8, 49u8, 206u8,
6414+
6u8, 136u8, 193u8, 164u8, 251u8, 60u8, 125u8, 91u8, 205u8, 144u8,
64166415
],
64176416
)
64186417
}
@@ -19533,9 +19532,9 @@ pub mod api {
1953319532
let runtime_metadata_hash = client.metadata().metadata_hash(&PALLETS);
1953419533
if runtime_metadata_hash
1953519534
!= [
19536-
155u8, 236u8, 207u8, 138u8, 149u8, 114u8, 96u8, 168u8, 143u8, 247u8, 148u8, 106u8,
19537-
148u8, 203u8, 48u8, 129u8, 14u8, 48u8, 155u8, 234u8, 78u8, 212u8, 73u8, 65u8,
19538-
212u8, 201u8, 174u8, 194u8, 72u8, 70u8, 240u8, 233u8,
19535+
10u8, 121u8, 157u8, 11u8, 147u8, 107u8, 235u8, 73u8, 90u8, 254u8, 82u8, 183u8,
19536+
112u8, 64u8, 213u8, 99u8, 23u8, 17u8, 10u8, 91u8, 124u8, 231u8, 209u8, 172u8, 59u8,
19537+
160u8, 15u8, 142u8, 149u8, 200u8, 95u8, 164u8,
1953919538
]
1954019539
{
1954119540
Err(::subxt::error::MetadataError::IncompatibleMetadata)

0 commit comments

Comments
 (0)