-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[CI] Add cumulus + beefy companions #9010
Changes from 7 commits
bff60a7
deaeab7
21c3d80
98030be
4b68a08
5f05ce8
07747bc
00a925b
3b90256
cd97118
98f83ce
a9427dd
359820c
3002789
8c5363d
dc8d301
c90db6c
7df4a60
1b8c9d8
8181635
c476a9d
f5f920d
46988ba
c96f997
a7ee4a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| #!/usr/bin/env sh | ||
| # | ||
| # check if a pr is compatible with companion pr or master if not available | ||
| # | ||
| # to override one that was just mentioned mark companion pr in the body of the | ||
| # pr like | ||
| # | ||
| # $REPO companion: $ORGANISATION/$REPO#567 | ||
| # | ||
| # $ORGANISATION and $REPO are set using $1 and $2. You can also specify a custom | ||
| # build command with $3 | ||
| # So invoke this script like: | ||
| # ./check_companion_build.sh paritytech polkadot 'cargo test --release' | ||
|
|
||
| set -e | ||
|
|
||
| ORGANISATION=$1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Apparently "Organisation" is valid spelling in British English but IMO it'd look better ORGANIZATION |
||
| REPO=$2 | ||
| BUILDSTRING=${3:-cargo test --all --release} | ||
|
TriplEight marked this conversation as resolved.
Outdated
|
||
|
|
||
| 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="Authorization: token ${GITHUB_PR_TOKEN}" | ||
|
|
||
| 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 <<-EOT | ||
|
|
||
|
|
||
| check_${REPO}_companion_build | ||
| ============================== | ||
|
|
||
| this job checks if there is a string in the description of the pr like | ||
|
|
||
| $REPO companion: $ORGANISATION/$REPO#567 | ||
|
|
||
|
|
||
| it will then run cargo check from this ${REPO}'s branch with substrate code | ||
| from this pull request. otherwise, it will uses master instead | ||
|
|
||
|
|
||
| EOT | ||
|
|
||
| # Set the user name and email to make merging work | ||
| git config --global user.name 'CI system' | ||
| git config --global user.email '<>' | ||
|
|
||
| # Merge master into our branch before building to make sure we don't miss | ||
| # any commits that are required. | ||
| git fetch --depth 100 origin | ||
| git merge origin/master | ||
|
Comment on lines
+63
to
+64
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can it just be |
||
|
|
||
| # Clone the current master branch into a local directory | ||
| # 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/${ORGANISATION}/${REPO}.git" | ||
|
|
||
| cd "$REPO" | ||
|
|
||
| # either it's a pull request then check for a companion otherwise use | ||
| # master | ||
| # shellcheck disable=SC2003 | ||
| 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 the target repo | ||
| curl -sSL -H "${github_header}" -o "${pr_data_file}" \ | ||
| "${github_api_substrate_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 \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Twice the companion merge was blocked due to isaacs/github#1681
Is it feasible to fail the check if the companion PR is coming from an organization repository? It's possible to query that using the Github API, e.g. https://api.github.com/users/paritytech will return Suggested message: cc @TriplEight
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, for sure let's add this warning with mentioning it's temporary until that bug is addressed. |
||
| -e "s;^.*[Cc]ompanion.*${ORGANISATION}/${REPO}#([0-9]+).*$;\1;p" \ | ||
| -e "s;^.*[Cc]ompanion.*https://github.com/${ORGANISATION}/${REPO}/pull/([0-9]+).*$;\1;p" \ | ||
| | tail -n 1)" | ||
|
|
||
| if [ "${pr_companion}" ] | ||
| then | ||
| boldprint "companion pr specified/detected: #${pr_companion}" | ||
| git fetch origin "refs/pull/${pr_companion}/head:pr/${pr_companion}" | ||
| git checkout "pr/${pr_companion}" | ||
| git merge origin/master | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be merging whatever branch the PR is currently targetting instead of master (although PRs usually target master). Perhaps it doesn't need to be handled at the moment, but a |
||
| else | ||
| boldprint "no companion branch found - building ${REPO}:master" | ||
| fi | ||
| rm -f "${pr_data_file}" | ||
| else | ||
| boldprint "this is not a pull request - building ${REPO}:master" | ||
| fi | ||
|
|
||
| # Patch all Substrate crates in the repo | ||
| diener patch --crates-to-patch ../ --substrate --path Cargo.toml | ||
|
s3krit marked this conversation as resolved.
Outdated
|
||
|
|
||
| # Test pr or master branch with this Substrate commit. | ||
| eval "$BUILDSTRING" | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.