mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 05:51:02 +00:00
[CI] Fix check_polkadot_companion_status.sh (#6631)
* check changes_requested and approved separately * handle checking more than 1 CHANGES_REQUESTED review
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# check for a polkadot companion pr and ensure it has approvals and is
|
||||
# check for a polkadot companion pr and ensure it has approvals and is
|
||||
# mergeable
|
||||
#
|
||||
|
||||
github_api_substrate_pull_url="https://api.github.com/repos/paritytech/substrate/pulls"
|
||||
github_api_polkadot_pull_url="https://api.github.com/repos/paritytech/polkadot/pulls"
|
||||
# use github api v3 in order to access the data without authentication
|
||||
github_header="Authorization: token ${GITHUB_PR_TOKEN}"
|
||||
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" ; }
|
||||
@@ -24,7 +24,7 @@ this job checks if there is a string in the description of the pr like
|
||||
|
||||
polkadot companion: paritytech/polkadot#567
|
||||
|
||||
or any other polkadot pr is mentioned in this pr's description and checks its
|
||||
or any other polkadot pr is mentioned in this pr's description and checks its
|
||||
status.
|
||||
|
||||
|
||||
@@ -68,7 +68,10 @@ boldprint "companion pr: #${pr_companion}"
|
||||
# mergable and approved
|
||||
|
||||
curl -H "${github_header}" -sS -o companion_pr.json \
|
||||
${github_api_polkadot_pull_url}/${pr_companion}
|
||||
${github_api_polkadot_pull_url}/${pr_companion}
|
||||
|
||||
pr_head_sha=$(jq -r -e '.head.sha' < companion_pr.json)
|
||||
boldprint "Polkadot PR's HEAD SHA: $pr_head_sha"
|
||||
|
||||
if jq -e .merged < companion_pr.json >/dev/null
|
||||
then
|
||||
@@ -85,11 +88,18 @@ else
|
||||
fi
|
||||
|
||||
curl -H "${github_header}" -sS -o companion_pr_reviews.json \
|
||||
${github_api_polkadot_pull_url}/${pr_companion}/reviews
|
||||
${github_api_polkadot_pull_url}/${pr_companion}/reviews
|
||||
|
||||
if [ -n "$(jq -r -e '.[].state | select(. == "CHANGES_REQUESTED")' < companion_pr_reviews.json)" ] && \
|
||||
[ -z "$(jq -r -e '.[].state | select(. == "APPROVED")' < companion_pr_reviews.json)" ]
|
||||
then
|
||||
# If there are any 'CHANGES_REQUESTED' reviews for the *current* review
|
||||
while IFS= read -r line; do
|
||||
if [ "$line" = "$pr_head_sha" ]; then
|
||||
boldprint "polkadot pr #${pr_companion} has CHANGES_REQUESTED for the latest commit"
|
||||
exit 1
|
||||
fi
|
||||
done <<< $(jq -r -e '.[] | select(.state == "CHANGES_REQUESTED").commit_id' < companion_pr_reviews.json)
|
||||
|
||||
# Then we check for at least 1 APPROVED
|
||||
if [ -z "$(jq -r -e '.[].state | select(. == "APPROVED")' < companion_pr_reviews.json)" ]; then
|
||||
boldprint "polkadot pr #${pr_companion} not APPROVED"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user