mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 03:31:05 +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
|
#!/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
|
# mergeable
|
||||||
#
|
#
|
||||||
|
|
||||||
github_api_substrate_pull_url="https://api.github.com/repos/paritytech/substrate/pulls"
|
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"
|
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
|
# 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" ; }
|
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 () { 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
|
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.
|
status.
|
||||||
|
|
||||||
|
|
||||||
@@ -68,7 +68,10 @@ boldprint "companion pr: #${pr_companion}"
|
|||||||
# mergable and approved
|
# mergable and approved
|
||||||
|
|
||||||
curl -H "${github_header}" -sS -o companion_pr.json \
|
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
|
if jq -e .merged < companion_pr.json >/dev/null
|
||||||
then
|
then
|
||||||
@@ -85,11 +88,18 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
curl -H "${github_header}" -sS -o companion_pr_reviews.json \
|
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)" ] && \
|
# If there are any 'CHANGES_REQUESTED' reviews for the *current* review
|
||||||
[ -z "$(jq -r -e '.[].state | select(. == "APPROVED")' < companion_pr_reviews.json)" ]
|
while IFS= read -r line; do
|
||||||
then
|
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"
|
boldprint "polkadot pr #${pr_companion} not APPROVED"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user