Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bff60a7
add cumulus companions
s3krit Jun 3, 2021
deaeab7
remove references to any specific repo in check_companion_build.sh
s3krit Jun 3, 2021
21c3d80
naughty naughty very naughty (revert me)
s3krit Jun 3, 2021
98030be
add custom build string option
s3krit Jun 3, 2021
4b68a08
add beefy
s3krit Jun 3, 2021
5f05ce8
Revert "naughty naughty very naughty (revert me)"
s3krit Jun 3, 2021
07747bc
out with the old
s3krit Jun 3, 2021
00a925b
add anchors
s3krit Jun 7, 2021
3b90256
move check-companion-build to test stage
s3krit Jun 7, 2021
cd97118
ugh...
s3krit Jun 7, 2021
98f83ce
fix
s3krit Jun 7, 2021
a9427dd
Merge branch 'master' of https://github.com/paritytech/substrate into…
s3krit Jun 10, 2021
359820c
dynamically patch crates as needed
s3krit Jun 10, 2021
3002789
Merge branch 'master' into mp-cumulus-companions
s3krit Jun 28, 2021
8c5363d
Merge remote-tracking branch 'origin/master' into mp-cumulus-companions
s3krit Jun 28, 2021
dc8d301
fix reviews
s3krit Jun 28, 2021
c90db6c
first attempt at deeper dependencies
s3krit Jun 28, 2021
7df4a60
include lib.sh
s3krit Jun 28, 2021
1b8c9d8
Merge remote-tracking branch 'origin/master' into mp-cumulus-companions
s3krit Jun 28, 2021
8181635
patch things correctly
s3krit Jun 28, 2021
c476a9d
improve comments, test something neat
s3krit Jun 28, 2021
f5f920d
Apply suggestions from code review
s3krit Jun 29, 2021
46988ba
update comments
s3krit Jun 29, 2021
c96f997
Merge branch 'master' into mp-cumulus-companions
s3krit Aug 6, 2021
a7ee4a3
use jq for parsing PRs
s3krit Aug 6, 2021
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
32 changes: 29 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ node-bench-regression-guard:
CI_IMAGE: "paritytech/node-bench-regression-guard:latest"
before_script: [""]
script:
- 'node-bench-regression-guard --reference artifacts/benches/master-*
- 'node-bench-regression-guard --reference artifacts/benches/master-*
--compare-with artifacts/benches/$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA'

cargo-check-subkey:
Expand Down Expand Up @@ -435,11 +435,37 @@ check-polkadot-companion-build:
- job: test-linux-stable-int
artifacts: false
script:
- ./.maintain/gitlab/check_polkadot_companion_build.sh
- ./.maintain/gitlab/check_companion_build.sh paritytech polkadot
after_script:
- cd polkadot && git rev-parse --abbrev-ref HEAD
allow_failure: true

check-cumulus-companion-build:
Comment thread
s3krit marked this conversation as resolved.
stage: build
<<: *docker-env
<<: *test-refs-no-trigger
needs:
- job: test-linux-stable-int
Comment thread
TriplEight marked this conversation as resolved.
Outdated
artifacts: false
script:
- ./.maintain/gitlab/check_companion_build.sh paritytech cumulus 'cargo check'
after_script:
- cd cumulus && git rev-parse --abbrev-ref HEAD
allow_failure: true
Comment thread
s3krit marked this conversation as resolved.
Outdated

check-beefy-companion-build:
stage: build
<<: *docker-env
<<: *test-refs-no-trigger
needs:
- job: test-linux-stable-int
Comment thread
s3krit marked this conversation as resolved.
Outdated
artifacts: false
script:
- ./.maintain/gitlab/check_companion_build.sh paritytech grandpa-bridge-gadget 'cargo check'
after_script:
- cd grandpa-bridge-gadget && git rev-parse --abbrev-ref HEAD
allow_failure: true
Comment thread
s3krit marked this conversation as resolved.
Outdated

test-browser-node:
stage: build
<<: *docker-env
Expand Down Expand Up @@ -699,7 +725,7 @@ trigger-simnet:
- if: $CI_COMMIT_REF_NAME == "master"
needs:
- job: publish-docker-substrate
# `build.env` brings here `$IMAGE_NAME` and `$IMAGE_TAG` (`$VERSION` here,
# `build.env` brings here `$IMAGE_NAME` and `$IMAGE_TAG` (`$VERSION` here,
# i.e. `2643-0.8.29-5f689e0a-6b24dc54`).
variables:
TRGR_PROJECT: ${CI_PROJECT_NAME}
Expand Down
100 changes: 100 additions & 0 deletions .maintain/gitlab/check_companion_build.sh
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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}
Comment thread
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can it just be git pull origin master? I don't quite get the depth numbers but fetching a single branch is better than doing fetch origin (which fetches everything)


# 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 \

@joao-paulo-parity joao-paulo-parity Jun 8, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 "type": "Organization"

Suggested message: Heads-up: You've opened the companion PR from an organization repository; bear in mind "bot merge" will not also merge the companion simultaneously due to a Github limitation (link).

cc @TriplEight

Context

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 FIXME note about this detail would be welcome.

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
Comment thread
s3krit marked this conversation as resolved.
Outdated

# Test pr or master branch with this Substrate commit.
eval "$BUILDSTRING"
92 changes: 0 additions & 92 deletions .maintain/gitlab/check_polkadot_companion_build.sh

This file was deleted.