mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 13:51:11 +00:00
ci: add check:merge:conflict job (#153)
* ci: add check:merge:conflict job * split caches between test and release job
This commit is contained in:
committed by
GitHub
parent
0a25c425b0
commit
fd4e71758e
+44
-9
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- merge-test
|
||||||
- test
|
- test
|
||||||
- build
|
- build
|
||||||
- publish
|
- publish
|
||||||
@@ -24,11 +25,7 @@ variables:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cache:
|
cache: {}
|
||||||
key: "${CI_JOB_NAME}"
|
|
||||||
paths:
|
|
||||||
- ./.cargo/
|
|
||||||
|
|
||||||
|
|
||||||
.collect_artifacts: &collect_artifacts
|
.collect_artifacts: &collect_artifacts
|
||||||
artifacts:
|
artifacts:
|
||||||
@@ -40,17 +37,49 @@ cache:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.kubernetes_build: &kubernetes_build
|
||||||
|
tags:
|
||||||
|
- kubernetes-parity-build
|
||||||
|
environment:
|
||||||
|
name: gke-build
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# disabled as there are bugs
|
# disabled as there are bugs
|
||||||
# before_script:
|
# before_script:
|
||||||
# - ./scripts/build.sh
|
# - ./scripts/build.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### stage: merge-test
|
||||||
|
|
||||||
|
check:merge:conflict:
|
||||||
|
stage: merge-test
|
||||||
|
image: parity/tools:latest
|
||||||
|
cache: {}
|
||||||
|
<<: *kubernetes_build
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# test will be run for ci on the current repo
|
# test will be run for ci on the current repo
|
||||||
# for version v0.2 branch tests are located in substrate repository and
|
# for version v0.2 branch tests are located in substrate repository and
|
||||||
# therefore not generically testable
|
# therefore not generically testable
|
||||||
test:rust:release:
|
test:rust:release:
|
||||||
stage: test
|
stage: test
|
||||||
|
cache:
|
||||||
|
key: "${CI_JOB_NAME}-test"
|
||||||
|
paths:
|
||||||
|
- ${CARGO_HOME}
|
||||||
|
- ./target
|
||||||
only:
|
only:
|
||||||
- triggers
|
- triggers
|
||||||
- tags
|
- tags
|
||||||
@@ -71,6 +100,11 @@ test:rust:release:
|
|||||||
|
|
||||||
build:rust:linux:release:
|
build:rust:linux:release:
|
||||||
stage: build
|
stage: build
|
||||||
|
cache:
|
||||||
|
key: "${CI_JOB_NAME}-build"
|
||||||
|
paths:
|
||||||
|
- ${CARGO_HOME}
|
||||||
|
- ./target
|
||||||
<<: *collect_artifacts
|
<<: *collect_artifacts
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
@@ -146,13 +180,14 @@ dockerize:release:
|
|||||||
when: manual
|
when: manual
|
||||||
cache: {}
|
cache: {}
|
||||||
retry: 1
|
retry: 1
|
||||||
image: dtzar/helm-kubectl:$HELM_VERSION
|
image: dtzar/helm-kubectl:$HELM_VERSION
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
- tags
|
- tags
|
||||||
- web
|
- web
|
||||||
tags:
|
tags:
|
||||||
- kubernetes
|
# this is the runner that is used to deploy it
|
||||||
|
- kubernetes-parity-build
|
||||||
before_script:
|
before_script:
|
||||||
- test -z "${DEPLOY_TAG}" &&
|
- test -z "${DEPLOY_TAG}" &&
|
||||||
test -f ./target/release/VERSION &&
|
test -f ./target/release/VERSION &&
|
||||||
@@ -181,11 +216,11 @@ dockerize:release:
|
|||||||
deploy:ew3:
|
deploy:ew3:
|
||||||
<<: *deploy
|
<<: *deploy
|
||||||
environment:
|
environment:
|
||||||
name: gke-beta-ew3
|
name: parity-prod-ew3
|
||||||
|
|
||||||
deploy:ue1:
|
deploy:ue1:
|
||||||
<<: *deploy
|
<<: *deploy
|
||||||
environment:
|
environment:
|
||||||
name: gke-beta-ue1
|
name: parity-prod-ue1
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+110
@@ -0,0 +1,110 @@
|
|||||||
|
#!/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
|
||||||
|
|
||||||
|
NODE_RUNTIME_COMPACT="runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm"
|
||||||
|
NODE_RUNTIME="runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.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/polkadot/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
|
||||||
|
|
||||||
|
if [ "${baseref}" = "null" -a "${baserepo}" = "null" ]
|
||||||
|
then
|
||||||
|
echo "| either connectivity issues with github or pull request not existant"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<-EOT
|
||||||
|
| not mergeable
|
||||||
|
|
|
||||||
|
| github sees a conflict - check if it's only about the following wasm blobs
|
||||||
|
|
|
||||||
|
| - ${NODE_RUNTIME_COMPACT}
|
||||||
|
| - ${NODE_RUNTIME}
|
||||||
|
|
|
||||||
|
EOT
|
||||||
|
|
||||||
|
git fetch origin master
|
||||||
|
git config --global user.email "devops-team+polkadot-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 ${NODE_RUNTIME_COMPACT} -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}\"" \
|
||||||
|
${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
|
||||||
Reference in New Issue
Block a user