mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 15:11:02 +00:00
[CI] add check_tags CI job (#1072)
* add check_tags CI job * fix typo in gitlab-ci.yml * add more useful CI output * Make presence of github token optional
This commit is contained in:
@@ -73,7 +73,16 @@ variables:
|
|||||||
- /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
|
- /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
|
||||||
- /^[0-9]+$/
|
- /^[0-9]+$/
|
||||||
|
|
||||||
|
#### stage: .pre
|
||||||
|
|
||||||
|
check-labels:
|
||||||
|
stage: .pre
|
||||||
|
image: parity/tools:latest
|
||||||
|
<<: *kubernetes-env
|
||||||
|
only:
|
||||||
|
- /^[0-9]+$/
|
||||||
|
script:
|
||||||
|
- ./scripts/gitlab/check_tags.sh
|
||||||
|
|
||||||
#### stage: test
|
#### stage: test
|
||||||
|
|
||||||
|
|||||||
Executable
+23
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
#shellcheck source=lib.sh
|
||||||
|
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh"
|
||||||
|
|
||||||
|
# Must have one of the following labels
|
||||||
|
labels=(
|
||||||
|
'B1-releasenotes'
|
||||||
|
'B1-runtimeworthy'
|
||||||
|
'B1-silent'
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "[+] Checking labels for $CI_COMMIT_BRANCH"
|
||||||
|
|
||||||
|
for label in "${labels[@]}"; do
|
||||||
|
if has_label 'paritytech/polkadot' "$CI_COMMIT_BRANCH" "$label"; then
|
||||||
|
echo "[+] Label $label detected, test passed"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "[!] PR does not have one of the required labels! Please add one of: ${labels[*]}"
|
||||||
|
exit 1
|
||||||
@@ -21,7 +21,11 @@ sanitised_git_logs(){
|
|||||||
check_tag () {
|
check_tag () {
|
||||||
repo=$1
|
repo=$1
|
||||||
tagver=$2
|
tagver=$2
|
||||||
tag_out=$(curl -H "Authorization: token $GITHUB_RELEASE_TOKEN" -s "$api_base/$repo/git/refs/tags/$tagver")
|
if [ -n "$GITHUB_RELEASE_TOKEN" ]; then
|
||||||
|
tag_out=$(curl -H "Authorization: token $GITHUB_RELEASE_TOKEN" -s "$api_base/$repo/git/refs/tags/$tagver")
|
||||||
|
else
|
||||||
|
tag_out=$(curl -s "$api_base/$repo/git/refs/tags/$tagver")
|
||||||
|
fi
|
||||||
tag_sha=$(echo "$tag_out" | jq -r .object.sha)
|
tag_sha=$(echo "$tag_out" | jq -r .object.sha)
|
||||||
object_url=$(echo "$tag_out" | jq -r .object.url)
|
object_url=$(echo "$tag_out" | jq -r .object.url)
|
||||||
if [ "$tag_sha" = "null" ]; then
|
if [ "$tag_sha" = "null" ]; then
|
||||||
@@ -46,7 +50,11 @@ has_label(){
|
|||||||
repo="$1"
|
repo="$1"
|
||||||
pr_id="$2"
|
pr_id="$2"
|
||||||
label="$3"
|
label="$3"
|
||||||
out=$(curl -H "Authorization: token $GITHUB_RELEASE_TOKEN" -s "$api_base/$repo/pulls/$pr_id")
|
if [ -n "$GITHUB_RELEASE_TOKEN" ]; then
|
||||||
|
out=$(curl -H "Authorization: token $GITHUB_RELEASE_TOKEN" -s "$api_base/$repo/pulls/$pr_id")
|
||||||
|
else
|
||||||
|
out=$(curl -s "$api_base/$repo/pulls/$pr_id")
|
||||||
|
fi
|
||||||
[ -n "$(echo "$out" | tr -d '\r\n' | jq ".labels | .[] | select(.name==\"$label\")")" ]
|
[ -n "$(echo "$out" | tr -d '\r\n' | jq ".labels | .[] | select(.name==\"$label\")")" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user