From 20a6e6da8ccb41bd77f781b0affdfb20b80af1f7 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Wed, 6 Jul 2022 15:48:34 +0100 Subject: 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. --- tools/ci/actions/check-changes-modified.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'tools') 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 -- cgit v1.2.1