diff --git a/substrate/.gitlab-ci.yml b/substrate/.gitlab-ci.yml index 51ee7bcb1e..c6f23cd45f 100644 --- a/substrate/.gitlab-ci.yml +++ b/substrate/.gitlab-ci.yml @@ -37,6 +37,17 @@ cache: #### stage: test +test:runtime: + stage: test + # image: alpine/git:latest + cache: {} + tags: + - linux-docker + only: + - /^[0-9]+$/ + script: + - ./scripts/gitlab/check_runtime.sh + test:rust:stable: &test stage: test @@ -57,6 +68,8 @@ test:rust:stable: &test tags: - linux-docker before_script: + - echo "build cache size:" + - du -hs ${CARGO_HOME} ./target - ./scripts/build.sh script: - time cargo test --all --release --verbose --locked diff --git a/substrate/scripts/gitlab/check_runtime.sh b/substrate/scripts/gitlab/check_runtime.sh new file mode 100755 index 0000000000..89484f385e --- /dev/null +++ b/substrate/scripts/gitlab/check_runtime.sh @@ -0,0 +1,70 @@ +#!/bin/sh +# +# +# check for any changes in the node/src/runtime, srml/ and core/sr_* trees. if +# there are any changes found, it should mark the PR breaksconsensus and +# "auto-fail" the PR in some way unless a) the runtime is rebuilt and b) there +# isn't a change in the runtime/src/lib.rs file that alters the version. + +set -e # fail on any error + +# give some context +git log --graph --oneline --decorate=short -n 10 + + +RUNTIME="node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm" + + + +# check if the wasm sources changed +if ! git diff --name-only origin/master...${CI_COMMIT_SHA} \ + | grep -q -e '^node/src/runtime' -e '^srml/' -e '^core/sr-' +then + cat <<-EOT + + no changes to the runtime source code detected + + EOT + exit 0 +fi + + + +# check for spec_version updates +add_spec_version="$(git diff origin/master...${CI_COMMIT_SHA} node/runtime/src/lib.rs \ + | sed -n -r 's/^\+[[:space:]]+spec_version: +([0-9]+),$/\1/p')" +sub_spec_version="$(git diff origin/master...${CI_COMMIT_SHA} node/runtime/src/lib.rs \ + | sed -n -r 's/^\-[[:space:]]+spec_version: +([0-9]+),$/\1/p')" + + +# see if the spec version and the binary blob changed +if git diff --name-only origin/master...${CI_COMMIT_SHA} \ + | grep -q "${RUNTIME}" && \ + [ "${add_spec_version}" != "${sub_spec_version}" ] +then + cat <<-EOT + + changes to the runtime sources and changes in the spec version and wasm + binary blob. + + spec_version: ${sub_spec_version} -> ${add_spec_version} + + EOT + exit 0 +fi + + +cat <<-EOT + +wasm source files changed but not the spec version and the runtime +binary blob. This may break the api. + +EOT + + + + + +exit 1 + +# vim: noexpandtab