Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

check polkadot for companion pull requests #5262

Merged
merged 15 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 9 additions & 24 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ check-line-width:
allow_failure: true


check-polkadot:
stage: build
<<: *docker-env
script:
- ./.maintain/gitlab/check_polkadot.sh
interruptible: true
allow_failure: true


cargo-audit:
stage: test
<<: *docker-env
Expand Down Expand Up @@ -376,30 +385,6 @@ check_warnings:
echo "___No warnings___";
fi

# Nightly check whether Polkadot 'master' branch builds.
check_polkadot:
stage: build
<<: *docker-env
allow_failure: true
only:
- master
- schedules
script:
- SUBSTRATE_PATH=$(pwd)
# Clone the current Polkadot master branch into ./polkadot.
- git clone --depth 1 https://gitlab.parity.io/parity/polkadot.git
- cd polkadot
# Make sure we override the crates in native and wasm build
- mkdir .cargo
- echo "paths = [ \"$SUBSTRATE_PATH\" ]" > .cargo/config
- mkdir -p target/debug/wbuild/.cargo
- echo "paths = [ \"$SUBSTRATE_PATH\" ]" > target/debug/wbuild/.cargo/config
# package, others are updated along the way.
- cargo update
# Check whether Polkadot 'master' branch builds with this Substrate commit.
- time cargo check
- cd -
- sccache -s

trigger-contracts-ci:
stage: publish
Expand Down
81 changes: 81 additions & 0 deletions .maintain/gitlab/check_polkadot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/sh
#
# check if a pr is compatible with polkadot companion pr or master if not
# available
#
# mark companion pr in the body of the polkadot pr like
#
# polkadot companion: paritytech/polkadot#567


github_api_substrate_pull_url="https://api.github.com/repos/paritytech/substrate/pulls"
# use github api v3 in order to access the data without authentication
github_header="Accept: application/vnd.github.v3+json"

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" ; }



boldcat <<-EOT


check_polkadot
==============

this job checks if there is a string in the description of the pr like

polkadot companion: paritytech/polkadot#567


it will then run cargo check from this polkadot's branch with substrate code
from this pull request.


EOT



SUBSTRATE_PATH=$(pwd)

# Clone the current Polkadot master branch into ./polkadot.
git clone --depth 1 https://github.com/paritytech/polkadot.git

cd polkadot

# either it's a pull request then check for a companion otherwise use
# polkadot:master
if expr match "${CI_COMMIT_REF_NAME}" '^[0-9]\+$' >/dev/null
then
boldprint "this is pull request no ${CI_COMMIT_REF_NAME}"
# get the last reference to a pr in polkadot
comppr="$(curl -H "${github_header}" -s ${github_api_substrate_pull_url}/${CI_COMMIT_REF_NAME} \
| sed -n -r 's;^[[:space:]]+"body":[[:space:]]+".*polkadot companion: paritytech/polkadot#([0-9]+).*"[^"]+$;\1;p;$!d')"
if [ "${comppr}" ]
then
boldprint "companion pr specified: #${comppr}"
git fetch --depth 1 origin refs/pull/${comppr}/head:pr/${comppr}
git checkout pr/${comppr}
else
boldprint "no companion pr declared - building polkadot:master"
fi
else
boldprint "this is not a pull request - building polkadot master"
fi

# Make sure we override the crates in native and wasm build
mkdir .cargo
# echo "paths = [ \"$SUBSTRATE_PATH\" ]" > .cargo/config
# see https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html
echo "[patch.\"https://github.com/paritytech/substrate\"]\nsubstrate = { path = \"$SUBSTRATE_PATH\" }" > .cargo/config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand, can you pls explain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ci pipeline is completely green for this branch: https://gitlab.parity.io/parity/substrate/pipelines/84173
(i just pushed a tag along with it before and that's why there are tag jobs that failed)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a test commit changing a function that is used in Polkadot and the job executed successfully. This shows that this is not working.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is not too time consuming for you, would you mind explaining why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you want to "patch" a crate, you need to list it. But you are only listing the substrate crate, which is the name of the substrate node. This crate is not even used by Polkadot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks, code updated resp reverted.


mkdir -p target/debug/wbuild/.cargo
cp .cargo/config target/debug/wbuild/.cargo/config

# package, others are updated along the way.
cargo update

# Test Polkadot pr or master branch with this Substrate commit.
time cargo test --all --release --verbose