diff --git a/.github/actions/run-e2e-test/action.yml b/.github/actions/run-e2e-test/action.yml index ff15febb55..d0139b4646 100644 --- a/.github/actions/run-e2e-test/action.yml +++ b/.github/actions/run-e2e-test/action.yml @@ -12,7 +12,7 @@ inputs: default: '4' test-case: description: 'Name of test to run.' - required: true + required: false randomized: description: 'Whether to use randomized test params.' required: false @@ -69,15 +69,18 @@ runs: run: docker logs Node0 --follow & - name: Download artifact with the test suite image + if: inputs.test-case != '' uses: actions/download-artifact@v2 with: name: aleph-e2e-client - name: Load test suite docker image + if: inputs.test-case != '' shell: bash run: docker load -i aleph-e2e-client.tar - name: Run single e2e test + if: inputs.test-case != '' shell: bash run: | ARGS=( diff --git a/.github/workflows/e2e-tests-main-devnet.yml b/.github/workflows/e2e-tests-main-devnet.yml index 70bb8fc8d9..492b585c1f 100644 --- a/.github/workflows/e2e-tests-main-devnet.yml +++ b/.github/workflows/e2e-tests-main-devnet.yml @@ -185,6 +185,25 @@ jobs: if-no-files-found: error retention-days: 7 + run-aleph-client-subxt-codegen-check: + needs: [build-test-docker] + name: Checks if runtime file in aleph-client is up-to-date + runs-on: ubuntu-20.04 + steps: + - name: Checkout source code + uses: actions/checkout@v2 + + - name: Run one node in the background + uses: ./.github/actions/run-e2e-test + with: + node-count: 1 + min-validator-count: 1 + + - name: check if runtime metadata matches + run: | + cd aleph-client + docker pull public.ecr.aws/p6e8q1z1/subxt-client-integration:latest + docker run --rm --network host --mount type=bind,source="$(pwd)/..",target=/subxt/aleph-node public.ecr.aws/p6e8q1z1/subxt-client-integration:latest run-e2e-finalization-test: needs: [build-test-docker, build-test-client] diff --git a/aleph-client/.dockerignore b/aleph-client/.dockerignore new file mode 100644 index 0000000000..11e58e6c04 --- /dev/null +++ b/aleph-client/.dockerignore @@ -0,0 +1,2 @@ +** +!docker/subxt-integration-entrypoint.sh diff --git a/aleph-client/docker/README.md b/aleph-client/docker/README.md new file mode 100644 index 0000000000..207b432454 --- /dev/null +++ b/aleph-client/docker/README.md @@ -0,0 +1,18 @@ +This directory contains following files: +### `subxt-integration.Dockerfile` +This is not a main `aleph-client`, rather it is a helper Dockerfile to run on GH, which has `subxt` tool. + +It requires: +* an `aleph-node` chain to be run in the background (ie `127.0.0.1:9944` port must be opened), +* access to `rustfmt.toml`, +* access to current `aleph_zero.rs` file + +The docker checks whether a `subxt`-generated runtime metadata is the same as from the current commit. + +It needs to be run only from `aleph-client` directory and in network host mode: +```bash + docker run --network host --mount type=bind,source="$(pwd)/..",target=/subxt/aleph-node subxt:latest +``` + +### `subxt-integration-entrypoint.sh` +An entrypoint for above Dockerfile diff --git a/aleph-client/docker/subxt-integration-entrypoint.sh b/aleph-client/docker/subxt-integration-entrypoint.sh new file mode 100644 index 0000000000..947010e7a5 --- /dev/null +++ b/aleph-client/docker/subxt-integration-entrypoint.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +subxt codegen --derive Clone --derive Debug --derive Eq --derive PartialEq | rustfmt --edition=2021 --config-path aleph-node/rustfmt.toml > aleph_zero.rs +diff -y -W 200 --suppress-common-lines aleph_zero.rs aleph-node/aleph-client/src/aleph_zero.rs +diff_exit_code=$? +if [[ ! $diff_exit_code -eq 0 ]]; then + echo "Current runtime metadata is different than versioned in git!" + echo "Run subxt codegen --derive Clone --derive Debug --derive Eq --derive PartialEq | rustfmt --edition=2021 >" \ +"src/aleph_zero.rs from aleph-client directory and commit to git." + exit 1 +fi +echo "Current runtime metadata and versioned in git matches." diff --git a/aleph-client/docker/subxt-integration.Dockerfile b/aleph-client/docker/subxt-integration.Dockerfile new file mode 100644 index 0000000000..54c2049df7 --- /dev/null +++ b/aleph-client/docker/subxt-integration.Dockerfile @@ -0,0 +1,13 @@ +FROM rustlang/rust:nightly-slim + +WORKDIR subxt + +RUN cargo install subxt-cli +RUN rustup component add rustfmt --toolchain nightly + +COPY docker/subxt-integration-entrypoint.sh /subxt/subxt-integration-entrypoint.sh + +RUN chmod +x /subxt/subxt-integration-entrypoint.sh +RUN rustc --version + +ENTRYPOINT ["./subxt-integration-entrypoint.sh"] diff --git a/aleph-client/rustfmt.toml b/aleph-client/rustfmt.toml new file mode 100644 index 0000000000..af85000b72 --- /dev/null +++ b/aleph-client/rustfmt.toml @@ -0,0 +1,7 @@ +edition = "2021" +use_field_init_shorthand = true +reorder_modules = true + +imports_granularity = "Crate" +group_imports = "StdExternalCrate" +reorder_imports = true diff --git a/aleph-client/src/aleph_zero.rs b/aleph-client/src/aleph_zero.rs index 96dc79aca0..c3d5c0f443 100644 --- a/aleph-client/src/aleph_zero.rs +++ b/aleph-client/src/aleph_zero.rs @@ -6409,10 +6409,9 @@ pub mod api { "FinalityVersion", vec![], [ - 134u8, 19u8, 94u8, 247u8, 125u8, 18u8, 148u8, 160u8, 167u8, 235u8, - 174u8, 4u8, 107u8, 69u8, 55u8, 187u8, 249u8, 13u8, 129u8, 99u8, 116u8, - 158u8, 38u8, 29u8, 239u8, 112u8, 150u8, 92u8, 151u8, 197u8, 223u8, - 30u8, + 99u8, 158u8, 103u8, 180u8, 128u8, 32u8, 84u8, 110u8, 229u8, 2u8, 3u8, + 114u8, 95u8, 125u8, 230u8, 210u8, 56u8, 85u8, 38u8, 136u8, 49u8, 206u8, + 6u8, 136u8, 193u8, 164u8, 251u8, 60u8, 125u8, 91u8, 205u8, 144u8, ], ) } @@ -19533,9 +19532,9 @@ pub mod api { let runtime_metadata_hash = client.metadata().metadata_hash(&PALLETS); if runtime_metadata_hash != [ - 155u8, 236u8, 207u8, 138u8, 149u8, 114u8, 96u8, 168u8, 143u8, 247u8, 148u8, 106u8, - 148u8, 203u8, 48u8, 129u8, 14u8, 48u8, 155u8, 234u8, 78u8, 212u8, 73u8, 65u8, - 212u8, 201u8, 174u8, 194u8, 72u8, 70u8, 240u8, 233u8, + 10u8, 121u8, 157u8, 11u8, 147u8, 107u8, 235u8, 73u8, 90u8, 254u8, 82u8, 183u8, + 112u8, 64u8, 213u8, 99u8, 23u8, 17u8, 10u8, 91u8, 124u8, 231u8, 209u8, 172u8, 59u8, + 160u8, 15u8, 142u8, 149u8, 200u8, 95u8, 164u8, ] { Err(::subxt::error::MetadataError::IncompatibleMetadata)