Files
pezkuwi-subxt/substrate/scripts/gitlab/check_runtime.sh
T
gabriel klawitter 888e7bb76f add test for wasm runtime changes (#1612)
* add test for wasm runtime changes

* use default container

* disable cache for runtime source test

* compare spec_versions directly
2019-02-05 10:50:44 +01:00

71 lines
1.6 KiB
Bash
Executable File

#!/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