From bff60a704a7cd65e9b315d63ab3bfd0caa318613 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Thu, 3 Jun 2021 14:13:18 +0200 Subject: [PATCH 01/20] add cumulus companions --- .gitlab-ci.yml | 19 ++++- .maintain/gitlab/check_companion_build.sh | 99 +++++++++++++++++++++++ 2 files changed, 115 insertions(+), 3 deletions(-) create mode 100755 .maintain/gitlab/check_companion_build.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 03fe9f8a2dcab..bce582cec20d9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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: @@ -435,11 +435,24 @@ 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: + stage: build + <<: *docker-env + <<: *test-refs-no-trigger + needs: + - job: test-linux-stable-int + artifacts: false + script: + - ./.maintain/gitlab/check_companion_build.sh paritytech cumulus + after_script: + - cd cumulus && git rev-parse --abbrev-ref HEAD + allow_failure: true + test-browser-node: stage: build <<: *docker-env @@ -699,7 +712,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} diff --git a/.maintain/gitlab/check_companion_build.sh b/.maintain/gitlab/check_companion_build.sh new file mode 100755 index 0000000000000..213a23d10cf6a --- /dev/null +++ b/.maintain/gitlab/check_companion_build.sh @@ -0,0 +1,99 @@ +#!/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 +# So invoke this script like: +# ./check_companion_build.sh paritytech polkadot + +set -e + +ORGANISATION=$1 +REPO=$2 + + +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 cumulus'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 Cumulus to make sure we don't miss +# any commits that are required by Cumulus. +git fetch --depth 100 origin +git merge origin/master + +# Clone the current Cumulus master branch into ./cumulus. +# 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 cumulus + 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 \ + -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 + else + boldprint "no companion branch found - building cumulus:master" + fi + rm -f "${pr_data_file}" +else + boldprint "this is not a pull request - building cumulus:master" +fi + +# Patch all Substrate crates in Cumulus +diener patch --crates-to-patch ../ --substrate --path Cargo.toml + +# Test Cumulus pr or master branch with this Substrate commit. +time cargo test --all --release --verbose From deaeab792a5382572f9293e7174ab0d8202f4a52 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Thu, 3 Jun 2021 14:16:37 +0200 Subject: [PATCH 02/20] remove references to any specific repo in check_companion_build.sh --- .maintain/gitlab/check_companion_build.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.maintain/gitlab/check_companion_build.sh b/.maintain/gitlab/check_companion_build.sh index 213a23d10cf6a..16adcc52f762b 100755 --- a/.maintain/gitlab/check_companion_build.sh +++ b/.maintain/gitlab/check_companion_build.sh @@ -37,7 +37,7 @@ 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 cumulus's branch with substrate code +it will then run cargo check from this ${REPO}'s branch with substrate code from this pull request. otherwise, it will uses master instead @@ -47,12 +47,12 @@ EOT git config --global user.name 'CI system' git config --global user.email '<>' -# Merge master into our branch before building Cumulus to make sure we don't miss -# any commits that are required by Cumulus. +# 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 -# Clone the current Cumulus master branch into ./cumulus. +# 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" @@ -67,7 +67,7 @@ then boldprint "this is pull request no ${CI_COMMIT_REF_NAME}" pr_data_file="$(mktemp)" - # get the last reference to a pr in cumulus + # 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}" @@ -85,15 +85,15 @@ then git checkout pr/${pr_companion} git merge origin/master else - boldprint "no companion branch found - building cumulus:master" + boldprint "no companion branch found - building ${REPO}:master" fi rm -f "${pr_data_file}" else - boldprint "this is not a pull request - building cumulus:master" + boldprint "this is not a pull request - building ${REPO}:master" fi -# Patch all Substrate crates in Cumulus +# Patch all Substrate crates in the repo diener patch --crates-to-patch ../ --substrate --path Cargo.toml -# Test Cumulus pr or master branch with this Substrate commit. +# Test pr or master branch with this Substrate commit. time cargo test --all --release --verbose From 21c3d80d491a0dfd46df81f37c10d55c30665c93 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Thu, 3 Jun 2021 14:24:25 +0200 Subject: [PATCH 03/20] naughty naughty very naughty (revert me) --- .gitlab-ci.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bce582cec20d9..56dad24098f79 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -140,17 +140,17 @@ default: #### stage: .pre -skip-if-draft: - image: paritytech/tools:latest - <<: *kubernetes-env - stage: .pre - rules: - - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs - script: - - echo "Commit message is ${CI_COMMIT_MESSAGE}" - - echo "Ref is ${CI_COMMIT_REF_NAME}" - - echo "pipeline source is ${CI_PIPELINE_SOURCE}" - - ./.maintain/gitlab/skip_if_draft.sh +# skip-if-draft: + # image: paritytech/tools:latest + # <<: *kubernetes-env + # stage: .pre + # rules: + # - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs + # script: + # - echo "Commit message is ${CI_COMMIT_MESSAGE}" + # - echo "Ref is ${CI_COMMIT_REF_NAME}" + # - echo "pipeline source is ${CI_PIPELINE_SOURCE}" + # - ./.maintain/gitlab/skip_if_draft.sh #### stage: check From 98030bee8da7fca506498e58cd1efb4aa71d6647 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Thu, 3 Jun 2021 14:33:44 +0200 Subject: [PATCH 04/20] add custom build string option --- .gitlab-ci.yml | 2 +- .maintain/gitlab/check_companion_build.sh | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 56dad24098f79..10660027804a5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -448,7 +448,7 @@ check-cumulus-companion-build: - job: test-linux-stable-int artifacts: false script: - - ./.maintain/gitlab/check_companion_build.sh paritytech cumulus + - ./.maintain/gitlab/check_companion_build.sh paritytech cumulus 'cargo check' after_script: - cd cumulus && git rev-parse --abbrev-ref HEAD allow_failure: true diff --git a/.maintain/gitlab/check_companion_build.sh b/.maintain/gitlab/check_companion_build.sh index 16adcc52f762b..7f53bba7edebe 100755 --- a/.maintain/gitlab/check_companion_build.sh +++ b/.maintain/gitlab/check_companion_build.sh @@ -7,15 +7,16 @@ # # $REPO companion: $ORGANISATION/$REPO#567 # -# $ORGANISATION and $REPO are set using $1 and $2 +# $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 +# ./check_companion_build.sh paritytech polkadot 'cargo test --release' set -e ORGANISATION=$1 REPO=$2 - +BUILDSTRING=${3:-cargo test --all --release} 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 @@ -81,8 +82,8 @@ then 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 fetch origin "refs/pull/${pr_companion}/head:pr/${pr_companion}" + git checkout "pr/${pr_companion}" git merge origin/master else boldprint "no companion branch found - building ${REPO}:master" @@ -96,4 +97,4 @@ fi diener patch --crates-to-patch ../ --substrate --path Cargo.toml # Test pr or master branch with this Substrate commit. -time cargo test --all --release --verbose +time eval "$BUILDSTRING" From 4b68a086cef9dab42eacaac3e0a9c727d697999f Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Thu, 3 Jun 2021 16:33:25 +0200 Subject: [PATCH 05/20] add beefy --- .gitlab-ci.yml | 13 +++++++++++++ .maintain/gitlab/check_companion_build.sh | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 10660027804a5..242d032890885 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -453,6 +453,19 @@ check-cumulus-companion-build: - cd cumulus && git rev-parse --abbrev-ref HEAD allow_failure: true +check-beefy-companion-build: + stage: build + <<: *docker-env + <<: *test-refs-no-trigger + needs: + - job: test-linux-stable-int + 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 + test-browser-node: stage: build <<: *docker-env diff --git a/.maintain/gitlab/check_companion_build.sh b/.maintain/gitlab/check_companion_build.sh index 7f53bba7edebe..b3839e842f39b 100755 --- a/.maintain/gitlab/check_companion_build.sh +++ b/.maintain/gitlab/check_companion_build.sh @@ -97,4 +97,4 @@ fi diener patch --crates-to-patch ../ --substrate --path Cargo.toml # Test pr or master branch with this Substrate commit. -time eval "$BUILDSTRING" +eval "$BUILDSTRING" From 5f05ce876ca9ab882a00a6a49449135d71d1e974 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Thu, 3 Jun 2021 18:36:56 +0200 Subject: [PATCH 06/20] Revert "naughty naughty very naughty (revert me)" This reverts commit 6fb44bb66d7a585416eb552032987e697a0d60bd. --- .gitlab-ci.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 242d032890885..3b4560df4b4d4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -140,17 +140,17 @@ default: #### stage: .pre -# skip-if-draft: - # image: paritytech/tools:latest - # <<: *kubernetes-env - # stage: .pre - # rules: - # - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs - # script: - # - echo "Commit message is ${CI_COMMIT_MESSAGE}" - # - echo "Ref is ${CI_COMMIT_REF_NAME}" - # - echo "pipeline source is ${CI_PIPELINE_SOURCE}" - # - ./.maintain/gitlab/skip_if_draft.sh +skip-if-draft: + image: paritytech/tools:latest + <<: *kubernetes-env + stage: .pre + rules: + - if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs + script: + - echo "Commit message is ${CI_COMMIT_MESSAGE}" + - echo "Ref is ${CI_COMMIT_REF_NAME}" + - echo "pipeline source is ${CI_PIPELINE_SOURCE}" + - ./.maintain/gitlab/skip_if_draft.sh #### stage: check From 07747bcb7f53bbf3073e868dc517609bf8743995 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Thu, 3 Jun 2021 18:50:22 +0200 Subject: [PATCH 07/20] out with the old --- .../gitlab/check_polkadot_companion_build.sh | 92 ------------------- 1 file changed, 92 deletions(-) delete mode 100755 .maintain/gitlab/check_polkadot_companion_build.sh diff --git a/.maintain/gitlab/check_polkadot_companion_build.sh b/.maintain/gitlab/check_polkadot_companion_build.sh deleted file mode 100755 index 89780f082e45b..0000000000000 --- a/.maintain/gitlab/check_polkadot_companion_build.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env sh -# -# check if a pr is compatible with polkadot companion pr or master if not -# available -# -# to override one that was just mentioned mark companion pr in the body of the -# polkadot pr like -# -# polkadot companion: paritytech/polkadot#567 -# - -set -e - -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${@}\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_companion_build -============================== - -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. 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 Polkadot to make sure we don't miss -# any commits that are required by Polkadot. -git fetch --depth 100 origin -git merge origin/master - -# Clone the current Polkadot master branch into ./polkadot. -# 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/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}" - - pr_data_file="$(mktemp)" - # get the last reference to a pr in polkadot - 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 \ - -e 's;^.*[Cc]ompanion.*paritytech/polkadot#([0-9]+).*$;\1;p' \ - -e 's;^.*[Cc]ompanion.*https://github.com/paritytech/polkadot/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 - else - boldprint "no companion branch found - building polkadot:master" - fi - rm -f "${pr_data_file}" -else - boldprint "this is not a pull request - building polkadot:master" -fi - -# Patch all Substrate crates in Polkadot -diener patch --crates-to-patch ../ --substrate --path Cargo.toml - -# Test Polkadot pr or master branch with this Substrate commit. -time cargo test --all --release --verbose From 00a925b2e2fba1f54bf1e5f422254219d7392011 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Mon, 7 Jun 2021 14:30:19 +0200 Subject: [PATCH 08/20] add anchors --- .gitlab-ci.yml | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3b4560df4b4d4..7f7146c269aff 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -427,7 +427,7 @@ check-polkadot-companion-status: script: - ./.maintain/gitlab/check_polkadot_companion_status.sh -check-polkadot-companion-build: +.check-companion-build: &check-companion-build stage: build <<: *docker-env <<: *test-refs-no-trigger @@ -435,23 +435,25 @@ check-polkadot-companion-build: - job: test-linux-stable-int artifacts: false script: - - ./.maintain/gitlab/check_companion_build.sh paritytech polkadot + - ./.maintain/gitlab/check_companion_build.sh "$COMPANION_ORG" "$COMPANION_REPO" "$COMPANION_BUILD" after_script: - - cd polkadot && git rev-parse --abbrev-ref HEAD + - cd "$COMPANION_REPO" && git rev-parse --abbrev-ref HEAD allow_failure: true +check-polkadot-companion-build: + <<: *check-companion-build + variables: + COMPANION_ORG: paritytech + COMPANION_REPO: polkadot + allow_failure: true + check-cumulus-companion-build: - stage: build - <<: *docker-env - <<: *test-refs-no-trigger - needs: - - job: test-linux-stable-int - 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 + <<: *check-companion-build + variables: + COMPANION_ORG: paritytech + COMPANION_REPO: cumulus + COMPANION_BUILD: "cargo check" + allow_failure: true check-beefy-companion-build: stage: build From 3b902567d718c483b8ebc36dbe75bd6e0bffd608 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Mon, 7 Jun 2021 15:11:03 +0200 Subject: [PATCH 09/20] move check-companion-build to test stage --- .gitlab-ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7f7146c269aff..6ad3139d63d52 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -428,12 +428,9 @@ check-polkadot-companion-status: - ./.maintain/gitlab/check_polkadot_companion_status.sh .check-companion-build: &check-companion-build - stage: build + stage: test <<: *docker-env <<: *test-refs-no-trigger - needs: - - job: test-linux-stable-int - artifacts: false script: - ./.maintain/gitlab/check_companion_build.sh "$COMPANION_ORG" "$COMPANION_REPO" "$COMPANION_BUILD" after_script: From cd971183241eecd8e571a776e866c65d3de1bd26 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Mon, 7 Jun 2021 16:01:26 +0200 Subject: [PATCH 10/20] ugh... --- .gitlab-ci.yml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6ad3139d63d52..1386e5fc23720 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -453,17 +453,12 @@ check-cumulus-companion-build: allow_failure: true check-beefy-companion-build: - stage: build - <<: *docker-env - <<: *test-refs-no-trigger - needs: - - job: test-linux-stable-int - 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 + <<: *check-companion-build + variables: + COMPANION_ORG: paritytech + COMPANION_REPO: beefy + COMPANION_BUILD: "cargo check" + allow_failure: true test-browser-node: stage: build From 98f83ce929101f504a0ebfb21b953c6aa371f524 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Mon, 7 Jun 2021 16:37:31 +0200 Subject: [PATCH 11/20] fix --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1386e5fc23720..d9335d524f8fa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -456,7 +456,7 @@ check-beefy-companion-build: <<: *check-companion-build variables: COMPANION_ORG: paritytech - COMPANION_REPO: beefy + COMPANION_REPO: grandpa-bridge-gadget COMPANION_BUILD: "cargo check" allow_failure: true From 359820c789fec2ae9a7aef41464e9798748a1049 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Thu, 10 Jun 2021 14:41:23 +0200 Subject: [PATCH 12/20] dynamically patch crates as needed --- .maintain/gitlab/check_companion_build.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.maintain/gitlab/check_companion_build.sh b/.maintain/gitlab/check_companion_build.sh index b3839e842f39b..2fdafaeed9329 100755 --- a/.maintain/gitlab/check_companion_build.sh +++ b/.maintain/gitlab/check_companion_build.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash # # check if a pr is compatible with companion pr or master if not available # @@ -93,8 +93,23 @@ 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 +# Patch polkadot, substrate or beefy deps as required +declare -A match_arg +match_arg=() +match_arg["--substrate"]='source = "git+https://github.com/paritytech/substrate?' +match_arg["--polkadot"]='source = "git+https://github.com/paritytech/polkadot?' +match_arg["--beefy"]='source = "git+https://github.com/paritytech/parity-bridges-gadget?' + +# For each Cargo.lock +while IFS= read -r cargo_lock; do + # If the Cargo.lock has a dependency, we patch with diener + for patch_arg in "${!match_arg[@]}"; do + if grep -q "${match_arg[$patch_arg]}" "$cargo_lock" ; then + echo "patching $patch_arg" + diener patch --crates-to-patch ../ "$patch_arg" --path Cargo.toml + fi + done +done < <(find . -name Cargo.lock) # Test pr or master branch with this Substrate commit. eval "$BUILDSTRING" From dc8d30188e0779c31f564a594b0fef2dbf70ba5f Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Mon, 28 Jun 2021 14:06:11 +0200 Subject: [PATCH 13/20] fix reviews --- .gitlab-ci.yml | 2 +- .maintain/gitlab/check_companion_build.sh | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 47e8582f5ca40..4e814eb4bf49e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -588,7 +588,7 @@ build-rust-doc: - buildah push --format=v2s2 "$IMAGE_NAME:latest" after_script: - buildah logout "$IMAGE_NAME" - # pass artifacts to the trigger-simnet job + # pass artifacts to the trigger-simnet job - echo "IMAGE_NAME=${IMAGE_NAME}" | tee -a ./artifacts/$PRODUCT/build.env - IMAGE_TAG="$(cat ./artifacts/$PRODUCT/VERSION)" - echo "IMAGE_TAG=${IMAGE_TAG}" | tee -a ./artifacts/$PRODUCT/build.env diff --git a/.maintain/gitlab/check_companion_build.sh b/.maintain/gitlab/check_companion_build.sh index 2fdafaeed9329..e4854f77bb1b4 100755 --- a/.maintain/gitlab/check_companion_build.sh +++ b/.maintain/gitlab/check_companion_build.sh @@ -16,7 +16,7 @@ set -e ORGANISATION=$1 REPO=$2 -BUILDSTRING=${3:-cargo test --all --release} +BUILDSTRING=${3:-cargo test --workspace --release} 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 @@ -100,16 +100,24 @@ match_arg["--substrate"]='source = "git+https://github.com/paritytech/substrate? match_arg["--polkadot"]='source = "git+https://github.com/paritytech/polkadot?' match_arg["--beefy"]='source = "git+https://github.com/paritytech/parity-bridges-gadget?' +declare -A patch_args +patch_args=() + # For each Cargo.lock while IFS= read -r cargo_lock; do # If the Cargo.lock has a dependency, we patch with diener for patch_arg in "${!match_arg[@]}"; do if grep -q "${match_arg[$patch_arg]}" "$cargo_lock" ; then + echo "marking $patch_arg as patchable" + patch_args["$patch_arg"]='true' echo "patching $patch_arg" - diener patch --crates-to-patch ../ "$patch_arg" --path Cargo.toml fi done done < <(find . -name Cargo.lock) +for patch_arg in "${!patch_args[@]}"; do + diener patch --crates-to-patch ../ "$patch_arg" --path Cargo.toml +done + # Test pr or master branch with this Substrate commit. eval "$BUILDSTRING" From c90db6c3ee9a52a12c42552ff66f134e815054e0 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Mon, 28 Jun 2021 14:54:08 +0200 Subject: [PATCH 14/20] first attempt at deeper dependencies --- .gitlab-ci.yml | 2 + .maintain/common/lib.sh | 21 ++++++++++ .maintain/gitlab/check_companion_build.sh | 49 +++++++++++++---------- 3 files changed, 51 insertions(+), 21 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4e814eb4bf49e..4cefaf5549d5d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -451,6 +451,8 @@ check-cumulus-companion-build: COMPANION_ORG: paritytech COMPANION_REPO: cumulus COMPANION_BUILD: "cargo check" + script: + - ./.maintain/gitlab/check_companion_build.sh "$COMPANION_ORG" "$COMPANION_REPO" "$COMPANION_BUILD" paritytech/polkadot allow_failure: true check-beefy-companion-build: diff --git a/.maintain/common/lib.sh b/.maintain/common/lib.sh index ce6c566d799ab..64e420aaea163 100755 --- a/.maintain/common/lib.sh +++ b/.maintain/common/lib.sh @@ -115,3 +115,24 @@ has_runtime_changes() { return 1 fi } + +# Given an origin repo & PR,and a repository, will check if the given PR has a +# companion PR in the target repo +get_companion() { + origin_repo="$1" + pr_num="$2" + companion_repo="$3" + github_header="Authorization: token ${GITHUB_PR_TOKEN}" + pr_data_file="$(mktemp)" + # get the last reference to a pr in the target repo + curl -sSL -H "${github_header}" -o "${pr_data_file}" \ + "${api_base}/$origin_repo/pulls/$pr_num" + + pr_body="$(sed -n -r 's/^[[:space:]]+"body": (".*")[^"]+$/\1/p' "${pr_data_file}")" + + echo "${pr_body}" | sed -n -r \ + -e "s;^.*[Cc]ompanion.*$companion_repo#([0-9]+).*$;\1;p" \ + -e "s;^.*[Cc]ompanion.*https://github.com/$companion_repo/pull/([0-9]+).*$;\1;p" \ + | tail -n 1 + rm -f "${pr_data_file}" +} diff --git a/.maintain/gitlab/check_companion_build.sh b/.maintain/gitlab/check_companion_build.sh index e4854f77bb1b4..7fae65c817d3d 100755 --- a/.maintain/gitlab/check_companion_build.sh +++ b/.maintain/gitlab/check_companion_build.sh @@ -17,16 +17,11 @@ set -e ORGANISATION=$1 REPO=$2 BUILDSTRING=${3:-cargo test --workspace --release} - -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}" +DEPS=("${@:4}") 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 @@ -66,20 +61,8 @@ cd "$REPO" 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 \ - -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}" ] + pr_companion="$(get_companion "paritytech/substrate" "$CI_COMMIT_REF_NAME" "$ORGANISATION/$REPO")" + if [ "$pr_companion" ] then boldprint "companion pr specified/detected: #${pr_companion}" git fetch origin "refs/pull/${pr_companion}/head:pr/${pr_companion}" @@ -88,11 +71,34 @@ then else boldprint "no companion branch found - building ${REPO}:master" fi - rm -f "${pr_data_file}" + + # If this repo has any additional dependencies, we should check whether they + # are mentioned as companions as well, and patch to use that if so + # Note: Will only work with repos supported by diener + declare -A diener_commands + diener_commands=() + diener_commands["paritytech/polkadot"]='--polkadot' + diener_commands["paritytech/substrate"]='--substrate' + diener_commands["paritytech/grandpa-bridge-gadget"]='--beefy' + + for dep in "${DEPS[@]}"; do + dep_companion="$(get_companion "paritytech/substrate" "$CI_COMMIT_REF_NAME" "$dep")" + if [ "$dep_companion" ]; then + echo "Companion PR found for $dep, need to patch $REPO to use that" + git clone --depth 20 "https://github.com/$dep.git" "$dep" + git -C "$dep" fetch origin "refs/pull/${dep_companion}/head:pr/${dep_companion}" + git -C "$dep" checkout "pr/${dep_companion}" + git -C "$dep" merge origin/master + diener patch --crates-to-patch "$dep" "${diener_commands[$dep]}" --path "Cargo.toml" + fi + + done + else boldprint "this is not a pull request - building ${REPO}:master" fi + # Patch polkadot, substrate or beefy deps as required declare -A match_arg match_arg=() @@ -116,6 +122,7 @@ while IFS= read -r cargo_lock; do done < <(find . -name Cargo.lock) for patch_arg in "${!patch_args[@]}"; do + echo "patching $patch_arg" diener patch --crates-to-patch ../ "$patch_arg" --path Cargo.toml done From 7df4a60674044bbf8f093cb913c8f153d1eec452 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Mon, 28 Jun 2021 15:55:08 +0200 Subject: [PATCH 15/20] include lib.sh --- .maintain/gitlab/check_companion_build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.maintain/gitlab/check_companion_build.sh b/.maintain/gitlab/check_companion_build.sh index 7fae65c817d3d..f1e3a38414b5a 100755 --- a/.maintain/gitlab/check_companion_build.sh +++ b/.maintain/gitlab/check_companion_build.sh @@ -14,6 +14,10 @@ set -e +# Include the common functions library +#shellcheck source=../common/lib.sh +. "$(dirname "${0}")/../common/lib.sh" + ORGANISATION=$1 REPO=$2 BUILDSTRING=${3:-cargo test --workspace --release} From 8181635d2e4c08f47256cc63231b0b9076194fe0 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Mon, 28 Jun 2021 17:50:56 +0200 Subject: [PATCH 16/20] patch things correctly --- .maintain/common/lib.sh | 25 ++++++++++------- .maintain/gitlab/check_companion_build.sh | 33 ++++------------------- 2 files changed, 20 insertions(+), 38 deletions(-) diff --git a/.maintain/common/lib.sh b/.maintain/common/lib.sh index 64e420aaea163..26f783fb51877 100755 --- a/.maintain/common/lib.sh +++ b/.maintain/common/lib.sh @@ -2,6 +2,18 @@ api_base="https://api.github.com/repos" + +set_github_token(){ + # These will exist if the function is called in Gitlab. + # If the function's called in Github, we should have GITHUB_ACCESS_TOKEN set + # already. + if [ -n "$GITHUB_RELEASE_TOKEN" ]; then + GITHUB_TOKEN="$GITHUB_RELEASE_TOKEN" + elif [ -n "$GITHUB_PR_TOKEN" ]; then + GITHUB_TOKEN="$GITHUB_PR_TOKEN" + fi +} + # Function to take 2 git tags/commits and get any lines from commit messages # that contain something that looks like a PR reference: e.g., (#1234) sanitised_git_logs(){ @@ -66,15 +78,7 @@ has_label(){ repo="$1" pr_id="$2" label="$3" - - # These will exist if the function is called in Gitlab. - # If the function's called in Github, we should have GITHUB_ACCESS_TOKEN set - # already. - if [ -n "$GITHUB_RELEASE_TOKEN" ]; then - GITHUB_TOKEN="$GITHUB_RELEASE_TOKEN" - elif [ -n "$GITHUB_PR_TOKEN" ]; then - GITHUB_TOKEN="$GITHUB_PR_TOKEN" - fi + set_github_token out=$(curl -H "Authorization: token $GITHUB_TOKEN" -s "$api_base/$repo/pulls/$pr_id") [ -n "$(echo "$out" | tr -d '\r\n' | jq ".labels | .[] | select(.name==\"$label\")")" ] @@ -122,8 +126,9 @@ get_companion() { origin_repo="$1" pr_num="$2" companion_repo="$3" - github_header="Authorization: token ${GITHUB_PR_TOKEN}" pr_data_file="$(mktemp)" + set_github_token + github_header="Authorization: token ${GITHUB_TOKEN}" # get the last reference to a pr in the target repo curl -sSL -H "${github_header}" -o "${pr_data_file}" \ "${api_base}/$origin_repo/pulls/$pr_num" diff --git a/.maintain/gitlab/check_companion_build.sh b/.maintain/gitlab/check_companion_build.sh index f1e3a38414b5a..9bfb03d10feef 100755 --- a/.maintain/gitlab/check_companion_build.sh +++ b/.maintain/gitlab/check_companion_build.sh @@ -22,6 +22,7 @@ ORGANISATION=$1 REPO=$2 BUILDSTRING=${3:-cargo test --workspace --release} DEPS=("${@:4}") +SUBSTRATE_DIR="$(pwd)" 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" ; } @@ -94,6 +95,9 @@ then git -C "$dep" checkout "pr/${dep_companion}" git -C "$dep" merge origin/master diener patch --crates-to-patch "$dep" "${diener_commands[$dep]}" --path "Cargo.toml" + # then tell this version of the dependency to use this version of substrate + # bit hacky at the moment since it assums any dependency will also depend on substrate + diener patch --crates-to-patch "$SUBSTRATE_DIR" --substrate --path "$dep/Cargo.toml" fi done @@ -102,33 +106,6 @@ else boldprint "this is not a pull request - building ${REPO}:master" fi - -# Patch polkadot, substrate or beefy deps as required -declare -A match_arg -match_arg=() -match_arg["--substrate"]='source = "git+https://github.com/paritytech/substrate?' -match_arg["--polkadot"]='source = "git+https://github.com/paritytech/polkadot?' -match_arg["--beefy"]='source = "git+https://github.com/paritytech/parity-bridges-gadget?' - -declare -A patch_args -patch_args=() - -# For each Cargo.lock -while IFS= read -r cargo_lock; do - # If the Cargo.lock has a dependency, we patch with diener - for patch_arg in "${!match_arg[@]}"; do - if grep -q "${match_arg[$patch_arg]}" "$cargo_lock" ; then - echo "marking $patch_arg as patchable" - patch_args["$patch_arg"]='true' - echo "patching $patch_arg" - fi - done -done < <(find . -name Cargo.lock) - -for patch_arg in "${!patch_args[@]}"; do - echo "patching $patch_arg" - diener patch --crates-to-patch ../ "$patch_arg" --path Cargo.toml -done - +diener patch --crates-to-patch ".." --substrate --path "Cargo.toml" # Test pr or master branch with this Substrate commit. eval "$BUILDSTRING" From c476a9d78703f5937fd3162e604575dfee35f304 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Mon, 28 Jun 2021 18:14:08 +0200 Subject: [PATCH 17/20] improve comments, test something neat --- .gitlab-ci.yml | 6 +++--- .maintain/gitlab/check_companion_build.sh | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4cefaf5549d5d..d6500c0b058f8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -433,7 +433,7 @@ check-polkadot-companion-status: <<: *docker-env <<: *test-refs-no-trigger script: - - ./.maintain/gitlab/check_companion_build.sh "$COMPANION_ORG" "$COMPANION_REPO" "$COMPANION_BUILD" + - ./.maintain/gitlab/check_companion_build.sh "$COMPANION_ORG" "$COMPANION_REPO" "$COMPANION_BUILD" "$COMPANION_DEPENDENCY" after_script: - cd "$COMPANION_REPO" && git rev-parse --abbrev-ref HEAD allow_failure: true @@ -443,6 +443,7 @@ check-polkadot-companion-build: variables: COMPANION_ORG: paritytech COMPANION_REPO: polkadot + COMPANION_DEPENDENCY: paritytech/grandpa-bridge-gadget allow_failure: true check-cumulus-companion-build: @@ -451,8 +452,7 @@ check-cumulus-companion-build: COMPANION_ORG: paritytech COMPANION_REPO: cumulus COMPANION_BUILD: "cargo check" - script: - - ./.maintain/gitlab/check_companion_build.sh "$COMPANION_ORG" "$COMPANION_REPO" "$COMPANION_BUILD" paritytech/polkadot + COMPANION_DEPENDENCY: paritytech/polkadot allow_failure: true check-beefy-companion-build: diff --git a/.maintain/gitlab/check_companion_build.sh b/.maintain/gitlab/check_companion_build.sh index 9bfb03d10feef..7dd6192557be2 100755 --- a/.maintain/gitlab/check_companion_build.sh +++ b/.maintain/gitlab/check_companion_build.sh @@ -9,8 +9,18 @@ # # $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' +# The Every argument after $3 is for specifying *additional* dependencies this +# project has that depend on substrate, which might also have companion PRs. + +# Example: Cumulus relies on both substrate and polkadot. If this substrate PR +# requires a companion build on polkadot, when we are testing that cumulus builds +# with this commit of substrate, we *also* need to clone & patch polkadot, and tell +# cumulus to use this cloned+patched version, else the build is guaranteed to fail +# (since it doesn't have the changes to polkadot that were required in the polkadot +# companion PR) + +# So invoke this script like (arguments in [] indicate optional arguments) +# ./check_companion_build.sh paritytech cumulus ['cargo test --release'] [paritytech/polkadot] set -e From f5f920d3cee66dadae92dfe86b01ff2399f39e7e Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Tue, 29 Jun 2021 15:13:29 +0200 Subject: [PATCH 18/20] Apply suggestions from code review Co-authored-by: Denis Pisarev --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d6500c0b058f8..2e5ccf160d322 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -428,7 +428,7 @@ check-polkadot-companion-status: script: - ./.maintain/gitlab/check_polkadot_companion_status.sh -.check-companion-build: &check-companion-build +.check-companion-build: &check-companion-build stage: test <<: *docker-env <<: *test-refs-no-trigger From 46988ba96c1a9b8158a128921630d2a44265be97 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Tue, 29 Jun 2021 15:17:00 +0200 Subject: [PATCH 19/20] update comments --- .maintain/gitlab/check_companion_build.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.maintain/gitlab/check_companion_build.sh b/.maintain/gitlab/check_companion_build.sh index 7dd6192557be2..2d6a2f896e198 100755 --- a/.maintain/gitlab/check_companion_build.sh +++ b/.maintain/gitlab/check_companion_build.sh @@ -9,7 +9,7 @@ # # $ORGANISATION and $REPO are set using $1 and $2. You can also specify a custom # build command with $3 -# The Every argument after $3 is for specifying *additional* dependencies this +# Every argument after $3 is for specifying *additional* dependencies this # project has that depend on substrate, which might also have companion PRs. # Example: Cumulus relies on both substrate and polkadot. If this substrate PR @@ -88,7 +88,8 @@ then fi # If this repo has any additional dependencies, we should check whether they - # are mentioned as companions as well, and patch to use that if so + # are mentioned as companions as well. If they are, we patch this repo to + # use that companion build as well. See example at top of this script # Note: Will only work with repos supported by diener declare -A diener_commands diener_commands=() @@ -104,10 +105,10 @@ then git -C "$dep" fetch origin "refs/pull/${dep_companion}/head:pr/${dep_companion}" git -C "$dep" checkout "pr/${dep_companion}" git -C "$dep" merge origin/master - diener patch --crates-to-patch "$dep" "${diener_commands[$dep]}" --path "Cargo.toml" - # then tell this version of the dependency to use this version of substrate - # bit hacky at the moment since it assums any dependency will also depend on substrate + # Tell this dependency to use the version of substrate in this PR diener patch --crates-to-patch "$SUBSTRATE_DIR" --substrate --path "$dep/Cargo.toml" + # then we tell this repository to point at our locally cloned dependency + diener patch --crates-to-patch "$dep" "${diener_commands[$dep]}" --path "Cargo.toml" fi done @@ -116,6 +117,7 @@ else boldprint "this is not a pull request - building ${REPO}:master" fi -diener patch --crates-to-patch ".." --substrate --path "Cargo.toml" # Test pr or master branch with this Substrate commit. +diener patch --crates-to-patch ".." --substrate --path "Cargo.toml" + eval "$BUILDSTRING" From a7ee4a3153b4b07c873ebefc482d7e4e6938e77a Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Fri, 6 Aug 2021 14:24:04 +0200 Subject: [PATCH 20/20] use jq for parsing PRs --- .gitlab-ci.yml | 4 ++-- .maintain/common/lib.sh | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 070bc20ba17b9..21db307dabc1e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -469,7 +469,7 @@ check-cumulus-companion-build: variables: COMPANION_ORG: paritytech COMPANION_REPO: cumulus - COMPANION_BUILD: "cargo check" + COMPANION_BUILD: "cargo check --all-targets --workspace" COMPANION_DEPENDENCY: paritytech/polkadot allow_failure: true @@ -478,7 +478,7 @@ check-beefy-companion-build: variables: COMPANION_ORG: paritytech COMPANION_REPO: grandpa-bridge-gadget - COMPANION_BUILD: "cargo check" + COMPANION_BUILD: "cargo check --all-targets --workspace" allow_failure: true test-browser-node: diff --git a/.maintain/common/lib.sh b/.maintain/common/lib.sh index 26f783fb51877..e0104f5da9976 100755 --- a/.maintain/common/lib.sh +++ b/.maintain/common/lib.sh @@ -126,18 +126,16 @@ get_companion() { origin_repo="$1" pr_num="$2" companion_repo="$3" - pr_data_file="$(mktemp)" set_github_token github_header="Authorization: token ${GITHUB_TOKEN}" # get the last reference to a pr in the target repo - curl -sSL -H "${github_header}" -o "${pr_data_file}" \ - "${api_base}/$origin_repo/pulls/$pr_num" - - pr_body="$(sed -n -r 's/^[[:space:]]+"body": (".*")[^"]+$/\1/p' "${pr_data_file}")" + pr_body=$( + curl -sSL -H "${github_header}" "${api_base}/$origin_repo/pulls/$pr_num" | \ + jq -r '.body' + ) echo "${pr_body}" | sed -n -r \ -e "s;^.*[Cc]ompanion.*$companion_repo#([0-9]+).*$;\1;p" \ -e "s;^.*[Cc]ompanion.*https://github.com/$companion_repo/pull/([0-9]+).*$;\1;p" \ | tail -n 1 - rm -f "${pr_data_file}" }