mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 15:55:49 +00:00
gitlab-ci: merge-test stage (#1752)
This commit is contained in:
committed by
Gav Wood
parent
fafffdb771
commit
3cbf2bc9c4
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- merge-test
|
||||||
- test
|
- test
|
||||||
- build
|
- build
|
||||||
- publish
|
- publish
|
||||||
@@ -35,10 +36,29 @@ cache:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### stage: merge-test
|
||||||
|
|
||||||
|
check:merge:conflict:
|
||||||
|
stage: merge-test
|
||||||
|
image: parity/tools:latest
|
||||||
|
cache: {}
|
||||||
|
tags:
|
||||||
|
- linux-docker
|
||||||
|
only:
|
||||||
|
- /^[0-9]+$/
|
||||||
|
variables:
|
||||||
|
GITHUB_API: "https://api.github.com"
|
||||||
|
GITLAB_API: "https://gitlab.parity.io/api/v4"
|
||||||
|
GITHUB_API_PROJECT: "parity%2Finfrastructure%2Fgithub-api"
|
||||||
|
script:
|
||||||
|
- ./scripts/gitlab/check_merge_conflict.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### stage: test
|
#### stage: test
|
||||||
|
|
||||||
test:runtime:
|
check:runtime:
|
||||||
stage: test
|
stage: test
|
||||||
image: parity/tools:latest
|
image: parity/tools:latest
|
||||||
cache: {}
|
cache: {}
|
||||||
@@ -64,7 +84,6 @@ test:rust:stable: &test
|
|||||||
RUSTFLAGS: -Cdebug-assertions=y
|
RUSTFLAGS: -Cdebug-assertions=y
|
||||||
TARGET: native
|
TARGET: native
|
||||||
only:
|
only:
|
||||||
- triggers
|
|
||||||
- tags
|
- tags
|
||||||
- master
|
- master
|
||||||
- schedules
|
- schedules
|
||||||
|
|||||||
+106
@@ -0,0 +1,106 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# check if there is a merge conflict with this pull request only about wasm
|
||||||
|
# binary blobs. if so trigger a rebuild of it and push it on the feature
|
||||||
|
# branch if owned by paritytech
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # fail on any error
|
||||||
|
|
||||||
|
TEST_RUNTIME="core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm"
|
||||||
|
NODE_RUNTIME="node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
jsonfile="$(mktemp)"
|
||||||
|
|
||||||
|
attemptno="1"
|
||||||
|
while ( ! test -s ${jsonfile} ) \
|
||||||
|
|| ( [ "$(jq -r .mergeable ${jsonfile})" = "null" ] \
|
||||||
|
&& [ "${attemptno}" -lt 5 ] )
|
||||||
|
do
|
||||||
|
echo "| checking pull request status (attempt no ${attemptno})"
|
||||||
|
curl -sS -o ${jsonfile} -H "Accept: application/vnd.github.v3+json" \
|
||||||
|
"${GITHUB_API}/repos/paritytech/substrate/pulls/${CI_COMMIT_REF_NAME}"
|
||||||
|
sleep 3
|
||||||
|
attemptno="$(( ${attemptno} + 1 ))"
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
baseref="$(jq -r .head.ref ${jsonfile})"
|
||||||
|
baserepo="$(jq -r .head.repo.full_name ${jsonfile})"
|
||||||
|
mergeable="$(jq -r .mergeable ${jsonfile})"
|
||||||
|
|
||||||
|
rm -f ${jsonfile}
|
||||||
|
|
||||||
|
|
||||||
|
cat <<-EOT
|
||||||
|
|
|
||||||
|
| pr is of feature branch ${baseref} on ${baserepo}
|
||||||
|
|
|
||||||
|
| tell me github is this branch mergeable into the master branch?
|
||||||
|
|
|
||||||
|
EOT
|
||||||
|
|
||||||
|
test "${mergeable}" = "true" && echo "| yes, it is." && exit 0
|
||||||
|
|
||||||
|
|
||||||
|
cat <<-EOT
|
||||||
|
| not mergeable
|
||||||
|
|
|
||||||
|
| github sees a conflict - check if it's only about the following wasm blobs
|
||||||
|
|
|
||||||
|
| - ${TEST_RUNTIME}
|
||||||
|
| - ${NODE_RUNTIME}
|
||||||
|
|
|
||||||
|
EOT
|
||||||
|
|
||||||
|
git fetch origin master
|
||||||
|
git config --global user.email "devops-team+substrate-ci-merge-conflict@parity.io"
|
||||||
|
git config --global user.name "I shall never commit to anything"
|
||||||
|
|
||||||
|
cat <<-EOT
|
||||||
|
|
|
||||||
|
| trying to merge with the master branch to see if there is a conflict about
|
||||||
|
| the wasm files only
|
||||||
|
|
|
||||||
|
EOT
|
||||||
|
|
||||||
|
if git merge --no-commit --no-ff origin/master | grep '^CONFLICT ' \
|
||||||
|
| grep -v -e ${TEST_RUNTIME} -e ${NODE_RUNTIME}
|
||||||
|
then
|
||||||
|
git merge --abort
|
||||||
|
echo "| there are more conflicting files than the wasm blobs"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
git merge --abort
|
||||||
|
|
||||||
|
|
||||||
|
cat <<-EOT
|
||||||
|
|
|
||||||
|
| only wasm blobs block the merge.
|
||||||
|
|
|
||||||
|
| triggering rebuild of wasm blobs which will be pushed onto the feature
|
||||||
|
| branch of this pull request upon success.
|
||||||
|
|
|
||||||
|
| see:
|
||||||
|
|
|
||||||
|
EOT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
curl -sS -X POST \
|
||||||
|
-F "token=${CI_JOB_TOKEN}" \
|
||||||
|
-F "ref=master" \
|
||||||
|
-F "variables[REBUILD_WASM]=\"${baserepo}:${baseref}\"" \
|
||||||
|
-F "variables[PRNO]=${CI_COMMIT_REF_NAME}" \
|
||||||
|
${GITLAB_API}/projects/${GITHUB_API_PROJECT}/trigger/pipeline \
|
||||||
|
| jq -r .web_url
|
||||||
|
|
||||||
|
# fail as there will be another commit on top of that feature branch that will
|
||||||
|
# be tested anyway.
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
|
||||||
|
# vim: noexpandtab
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
set -e # fail on any error
|
set -e # fail on any error
|
||||||
|
|
||||||
|
|
||||||
# give some context
|
# give some context
|
||||||
git log --graph --oneline --decorate=short -n 10
|
git log --graph --oneline --decorate=short -n 10
|
||||||
|
|
||||||
@@ -15,6 +16,18 @@ git log --graph --oneline --decorate=short -n 10
|
|||||||
RUNTIME="node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm"
|
RUNTIME="node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm"
|
||||||
VERSIONS_FILE="node/runtime/src/lib.rs"
|
VERSIONS_FILE="node/runtime/src/lib.rs"
|
||||||
|
|
||||||
|
github_label () {
|
||||||
|
echo
|
||||||
|
echo "# run github-api job for labelling it ${1}"
|
||||||
|
curl -sS -X POST \
|
||||||
|
-F "token=${CI_JOB_TOKEN}" \
|
||||||
|
-F "ref=master" \
|
||||||
|
-F "variables[LABEL]=${1}" \
|
||||||
|
-F "variables[PRNO]=${CI_COMMIT_REF_NAME}" \
|
||||||
|
${GITLAB_API}/projects/${GITHUB_API_PROJECT}/trigger/pipeline
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# check if the wasm sources changed
|
# check if the wasm sources changed
|
||||||
@@ -45,14 +58,8 @@ sub_spec_version="$(git diff origin/master...${CI_COMMIT_SHA} ${VERSIONS_FILE} \
|
|||||||
# see if the version and the binary blob changed
|
# see if the version and the binary blob changed
|
||||||
if [ "${add_spec_version}" != "${sub_spec_version}" ]
|
if [ "${add_spec_version}" != "${sub_spec_version}" ]
|
||||||
then
|
then
|
||||||
echo
|
|
||||||
echo "# run github-api job for labelling it breaksapi"
|
github_label "B2-breaksapi"
|
||||||
curl -sS -X POST \
|
|
||||||
-F "token=${CI_JOB_TOKEN}" \
|
|
||||||
-F "ref=master" \
|
|
||||||
-F "variables[BREAKSAPI]=true" \
|
|
||||||
-F "variables[PRNO]=${CI_COMMIT_REF_NAME}" \
|
|
||||||
${GITLAB_API}/projects/${GITHUB_API_PROJECT}/trigger/pipeline
|
|
||||||
|
|
||||||
if git diff --name-only origin/master...${CI_COMMIT_SHA} \
|
if git diff --name-only origin/master...${CI_COMMIT_SHA} \
|
||||||
| grep -q "${RUNTIME}"
|
| grep -q "${RUNTIME}"
|
||||||
@@ -122,14 +129,7 @@ fi
|
|||||||
|
|
||||||
# dropped through. there's something wrong; mark `gotissues` and exit 1.
|
# dropped through. there's something wrong; mark `gotissues` and exit 1.
|
||||||
|
|
||||||
echo
|
github_label "A4-gotissues"
|
||||||
echo "# run github-api job for labelling it gotissues"
|
|
||||||
curl -sS -X POST \
|
|
||||||
-F "token=${CI_JOB_TOKEN}" \
|
|
||||||
-F "ref=master" \
|
|
||||||
-F "variables[GOTISSUES]=true" \
|
|
||||||
-F "variables[PRNO]=${CI_COMMIT_REF_NAME}" \
|
|
||||||
${GITLAB_API}/projects/${GITHUB_API_PROJECT}/trigger/pipeline
|
|
||||||
|
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user