Ignore checks for companion PRs (#1455)

This commit is contained in:
Cecile Tonglet
2020-08-06 06:52:03 +02:00
committed by GitHub
parent bd85b3c7d3
commit 497772da18
8 changed files with 210 additions and 156 deletions
+6
View File
@@ -14,3 +14,9 @@ indent_style=space
indent_size=2 indent_size=2
tab_width=8 tab_width=8
end_of_line=lf end_of_line=lf
[*.sh]
indent_style=space
indent_size=2
tab_width=8
end_of_line=lf
+4 -21
View File
@@ -99,17 +99,7 @@ test-deterministic-wasm:
<<: *docker-env <<: *docker-env
except: except:
script: script:
# build runtime - ./scripts/gitlab/test_deterministic_wasm.sh
- 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 test-linux-stable: &test
stage: test stage: test
@@ -123,7 +113,7 @@ test-linux-stable: &test
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings" RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
TARGET: native TARGET: native
script: script:
- time cargo test --all --release --verbose --locked --features runtime-benchmarks - ./scripts/gitlab/test_linux_stable.sh
- sccache -s - sccache -s
check-web-wasm: &test check-web-wasm: &test
@@ -134,14 +124,7 @@ check-web-wasm: &test
script: script:
# WASM support is in progress. As more and more crates support WASM, we # 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 # 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 - ./scripts/gitlab/check_web_wasm.sh
- 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 - sccache -s
check-runtime-benchmarks: &test check-runtime-benchmarks: &test
@@ -151,7 +134,7 @@ check-runtime-benchmarks: &test
<<: *compiler_info <<: *compiler_info
script: script:
# Check that the node will compile with `runtime-benchmarks` feature flag. # 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 - sccache -s
build-wasm-release: build-wasm-release:
+137 -135
View File
@@ -34,13 +34,13 @@ boldprint "make sure the master branch is available in shallow clones"
git fetch --depth="${GIT_DEPTH:-100}" origin master git fetch --depth="${GIT_DEPTH:-100}" origin master
runtimes=( runtimes=(
"kusama" "kusama"
"polkadot" "polkadot"
"westend" "westend"
) )
common_dirs=( common_dirs=(
"common" "common"
) )
# Helper function to join elements in an array with a multi-char delimiter # 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}" boldprint "check if the wasm sources changed since ${LATEST_TAG}"
if ! git diff --name-only "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" \ 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 then
boldprint "no changes to any runtime source code detected" boldprint "no changes to any runtime source code detected"
# continue checking if Cargo.lock was updated with a new substrate reference # continue checking if Cargo.lock was updated with a new substrate reference
# and if that change includes a {spec|impl}_version update. # and if that change includes a {spec|impl}_version update.
SUBSTRATE_REFS_CHANGED="$( SUBSTRATE_REFS_CHANGED="$(
git diff "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" Cargo.lock \ 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 | sed -n -r "s~^[\+\-]source = \"${SUBSTRATE_REPO_CARGO}#([a-f0-9]+)\".*$~\1~p" | sort -u | wc -l
)" )"
# check Cargo.lock for substrate ref change # check Cargo.lock for substrate ref change
case "${SUBSTRATE_REFS_CHANGED}" in case "${SUBSTRATE_REFS_CHANGED}" in
(0) (0)
boldprint "substrate refs not changed in Cargo.lock" boldprint "substrate refs not changed in Cargo.lock"
exit 0 exit 0
;; ;;
(2) (2)
boldprint "substrate refs updated since ${LATEST_TAG}" boldprint "substrate refs updated since ${LATEST_TAG}"
;; ;;
(*) (*)
boldprint "check unsupported: more than one commit targeted in repo ${SUBSTRATE_REPO_CARGO}" boldprint "check unsupported: more than one commit targeted in repo ${SUBSTRATE_REPO_CARGO}"
exit 1 exit 1
esac esac
SUBSTRATE_PREV_REF="$( SUBSTRATE_PREV_REF="$(
git diff "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" Cargo.lock \ 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 | sed -n -r "s~^\-source = \"${SUBSTRATE_REPO_CARGO}#([a-f0-9]+)\".*$~\1~p" | sort -u | head -n 1
)" )"
SUBSTRATE_NEW_REF="$( SUBSTRATE_NEW_REF="$(
git diff "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" Cargo.lock \ 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 | sed -n -r "s~^\+source = \"${SUBSTRATE_REPO_CARGO}#([a-f0-9]+)\".*$~\1~p" | sort -u | head -n 1
)" )"
boldcat <<-EOT boldcat <<EOT
previous substrate commit id ${SUBSTRATE_PREV_REF} previous substrate commit id ${SUBSTRATE_PREV_REF}
new substrate commit id ${SUBSTRATE_NEW_REF} new substrate commit id ${SUBSTRATE_NEW_REF}
EOT EOT
# okay so now need to fetch the substrate repository and check whether spec_version or impl_version has changed there # 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)" SUBSTRATE_CLONE_DIR="$(mktemp -t -d substrate-XXXXXX)"
trap 'rm -rf "${SUBSTRATE_CLONE_DIR}"' INT QUIT TERM ABRT EXIT trap 'rm -rf "${SUBSTRATE_CLONE_DIR}"' INT QUIT TERM ABRT EXIT
git clone --depth="${GIT_DEPTH:-100}" --no-tags \ git clone --depth="${GIT_DEPTH:-100}" --no-tags \
"${SUBSTRATE_REPO}" "${SUBSTRATE_CLONE_DIR}" "${SUBSTRATE_REPO}" "${SUBSTRATE_CLONE_DIR}"
# check if there are changes to the spec|impl versions # check if there are changes to the spec|impl versions
git -C "${SUBSTRATE_CLONE_DIR}" diff \ git -C "${SUBSTRATE_CLONE_DIR}" diff \
"${SUBSTRATE_PREV_REF}..${SUBSTRATE_NEW_REF}" "${SUBSTRATE_VERSIONS_FILE}" \ "${SUBSTRATE_PREV_REF}..${SUBSTRATE_NEW_REF}" "${SUBSTRATE_VERSIONS_FILE}" \
| grep -E '^[\+\-][[:space:]]+(spec|impl)_version: +([0-9]+),$' || exit 0 | grep -E '^[\+\-][[:space:]]+(spec|impl)_version: +([0-9]+),$' || exit 0
boldcat <<-EOT boldcat <<EOT
spec_version or or impl_version have changed in substrate after updating Cargo.lock spec_version or or impl_version have changed in substrate after updating Cargo.lock
please make sure versions are bumped in polkadot accordingly please make sure versions are bumped in polkadot accordingly
EOT EOT
# Now check if any of the substrate changes have been tagged D2-breaksapi # Now check if any of the substrate changes have been tagged D2-breaksapi
( (
cd "${SUBSTRATE_CLONE_DIR}" cd "${SUBSTRATE_CLONE_DIR}"
substrate_changes="$(sanitised_git_logs "${SUBSTRATE_PREV_REF}" "${SUBSTRATE_NEW_REF}")" substrate_changes="$(sanitised_git_logs "${SUBSTRATE_PREV_REF}" "${SUBSTRATE_NEW_REF}")"
echo "$substrate_changes" | while read -r line; do echo "$substrate_changes" | while read -r line; do
pr_id=$(echo "$line" | sed -E 's/.*#([0-9]+)\)$/\1/') pr_id=$(echo "$line" | sed -E 's/.*#([0-9]+)\)$/\1/')
if has_label 'paritytech/substrate' "$pr_id" 'D2-breaksapi'; then if has_label 'paritytech/substrate' "$pr_id" 'D2-breaksapi'; then
boldprint "Substrate change labelled with D2-breaksapi. Labelling..." boldprint "Substrate change labelled with D2-breaksapi. Labelling..."
github_label "D2-breaksapi" github_label "D2-breaksapi"
exit 1 exit 1
fi fi
done done
) )
fi fi
failed_runtime_checks=()
# Iterate over each runtime defined at the start of the script # Iterate over each runtime defined at the start of the script
for RUNTIME in "${runtimes[@]}" for RUNTIME in "${runtimes[@]}"
do do
# Check if there were changes to this specific runtime or common directories. # Check if there were changes to this specific runtime or common directories.
# If not, we can skip to the next runtime # If not, we can skip to the next runtime
regex="^runtime/$(join_by '|^runtime/' "$RUNTIME" "${common_dirs[@]}")" regex="^runtime/$(join_by '|^runtime/' "$RUNTIME" "${common_dirs[@]}")"
if ! git diff --name-only "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" \ if ! git diff --name-only "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" \
| grep -E -q -e "$regex"; then | grep -E -q -e "$regex"; then
continue continue
fi fi
# check for spec_version updates: if the spec versions changed, then there is # check for spec_version updates: if the spec versions changed, then there is
# consensus-critical logic that has changed. the runtime wasm blobs must be # consensus-critical logic that has changed. the runtime wasm blobs must be
# rebuilt. # rebuilt.
add_spec_version="$( add_spec_version="$(
git diff "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" "runtime/${RUNTIME}/src/lib.rs" \ git diff "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" "runtime/${RUNTIME}/src/lib.rs" \
| sed -n -r "s/^\+[[:space:]]+spec_version: +([0-9]+),$/\1/p" | sed -n -r "s/^\+[[:space:]]+spec_version: +([0-9]+),$/\1/p"
)" )"
sub_spec_version="$( sub_spec_version="$(
git diff "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" "runtime/${RUNTIME}/src/lib.rs" \ git diff "refs/tags/${LATEST_TAG}...${CI_COMMIT_SHA}" "runtime/${RUNTIME}/src/lib.rs" \
| sed -n -r "s/^\-[[:space:]]+spec_version: +([0-9]+),$/\1/p" | sed -n -r "s/^\-[[:space:]]+spec_version: +([0-9]+),$/\1/p"
)" )"
# see if the version and the binary blob changed # see if the version and the binary blob changed
if [ "${add_spec_version}" != "${sub_spec_version}" ] if [ "${add_spec_version}" != "${sub_spec_version}" ]
then then
if git diff --name-only "origin/master...${CI_COMMIT_SHA}" \ if git diff --name-only "origin/master...${CI_COMMIT_SHA}" \
| grep -E -q -e "$regex" | grep -E -q -e "$regex"
then then
# add label breaksapi only if this pr altered the runtime sources # add label breaksapi only if this pr altered the runtime sources
github_label "D2-breaksapi" github_label "D2-breaksapi"
fi fi
boldcat <<-EOT boldcat <<EOT
## RUNTIME: ${RUNTIME} ## ## RUNTIME: ${RUNTIME} ##
changes to the ${RUNTIME} runtime sources and changes in the spec version. changes to the ${RUNTIME} runtime sources and changes in the spec version.
spec_version: ${sub_spec_version} -> ${add_spec_version} spec_version: ${sub_spec_version} -> ${add_spec_version}
EOT EOT
continue continue
else else
# check for impl_version updates: if only the impl versions changed, we assume # check for impl_version updates: if only the impl versions changed, we assume
# there is no consensus-critical logic that has changed. # there is no consensus-critical logic that has changed.
add_impl_version="$( add_impl_version="$(
git diff refs/tags/"${LATEST_TAG}...${CI_COMMIT_SHA}" "runtime/${RUNTIME}/src/lib.rs" \ 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' | sed -n -r 's/^\+[[:space:]]+impl_version: +([0-9]+),$/\1/p'
)" )"
sub_impl_version="$( sub_impl_version="$(
git diff refs/tags/"${LATEST_TAG}...${CI_COMMIT_SHA}" "runtime/${RUNTIME}/src/lib.rs" \ 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' | sed -n -r 's/^\-[[:space:]]+impl_version: +([0-9]+),$/\1/p'
)" )"
# see if the impl version changed # see if the impl version changed
if [ "${add_impl_version}" != "${sub_impl_version}" ] if [ "${add_impl_version}" != "${sub_impl_version}" ]
then then
boldcat <<-EOT boldcat <<EOT
## RUNTIME: ${RUNTIME} ## ## RUNTIME: ${RUNTIME} ##
changes to the ${RUNTIME} runtime sources and changes in the impl version. changes to the ${RUNTIME} runtime sources and changes in the impl version.
impl_version: ${sub_impl_version} -> ${add_impl_version} impl_version: ${sub_impl_version} -> ${add_impl_version}
EOT EOT
continue continue
fi fi
failed_runtime_checks+=("$RUNTIME")
boldcat <<-EOT fi
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'.
source file directories:
- runtime
versions file: ${RUNTIME}
EOT
exit 1
fi
done done
exit 0 if [ ${#failed_runtime_checks} -gt 0 ]; then
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'.
# vim: noexpandtab source file directories:
- runtime
version files: ${failed_runtime_checks[@]}
EOT
exit 1
fi
exit 0
+8
View File
@@ -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 check --features runtime-benchmarks
+15
View File
@@ -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
+15
View File
@@ -96,3 +96,18 @@ curl -XPOST -d "$1" "https://matrix.parity.io/_matrix/client/r0/rooms/$2/send/m.
# Pretty-printing functions # Pretty-printing functions
boldprint () { printf "|\n| \033[1m%s\033[0m\n|\n" "${@}"; } 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" ; } 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
}
+17
View File
@@ -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
+8
View File
@@ -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