From a60352fd7b4e45a8eabdf62acb6322f3cd5109d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Thu, 6 Aug 2020 14:36:58 +0200 Subject: [PATCH 1/3] Revert "Ignore checks for companion PRs (#1455)" This reverts commit 161ff37d351de8fcf4695c5c8cde1bf45ec42ae6. --- .editorconfig | 6 - .gitlab-ci.yml | 25 +- scripts/gitlab/check_runtime.sh | 292 ++++++++++----------- scripts/gitlab/check_runtime_benchmarks.sh | 8 - scripts/gitlab/check_web_wasm.sh | 15 -- scripts/gitlab/lib.sh | 15 -- scripts/gitlab/test_deterministic_wasm.sh | 17 -- scripts/gitlab/test_linux_stable.sh | 8 - 8 files changed, 166 insertions(+), 220 deletions(-) delete mode 100755 scripts/gitlab/check_runtime_benchmarks.sh delete mode 100755 scripts/gitlab/check_web_wasm.sh delete mode 100755 scripts/gitlab/test_deterministic_wasm.sh delete mode 100755 scripts/gitlab/test_linux_stable.sh diff --git a/.editorconfig b/.editorconfig index dda39da09e90..f511aad46079 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,9 +14,3 @@ indent_style=space indent_size=2 tab_width=8 end_of_line=lf - -[*.sh] -indent_style=space -indent_size=2 -tab_width=8 -end_of_line=lf diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1f2ef6ded2a7..11312ad64959 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -99,7 +99,17 @@ test-deterministic-wasm: <<: *docker-env except: script: - - ./scripts/gitlab/test_deterministic_wasm.sh + # build runtime + - WASM_BUILD_NO_COLOR=1 cargo build --verbose --release -p kusama-runtime -p polkadot-runtime -p westend-runtime + # make checksum + - sha256sum target/release/wbuild/target/wasm32-unknown-unknown/release/*.wasm > checksum.sha256 + # clean up – FIXME: can we reuse some of the artifacts? + - cargo clean + # build again + - WASM_BUILD_NO_COLOR=1 cargo build --verbose --release -p kusama-runtime -p polkadot-runtime -p westend-runtime + # confirm checksum + - sha256sum -c checksum.sha256 + test-linux-stable: &test stage: test @@ -113,7 +123,7 @@ test-linux-stable: &test RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings" TARGET: native script: - - ./scripts/gitlab/test_linux_stable.sh + - time cargo test --all --release --verbose --locked --features runtime-benchmarks - sccache -s check-web-wasm: &test @@ -124,7 +134,14 @@ check-web-wasm: &test script: # WASM support is in progress. As more and more crates support WASM, we # should add entries here. See https://github.com/paritytech/polkadot/issues/625 - - ./scripts/gitlab/check_web_wasm.sh + - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path runtime/polkadot/Cargo.toml + - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path runtime/kusama/Cargo.toml + - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path erasure-coding/Cargo.toml + - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path parachain/Cargo.toml + - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path primitives/Cargo.toml + - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path rpc/Cargo.toml + - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path statement-table/Cargo.toml + - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path cli/Cargo.toml --no-default-features --features browser - sccache -s check-runtime-benchmarks: &test @@ -134,7 +151,7 @@ check-runtime-benchmarks: &test <<: *compiler_info script: # Check that the node will compile with `runtime-benchmarks` feature flag. - - ./scripts/gitlab/check_runtime_benchmarks.sh + - time cargo check --features runtime-benchmarks - sccache -s build-wasm-release: diff --git a/scripts/gitlab/check_runtime.sh b/scripts/gitlab/check_runtime.sh index 0c635c88246c..30fdcd455c1d 100755 --- a/scripts/gitlab/check_runtime.sh +++ b/scripts/gitlab/check_runtime.sh @@ -34,13 +34,13 @@ boldprint "make sure the master branch is available in shallow clones" git fetch --depth="${GIT_DEPTH:-100}" origin master runtimes=( - "kusama" - "polkadot" - "westend" + "kusama" + "polkadot" + "westend" ) common_dirs=( - "common" + "common" ) # Helper function to join elements in an array with a multi-char delimiter @@ -52,178 +52,176 @@ runtime_regex="^runtime/$(join_by '|^runtime/' "${runtimes[@]}" "${common_dirs[@ boldprint "check if the wasm sources changed since ${LATEST_TAG}" if ! git diff --name-only "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" \ - | grep -E -q -e "$runtime_regex" + | grep -E -q -e "$runtime_regex" then - boldprint "no changes to any runtime source code detected" - # continue checking if Cargo.lock was updated with a new substrate reference - # and if that change includes a {spec|impl}_version update. - - SUBSTRATE_REFS_CHANGED="$( - git diff "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" Cargo.lock \ - | sed -n -r "s~^[\+\-]source = \"${SUBSTRATE_REPO_CARGO}#([a-f0-9]+)\".*$~\1~p" | sort -u | wc -l - )" - - # check Cargo.lock for substrate ref change - case "${SUBSTRATE_REFS_CHANGED}" in - (0) - boldprint "substrate refs not changed in Cargo.lock" - exit 0 - ;; - (2) - boldprint "substrate refs updated since ${LATEST_TAG}" - ;; - (*) - boldprint "check unsupported: more than one commit targeted in repo ${SUBSTRATE_REPO_CARGO}" - exit 1 - esac - - - SUBSTRATE_PREV_REF="$( - git diff "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" Cargo.lock \ - | sed -n -r "s~^\-source = \"${SUBSTRATE_REPO_CARGO}#([a-f0-9]+)\".*$~\1~p" | sort -u | head -n 1 - )" - - SUBSTRATE_NEW_REF="$( - git diff "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" Cargo.lock \ - | sed -n -r "s~^\+source = \"${SUBSTRATE_REPO_CARGO}#([a-f0-9]+)\".*$~\1~p" | sort -u | head -n 1 - )" - - - boldcat < ${add_spec_version} + spec_version: ${sub_spec_version} -> ${add_spec_version} -EOT - continue + EOT + continue - else - # check for impl_version updates: if only the impl versions changed, we assume - # there is no consensus-critical logic that has changed. + else + # check for impl_version updates: if only the impl versions changed, we assume + # there is no consensus-critical logic that has changed. - add_impl_version="$( - git diff refs/tags/"${LATEST_TAG}...${CI_COMMIT_SHA}" "runtime/${RUNTIME}/src/lib.rs" \ - | sed -n -r 's/^\+[[:space:]]+impl_version: +([0-9]+),$/\1/p' - )" - sub_impl_version="$( - git diff refs/tags/"${LATEST_TAG}...${CI_COMMIT_SHA}" "runtime/${RUNTIME}/src/lib.rs" \ - | sed -n -r 's/^\-[[:space:]]+impl_version: +([0-9]+),$/\1/p' - )" + add_impl_version="$( + git diff refs/tags/"${LATEST_TAG}...${CI_COMMIT_SHA}" "runtime/${RUNTIME}/src/lib.rs" \ + | sed -n -r 's/^\+[[:space:]]+impl_version: +([0-9]+),$/\1/p' + )" + sub_impl_version="$( + git diff refs/tags/"${LATEST_TAG}...${CI_COMMIT_SHA}" "runtime/${RUNTIME}/src/lib.rs" \ + | sed -n -r 's/^\-[[:space:]]+impl_version: +([0-9]+),$/\1/p' + )" - # see if the impl version changed - if [ "${add_impl_version}" != "${sub_impl_version}" ] - then - boldcat < ${add_impl_version} + impl_version: ${sub_impl_version} -> ${add_impl_version} -EOT - continue - fi + EOT + continue + fi - failed_runtime_checks+=("$RUNTIME") - fi -done -if [ ${#failed_runtime_checks} -gt 0 ]; then - boldcat </dev/null 2>&1 && pwd )/lib.sh" - -skip_if_companion_pr - -time cargo check --features runtime-benchmarks diff --git a/scripts/gitlab/check_web_wasm.sh b/scripts/gitlab/check_web_wasm.sh deleted file mode 100755 index 056e90d1e37d..000000000000 --- a/scripts/gitlab/check_web_wasm.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -#shellcheck source=lib.sh -source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh" - -skip_if_companion_pr - -time cargo build --locked --target=wasm32-unknown-unknown --manifest-path runtime/polkadot/Cargo.toml -time cargo build --locked --target=wasm32-unknown-unknown --manifest-path runtime/kusama/Cargo.toml -time cargo build --locked --target=wasm32-unknown-unknown --manifest-path erasure-coding/Cargo.toml -time cargo build --locked --target=wasm32-unknown-unknown --manifest-path parachain/Cargo.toml -time cargo build --locked --target=wasm32-unknown-unknown --manifest-path primitives/Cargo.toml -time cargo build --locked --target=wasm32-unknown-unknown --manifest-path rpc/Cargo.toml -time cargo build --locked --target=wasm32-unknown-unknown --manifest-path statement-table/Cargo.toml -time cargo build --locked --target=wasm32-unknown-unknown --manifest-path cli/Cargo.toml --no-default-features --features browser diff --git a/scripts/gitlab/lib.sh b/scripts/gitlab/lib.sh index 993cab35e340..ab2e7c86f676 100755 --- a/scripts/gitlab/lib.sh +++ b/scripts/gitlab/lib.sh @@ -96,18 +96,3 @@ curl -XPOST -d "$1" "https://matrix.parity.io/_matrix/client/r0/rooms/$2/send/m. # Pretty-printing functions boldprint () { printf "|\n| \033[1m%s\033[0m\n|\n" "${@}"; } boldcat () { printf "|\n"; while read -r l; do printf "| \033[1m%s\033[0m\n" "${l}"; done; printf "|\n" ; } - -skip_if_companion_pr() { - url="https://api.github.com/repos/paritytech/polkadot/pulls/${CI_COMMIT_REF_NAME}" - echo "[+] API URL: $url" - - pr_title=$(curl -sSL -H "Authorization: token ${GITHUB_PR_TOKEN}" "$url" | jq -r .title) - echo "[+] PR title: $pr_title" - - if echo "$pr_title" | grep -qi '^companion'; then - echo "[!] PR is a companion PR. Build is already done in substrate" - exit 0 - else - echo "[+] PR is not a companion PR. Proceeding test" - fi -} diff --git a/scripts/gitlab/test_deterministic_wasm.sh b/scripts/gitlab/test_deterministic_wasm.sh deleted file mode 100755 index f2bf2a4f05f1..000000000000 --- a/scripts/gitlab/test_deterministic_wasm.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -#shellcheck source=lib.sh -source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh" - -skip_if_companion_pr - -# build runtime -WASM_BUILD_NO_COLOR=1 cargo build --verbose --release -p kusama-runtime -p polkadot-runtime -p westend-runtime -# make checksum -sha256sum target/release/wbuild/target/wasm32-unknown-unknown/release/*.wasm > checksum.sha256 -# clean up - FIXME: can we reuse some of the artifacts? -cargo clean -# build again -WASM_BUILD_NO_COLOR=1 cargo build --verbose --release -p kusama-runtime -p polkadot-runtime -p westend-runtime -# confirm checksum -sha256sum -c checksum.sha256 diff --git a/scripts/gitlab/test_linux_stable.sh b/scripts/gitlab/test_linux_stable.sh deleted file mode 100755 index f523e24434ab..000000000000 --- a/scripts/gitlab/test_linux_stable.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -#shellcheck source=lib.sh -source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh" - -skip_if_companion_pr - -time cargo test --all --release --verbose --locked --features runtime-benchmarks From 05a106f235283d3100d501019307bc02492e1ba7 Mon Sep 17 00:00:00 2001 From: Cecile Tonglet Date: Thu, 6 Aug 2020 16:10:58 +0200 Subject: [PATCH 2/3] Revert "Revert "Ignore checks for companion PRs (#1455)"" This reverts commit 4ac4a2b79a94a92e79699b034e36c245a4fd56f3. --- .editorconfig | 6 + .gitlab-ci.yml | 25 +- scripts/gitlab/check_runtime.sh | 292 +++++++++++---------- scripts/gitlab/check_runtime_benchmarks.sh | 8 + scripts/gitlab/check_web_wasm.sh | 15 ++ scripts/gitlab/lib.sh | 15 ++ scripts/gitlab/test_deterministic_wasm.sh | 17 ++ scripts/gitlab/test_linux_stable.sh | 8 + 8 files changed, 220 insertions(+), 166 deletions(-) create mode 100755 scripts/gitlab/check_runtime_benchmarks.sh create mode 100755 scripts/gitlab/check_web_wasm.sh create mode 100755 scripts/gitlab/test_deterministic_wasm.sh create mode 100755 scripts/gitlab/test_linux_stable.sh diff --git a/.editorconfig b/.editorconfig index f511aad46079..dda39da09e90 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,3 +14,9 @@ indent_style=space indent_size=2 tab_width=8 end_of_line=lf + +[*.sh] +indent_style=space +indent_size=2 +tab_width=8 +end_of_line=lf diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 11312ad64959..1f2ef6ded2a7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -99,17 +99,7 @@ test-deterministic-wasm: <<: *docker-env except: script: - # build runtime - - WASM_BUILD_NO_COLOR=1 cargo build --verbose --release -p kusama-runtime -p polkadot-runtime -p westend-runtime - # make checksum - - sha256sum target/release/wbuild/target/wasm32-unknown-unknown/release/*.wasm > checksum.sha256 - # clean up – FIXME: can we reuse some of the artifacts? - - cargo clean - # build again - - WASM_BUILD_NO_COLOR=1 cargo build --verbose --release -p kusama-runtime -p polkadot-runtime -p westend-runtime - # confirm checksum - - sha256sum -c checksum.sha256 - + - ./scripts/gitlab/test_deterministic_wasm.sh test-linux-stable: &test stage: test @@ -123,7 +113,7 @@ test-linux-stable: &test RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings" TARGET: native script: - - time cargo test --all --release --verbose --locked --features runtime-benchmarks + - ./scripts/gitlab/test_linux_stable.sh - sccache -s check-web-wasm: &test @@ -134,14 +124,7 @@ check-web-wasm: &test script: # WASM support is in progress. As more and more crates support WASM, we # should add entries here. See https://github.com/paritytech/polkadot/issues/625 - - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path runtime/polkadot/Cargo.toml - - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path runtime/kusama/Cargo.toml - - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path erasure-coding/Cargo.toml - - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path parachain/Cargo.toml - - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path primitives/Cargo.toml - - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path rpc/Cargo.toml - - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path statement-table/Cargo.toml - - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path cli/Cargo.toml --no-default-features --features browser + - ./scripts/gitlab/check_web_wasm.sh - sccache -s check-runtime-benchmarks: &test @@ -151,7 +134,7 @@ check-runtime-benchmarks: &test <<: *compiler_info script: # Check that the node will compile with `runtime-benchmarks` feature flag. - - time cargo check --features runtime-benchmarks + - ./scripts/gitlab/check_runtime_benchmarks.sh - sccache -s build-wasm-release: diff --git a/scripts/gitlab/check_runtime.sh b/scripts/gitlab/check_runtime.sh index 30fdcd455c1d..0c635c88246c 100755 --- a/scripts/gitlab/check_runtime.sh +++ b/scripts/gitlab/check_runtime.sh @@ -34,13 +34,13 @@ boldprint "make sure the master branch is available in shallow clones" git fetch --depth="${GIT_DEPTH:-100}" origin master runtimes=( - "kusama" - "polkadot" - "westend" + "kusama" + "polkadot" + "westend" ) common_dirs=( - "common" + "common" ) # Helper function to join elements in an array with a multi-char delimiter @@ -52,176 +52,178 @@ runtime_regex="^runtime/$(join_by '|^runtime/' "${runtimes[@]}" "${common_dirs[@ boldprint "check if the wasm sources changed since ${LATEST_TAG}" if ! git diff --name-only "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" \ - | grep -E -q -e "$runtime_regex" + | grep -E -q -e "$runtime_regex" then - boldprint "no changes to any runtime source code detected" - # continue checking if Cargo.lock was updated with a new substrate reference - # and if that change includes a {spec|impl}_version update. - - SUBSTRATE_REFS_CHANGED="$( - git diff "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" Cargo.lock \ - | sed -n -r "s~^[\+\-]source = \"${SUBSTRATE_REPO_CARGO}#([a-f0-9]+)\".*$~\1~p" | sort -u | wc -l - )" - - # check Cargo.lock for substrate ref change - case "${SUBSTRATE_REFS_CHANGED}" in - (0) - boldprint "substrate refs not changed in Cargo.lock" - exit 0 - ;; - (2) - boldprint "substrate refs updated since ${LATEST_TAG}" - ;; - (*) - boldprint "check unsupported: more than one commit targeted in repo ${SUBSTRATE_REPO_CARGO}" - exit 1 - esac - - - SUBSTRATE_PREV_REF="$( - git diff "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" Cargo.lock \ - | sed -n -r "s~^\-source = \"${SUBSTRATE_REPO_CARGO}#([a-f0-9]+)\".*$~\1~p" | sort -u | head -n 1 - )" - - SUBSTRATE_NEW_REF="$( - git diff "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" Cargo.lock \ - | sed -n -r "s~^\+source = \"${SUBSTRATE_REPO_CARGO}#([a-f0-9]+)\".*$~\1~p" | sort -u | head -n 1 - )" - - - boldcat <<-EOT - previous substrate commit id ${SUBSTRATE_PREV_REF} - new substrate commit id ${SUBSTRATE_NEW_REF} - EOT - - # okay so now need to fetch the substrate repository and check whether spec_version or impl_version has changed there - SUBSTRATE_CLONE_DIR="$(mktemp -t -d substrate-XXXXXX)" - trap 'rm -rf "${SUBSTRATE_CLONE_DIR}"' INT QUIT TERM ABRT EXIT - - git clone --depth="${GIT_DEPTH:-100}" --no-tags \ - "${SUBSTRATE_REPO}" "${SUBSTRATE_CLONE_DIR}" - - # check if there are changes to the spec|impl versions - git -C "${SUBSTRATE_CLONE_DIR}" diff \ - "${SUBSTRATE_PREV_REF}..${SUBSTRATE_NEW_REF}" "${SUBSTRATE_VERSIONS_FILE}" \ - | grep -E '^[\+\-][[:space:]]+(spec|impl)_version: +([0-9]+),$' || exit 0 - - boldcat <<-EOT - spec_version or or impl_version have changed in substrate after updating Cargo.lock - please make sure versions are bumped in polkadot accordingly - EOT - - # Now check if any of the substrate changes have been tagged D2-breaksapi - ( - cd "${SUBSTRATE_CLONE_DIR}" - substrate_changes="$(sanitised_git_logs "${SUBSTRATE_PREV_REF}" "${SUBSTRATE_NEW_REF}")" - echo "$substrate_changes" | while read -r line; do - pr_id=$(echo "$line" | sed -E 's/.*#([0-9]+)\)$/\1/') - - if has_label 'paritytech/substrate' "$pr_id" 'D2-breaksapi'; then - boldprint "Substrate change labelled with D2-breaksapi. Labelling..." - github_label "D2-breaksapi" - exit 1 - fi - done - ) + boldprint "no changes to any runtime source code detected" + # continue checking if Cargo.lock was updated with a new substrate reference + # and if that change includes a {spec|impl}_version update. + + SUBSTRATE_REFS_CHANGED="$( + git diff "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" Cargo.lock \ + | sed -n -r "s~^[\+\-]source = \"${SUBSTRATE_REPO_CARGO}#([a-f0-9]+)\".*$~\1~p" | sort -u | wc -l + )" + + # check Cargo.lock for substrate ref change + case "${SUBSTRATE_REFS_CHANGED}" in + (0) + boldprint "substrate refs not changed in Cargo.lock" + exit 0 + ;; + (2) + boldprint "substrate refs updated since ${LATEST_TAG}" + ;; + (*) + boldprint "check unsupported: more than one commit targeted in repo ${SUBSTRATE_REPO_CARGO}" + exit 1 + esac + + + SUBSTRATE_PREV_REF="$( + git diff "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" Cargo.lock \ + | sed -n -r "s~^\-source = \"${SUBSTRATE_REPO_CARGO}#([a-f0-9]+)\".*$~\1~p" | sort -u | head -n 1 + )" + + SUBSTRATE_NEW_REF="$( + git diff "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" Cargo.lock \ + | sed -n -r "s~^\+source = \"${SUBSTRATE_REPO_CARGO}#([a-f0-9]+)\".*$~\1~p" | sort -u | head -n 1 + )" + + + boldcat < ${add_spec_version} +changes to the ${RUNTIME} runtime sources and changes in the spec version. - EOT - continue +spec_version: ${sub_spec_version} -> ${add_spec_version} - else - # check for impl_version updates: if only the impl versions changed, we assume - # there is no consensus-critical logic that has changed. +EOT + continue - add_impl_version="$( - git diff refs/tags/"${LATEST_TAG}...${CI_COMMIT_SHA}" "runtime/${RUNTIME}/src/lib.rs" \ - | sed -n -r 's/^\+[[:space:]]+impl_version: +([0-9]+),$/\1/p' - )" - sub_impl_version="$( - git diff refs/tags/"${LATEST_TAG}...${CI_COMMIT_SHA}" "runtime/${RUNTIME}/src/lib.rs" \ - | sed -n -r 's/^\-[[:space:]]+impl_version: +([0-9]+),$/\1/p' - )" + else + # check for impl_version updates: if only the impl versions changed, we assume + # there is no consensus-critical logic that has changed. + add_impl_version="$( + git diff refs/tags/"${LATEST_TAG}...${CI_COMMIT_SHA}" "runtime/${RUNTIME}/src/lib.rs" \ + | sed -n -r 's/^\+[[:space:]]+impl_version: +([0-9]+),$/\1/p' + )" + sub_impl_version="$( + git diff refs/tags/"${LATEST_TAG}...${CI_COMMIT_SHA}" "runtime/${RUNTIME}/src/lib.rs" \ + | sed -n -r 's/^\-[[:space:]]+impl_version: +([0-9]+),$/\1/p' + )" - # see if the impl version changed - if [ "${add_impl_version}" != "${sub_impl_version}" ] - then - boldcat <<-EOT - ## RUNTIME: ${RUNTIME} ## + # see if the impl version changed + if [ "${add_impl_version}" != "${sub_impl_version}" ] + then + boldcat < ${add_impl_version} +changes to the ${RUNTIME} runtime sources and changes in the impl version. - EOT - continue - fi +impl_version: ${sub_impl_version} -> ${add_impl_version} +EOT + continue + fi - boldcat <<-EOT - wasm source files changed or the spec version in the substrate reference in - the Cargo.lock but not the spec/impl version. If changes made do not alter - logic, just bump 'impl_version'. If they do change logic, bump - 'spec_version'. + failed_runtime_checks+=("$RUNTIME") + fi +done - source file directories: - - runtime +if [ ${#failed_runtime_checks} -gt 0 ]; then + boldcat </dev/null 2>&1 && pwd )/lib.sh" + +skip_if_companion_pr + +time cargo check --features runtime-benchmarks diff --git a/scripts/gitlab/check_web_wasm.sh b/scripts/gitlab/check_web_wasm.sh new file mode 100755 index 000000000000..056e90d1e37d --- /dev/null +++ b/scripts/gitlab/check_web_wasm.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +#shellcheck source=lib.sh +source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh" + +skip_if_companion_pr + +time cargo build --locked --target=wasm32-unknown-unknown --manifest-path runtime/polkadot/Cargo.toml +time cargo build --locked --target=wasm32-unknown-unknown --manifest-path runtime/kusama/Cargo.toml +time cargo build --locked --target=wasm32-unknown-unknown --manifest-path erasure-coding/Cargo.toml +time cargo build --locked --target=wasm32-unknown-unknown --manifest-path parachain/Cargo.toml +time cargo build --locked --target=wasm32-unknown-unknown --manifest-path primitives/Cargo.toml +time cargo build --locked --target=wasm32-unknown-unknown --manifest-path rpc/Cargo.toml +time cargo build --locked --target=wasm32-unknown-unknown --manifest-path statement-table/Cargo.toml +time cargo build --locked --target=wasm32-unknown-unknown --manifest-path cli/Cargo.toml --no-default-features --features browser diff --git a/scripts/gitlab/lib.sh b/scripts/gitlab/lib.sh index ab2e7c86f676..993cab35e340 100755 --- a/scripts/gitlab/lib.sh +++ b/scripts/gitlab/lib.sh @@ -96,3 +96,18 @@ curl -XPOST -d "$1" "https://matrix.parity.io/_matrix/client/r0/rooms/$2/send/m. # Pretty-printing functions boldprint () { printf "|\n| \033[1m%s\033[0m\n|\n" "${@}"; } boldcat () { printf "|\n"; while read -r l; do printf "| \033[1m%s\033[0m\n" "${l}"; done; printf "|\n" ; } + +skip_if_companion_pr() { + url="https://api.github.com/repos/paritytech/polkadot/pulls/${CI_COMMIT_REF_NAME}" + echo "[+] API URL: $url" + + pr_title=$(curl -sSL -H "Authorization: token ${GITHUB_PR_TOKEN}" "$url" | jq -r .title) + echo "[+] PR title: $pr_title" + + if echo "$pr_title" | grep -qi '^companion'; then + echo "[!] PR is a companion PR. Build is already done in substrate" + exit 0 + else + echo "[+] PR is not a companion PR. Proceeding test" + fi +} diff --git a/scripts/gitlab/test_deterministic_wasm.sh b/scripts/gitlab/test_deterministic_wasm.sh new file mode 100755 index 000000000000..f2bf2a4f05f1 --- /dev/null +++ b/scripts/gitlab/test_deterministic_wasm.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +#shellcheck source=lib.sh +source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh" + +skip_if_companion_pr + +# build runtime +WASM_BUILD_NO_COLOR=1 cargo build --verbose --release -p kusama-runtime -p polkadot-runtime -p westend-runtime +# make checksum +sha256sum target/release/wbuild/target/wasm32-unknown-unknown/release/*.wasm > checksum.sha256 +# clean up - FIXME: can we reuse some of the artifacts? +cargo clean +# build again +WASM_BUILD_NO_COLOR=1 cargo build --verbose --release -p kusama-runtime -p polkadot-runtime -p westend-runtime +# confirm checksum +sha256sum -c checksum.sha256 diff --git a/scripts/gitlab/test_linux_stable.sh b/scripts/gitlab/test_linux_stable.sh new file mode 100755 index 000000000000..f523e24434ab --- /dev/null +++ b/scripts/gitlab/test_linux_stable.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +#shellcheck source=lib.sh +source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh" + +skip_if_companion_pr + +time cargo test --all --release --verbose --locked --features runtime-benchmarks From c2eda36bf74a2b0318df01b8d14340582fc58774 Mon Sep 17 00:00:00 2001 From: Cecile Tonglet Date: Thu, 6 Aug 2020 16:11:49 +0200 Subject: [PATCH 3/3] WIP Forked at: e91642361133dba084a9c9b3efa45fcb6cd3c5ca Parent branch: origin/rococo-branch --- scripts/gitlab/check_runtime_benchmarks.sh | 2 -- scripts/gitlab/check_web_wasm.sh | 2 -- scripts/gitlab/test_deterministic_wasm.sh | 2 -- scripts/gitlab/test_linux_stable.sh | 2 -- 4 files changed, 8 deletions(-) diff --git a/scripts/gitlab/check_runtime_benchmarks.sh b/scripts/gitlab/check_runtime_benchmarks.sh index 6714279d5e58..d215106ef25d 100755 --- a/scripts/gitlab/check_runtime_benchmarks.sh +++ b/scripts/gitlab/check_runtime_benchmarks.sh @@ -3,6 +3,4 @@ #shellcheck source=lib.sh source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh" -skip_if_companion_pr - time cargo check --features runtime-benchmarks diff --git a/scripts/gitlab/check_web_wasm.sh b/scripts/gitlab/check_web_wasm.sh index 056e90d1e37d..9d9006e908a7 100755 --- a/scripts/gitlab/check_web_wasm.sh +++ b/scripts/gitlab/check_web_wasm.sh @@ -3,8 +3,6 @@ #shellcheck source=lib.sh source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh" -skip_if_companion_pr - time cargo build --locked --target=wasm32-unknown-unknown --manifest-path runtime/polkadot/Cargo.toml time cargo build --locked --target=wasm32-unknown-unknown --manifest-path runtime/kusama/Cargo.toml time cargo build --locked --target=wasm32-unknown-unknown --manifest-path erasure-coding/Cargo.toml diff --git a/scripts/gitlab/test_deterministic_wasm.sh b/scripts/gitlab/test_deterministic_wasm.sh index f2bf2a4f05f1..db391ca0a2fd 100755 --- a/scripts/gitlab/test_deterministic_wasm.sh +++ b/scripts/gitlab/test_deterministic_wasm.sh @@ -3,8 +3,6 @@ #shellcheck source=lib.sh source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh" -skip_if_companion_pr - # build runtime WASM_BUILD_NO_COLOR=1 cargo build --verbose --release -p kusama-runtime -p polkadot-runtime -p westend-runtime # make checksum diff --git a/scripts/gitlab/test_linux_stable.sh b/scripts/gitlab/test_linux_stable.sh index f523e24434ab..a18ff4387409 100755 --- a/scripts/gitlab/test_linux_stable.sh +++ b/scripts/gitlab/test_linux_stable.sh @@ -3,6 +3,4 @@ #shellcheck source=lib.sh source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh" -skip_if_companion_pr - time cargo test --all --release --verbose --locked --features runtime-benchmarks