summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDavid Allsopp <david.allsopp@metastack.com>2022-07-06 15:48:34 +0100
committerDavid Allsopp <david.allsopp@metastack.com>2022-08-29 18:01:00 +0100
commit20a6e6da8ccb41bd77f781b0affdfb20b80af1f7 (patch)
treee995595bddba079c8a9122931337560bb131c6c4 /tools
parent03bae526a42546813c3876c1d3ff3d71acb3f411 (diff)
downloadocaml-20a6e6da8ccb41bd77f781b0affdfb20b80af1f7.tar.gz
Tweak the Check Changes job
At present, if a PR is opened with no Changes entry, the job fails. If the no-changes-entry-needed label is then added, the job is skipped. However, when the PR is merged, GitHub then reports a failed check. This restores the old behaviour where we use the GitHub API to check the labels on the PR but, unlike on Travis, uses the GITHUB_TOKEN set-up within the runner so that we (hopefully) don't upset GitHub API rate limiting.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/ci/actions/check-changes-modified.sh16
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/ci/actions/check-changes-modified.sh b/tools/ci/actions/check-changes-modified.sh
index e989e964b9..04c221c350 100755
--- a/tools/ci/actions/check-changes-modified.sh
+++ b/tools/ci/actions/check-changes-modified.sh
@@ -18,7 +18,12 @@ set -e
# Hygiene Checks: check that Changes has been updated in PRs
# One of the following must be true:
# - A commit in the PR alters the Changes file
-# - The no-change-entry-needed label is applied to the PR (handled in YAML)
+# - The no-change-entry-needed label is applied to the PR
+
+API_URL="$1"
+shift 1
+
+AUTH="authorization: Bearer $GITHUB_TOKEN"
# We need all the commits in the PR to be available
. tools/ci/actions/deepen-fetch.sh
@@ -26,8 +31,13 @@ set -e
MSG='Check Changes has been updated'
COMMIT_RANGE="$MERGE_BASE..$PR_HEAD"
+LABEL='no-change-entry-needed'
# Check if Changes has been updated in the PR
-if git diff "$COMMIT_RANGE" --name-only --exit-code Changes > /dev/null; then
+if ! git diff "$COMMIT_RANGE" --name-only --exit-code Changes > /dev/null; then
+ echo -e "$MSG: \e[32mYES\e[0m"
+elif curl --silent --header "$AUTH" "$API_URL/labels" | grep -q "$LABEL"; then
+ echo -e "$MSG: \e[33mSKIP\e[0m"
+else
echo -e "$MSG: \e[31mNO\e[0m"
cat <<"EOF"
------------------------------------------------------------------------
@@ -42,6 +52,4 @@ using the "no-change-entry-needed" label on the github pull request.
------------------------------------------------------------------------
EOF
exit 1
-else
- echo -e "$MSG: \e[32mYES\e[0m"
fi