-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Companion: move check-polkadot-companion-build to polkadot #1426
Changes from 1 commit
e5e4e79
36802ad
3c3318d
d9584b5
eda599c
905551f
6c7bc96
38cf177
0d00e35
d062be6
6f18a20
b687b14
32d831f
3a8f8b8
0003994
9ddeb6f
f0037fb
69ddd54
0080e32
6bac55c
1c9dbe1
063fbe3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Forked at: d390eb5 Parent branch: origin/master
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,87 @@ | ||
| #!/bin/sh | ||
| url="https://api.github.com/repos/paritytech/polkadot/pulls/${CI_COMMIT_REF_NAME}" | ||
| echo "[+] API URL: $url" | ||
|
|
||
| pr_title=$(curl -H "Authorization: token ${GITHUB_PR_TOKEN}" "$url" | grep -Po '"title": "\K[^"]+') | ||
| 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 | ||
| github_api_polkadot_pull_url="https://api.github.com/repos/paritytech/polkadot/pulls" | ||
| # use github api v3 in order to access the data without authentication | ||
| github_header="Authorization: token ${GITHUB_PR_TOKEN}" | ||
|
|
||
| boldprint () { printf "|\n| \033[1m${@}\033[0m\n|\n" ; } | ||
| boldcat () { printf "|\n"; while read l; do printf "| \033[1m${l}\033[0m\n"; done; printf "|\n" ; } | ||
|
|
||
|
|
||
|
|
||
| POLKADOT_PATH=$(pwd) | ||
|
|
||
|
|
||
| prepare_git(){ | ||
| # Set the user name and email to make merging work | ||
| git config --global user.name 'CI system' | ||
| git config --global user.email '<>' | ||
| } | ||
|
|
||
|
|
||
| prepare_substrate(){ | ||
| pr_companion=$1 | ||
| boldprint "companion pr specified/detected: #${pr_companion}" | ||
|
|
||
| # Clone the current Substrate master branch into ./substrate. | ||
| # NOTE: we need to pull enough commits to be able to find a common | ||
| # ancestor for successfully performing merges below. | ||
| git clone --depth 20 https://github.com/paritytech/substrate.git | ||
| cd substrate | ||
| SUBSTRATE_PATH=$(pwd) | ||
|
|
||
| git fetch origin refs/pull/${pr_companion}/head:pr/${pr_companion} | ||
| git checkout pr/${pr_companion} | ||
| git merge origin/master | ||
|
|
||
| cd "$POLKADOT_PATH" | ||
|
|
||
| # Merge master into our branch before building Polkadot to make sure we don't miss | ||
| # any commits that are required by Polkadot. | ||
| git merge origin/master | ||
|
||
|
|
||
| # Make sure we override the crates in native and wasm build | ||
| # patching the git path as described in the link below did not test correctly | ||
| # https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html | ||
| mkdir .cargo | ||
| echo "paths = [ \"$SUBSTRATE_PATH\" ]" > .cargo/config | ||
|
||
|
|
||
| mkdir -p target/debug/wbuild/.cargo | ||
| cp .cargo/config target/debug/wbuild/.cargo/config | ||
| } | ||
|
|
||
|
|
||
| # either it's a pull request then check for a companion otherwise use | ||
| # substrate:master | ||
| if expr match "${CI_COMMIT_REF_NAME}" '^[0-9]\+$' >/dev/null | ||
| then | ||
| boldprint "this is pull request no ${CI_COMMIT_REF_NAME}" | ||
|
|
||
| pr_data_file="$(mktemp)" | ||
| # get the last reference to a pr in substrate | ||
| curl -sSL -H "${github_header}" -o "${pr_data_file}" \ | ||
| "${github_api_polkadot_pull_url}/${CI_COMMIT_REF_NAME}" | ||
|
|
||
| pr_body="$(sed -n -r 's/^[[:space:]]+"body": (".*")[^"]+$/\1/p' "${pr_data_file}")" | ||
|
|
||
| pr_companion="$(echo "${pr_body}" | sed -n -r \ | ||
| -e 's;^.*substrate companion: paritytech/substrate#([0-9]+).*$;\1;p' \ | ||
| -e 's;^.*substrate companion: https://github.com/paritytech/substrate/pull/([0-9]+).*$;\1;p' \ | ||
| | tail -n 1)" | ||
|
|
||
| if [ "${pr_companion}" ] | ||
| then | ||
| prepare_git | ||
| prepare_substrate "$pr_companion" | ||
| else | ||
| boldprint "no companion branch found - building substrate:master" | ||
cecton marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fi | ||
| rm -f "${pr_data_file}" | ||
| else | ||
| echo "[+] PR is not a companion PR. Proceeding test" | ||
| time cargo test --all --release --verbose --locked --features runtime-benchmarks | ||
| boldprint "this is not a pull request - building substrate:master" | ||
cecton marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fi | ||
|
|
||
|
|
||
| # Test Polkadot pr or master branch with this Substrate commit. | ||
| time cargo test --all --release --verbose --locked --features runtime-benchmarks | ||
Uh oh!
There was an error while loading. Please reload this page.