From 741aaf9a38aeff5bfb732ae5c00fd9eb0b0e8cda Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Fri, 8 Jan 2021 15:21:44 +0100 Subject: [PATCH 1/3] pr_check: fix README --- dist/tools/pr_check/README.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/dist/tools/pr_check/README.md b/dist/tools/pr_check/README.md index 149ad0d660ac..d70404151296 100644 --- a/dist/tools/pr_check/README.md +++ b/dist/tools/pr_check/README.md @@ -1,18 +1,17 @@ # About -This script checks if a Pull Request needs squashing or if it is waiting for -another Pull Request. +This script checks if a Pull Request needs squashing. # Usage ```bash -./check.sh [] +./check.sh [] ``` -The optional `` parameter refers to the branch the pull request's -branch branched from. The script will output all commits marked as squashable -from `HEAD` to the merge-base with ``. The default for -`` is `master`. +The `` parameter refers to the branch the pull request's branch branched +from. The script will output all commits marked as squashable from `HEAD` to the +merge-base with ``. The default for `` is `master`. -A commit is marked as squashable if it contains the keywords SQUASH or FIX -(case insensitive) within the first five characters of it's subject title. +A commit is marked as squashable if it contains the keywords SQUASH, FIX or +REMOVE ME (case insensitive) within the first five characters of it's subject +title. From 375df5740ac5fb4c69f21c6cd4889bf40fbb6295 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Fri, 8 Jan 2021 15:22:31 +0100 Subject: [PATCH 2/3] pr_check: remove label check --- .github/workflows/check-pr.yml | 3 --- dist/tools/pr_check/check.sh | 13 ----------- dist/tools/pr_check/check_labels.sh | 36 ----------------------------- 3 files changed, 52 deletions(-) delete mode 100644 dist/tools/pr_check/check_labels.sh diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml index 1970c6726c92..8a67021d3ef9 100644 --- a/.github/workflows/check-pr.yml +++ b/.github/workflows/check-pr.yml @@ -32,8 +32,5 @@ jobs: run: git fetch origin '${{ github.base_ref }}:${{ github.base_ref }}' - name: Run checks - env: # enforce deactivation of label check in pr_check - TRAVIS_PULL_REQUEST: - CI_PULL_NR: run: | ./dist/tools/${{ matrix.check }}/check.sh "${{ github.base_ref }}" diff --git a/dist/tools/pr_check/check.sh b/dist/tools/pr_check/check.sh index 12eb2ada8a41..ef4f631bf1a1 100755 --- a/dist/tools/pr_check/check.sh +++ b/dist/tools/pr_check/check.sh @@ -11,7 +11,6 @@ cd $RIOTBASE : "${RIOTTOOLS:=${RIOTBASE}/dist/tools}" -. "${RIOTTOOLS}"/pr_check/check_labels.sh EXIT_CODE=0 @@ -45,16 +44,4 @@ if [ -n "${SQUASH_COMMITS}" ]; then EXIT_CODE=1 fi -if [ -n "$TRAVIS_PULL_REQUEST" -o -n "$CI_PULL_NR" ]; then - if check_gh_label "CI: needs squashing"; then - echo -e "${CERROR}Pull request needs squashing according to its labels set on GitHub${CRESET}" - EXIT_CODE=1 - fi - - if check_gh_label "State: waiting for other PR"; then - echo -e "${CERROR}Pull request is waiting for another pull request according to its labels set on GitHub${CRESET}" - EXIT_CODE=1 - fi -fi - exit ${EXIT_CODE} diff --git a/dist/tools/pr_check/check_labels.sh b/dist/tools/pr_check/check_labels.sh deleted file mode 100644 index 6034a6ef6529..000000000000 --- a/dist/tools/pr_check/check_labels.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2014 Martine Lenders -# -# This file is subject to the terms and conditions of the GNU Lesser -# General Public License v2.1. See the file LICENSE in the top level -# directory for more details. -# - -# The following script part has been moved here from: -# ./dist/tools/pr_check/check.sh - -GITHUB_API_HOST="https://api.github.com" -GITHUB_REPO="RIOT-OS/RIOT" - -if which wget &> /dev/null; then - GET="wget -O -" -elif which curl &> /dev/null; then - GET="curl" -else - echo "Script needs wget or curl" >&2 - exit 2 -fi - -if [ -n "$TRAVIS_PULL_REQUEST" ]; then - LABELS_JSON=$(${GET} "${GITHUB_API_HOST}/repos/${GITHUB_REPO}/issues/${TRAVIS_PULL_REQUEST}/labels" 2> /dev/null) -elif [ -n "$CI_PULL_LABELS" ]; then - LABELS_JSON="$CI_PULL_LABELS" -fi - -check_gh_label() { - LABEL="${1}" - - echo "${LABELS_JSON}" | grep -q "${LABEL}" - return $? -} From d4628dc07fec18d1d6e453c553cfa0105258ac8e Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Fri, 8 Jan 2021 15:26:52 +0100 Subject: [PATCH 3/3] dist/tools/pr_check: annotate errors in Github Action --- dist/tools/pr_check/check.sh | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/dist/tools/pr_check/check.sh b/dist/tools/pr_check/check.sh index ef4f631bf1a1..b00f428fa350 100755 --- a/dist/tools/pr_check/check.sh +++ b/dist/tools/pr_check/check.sh @@ -7,6 +7,8 @@ # directory for more details. # +. "$(dirname "$0")/../ci/github_annotate.sh" + : "${RIOTBASE:=$(cd $(dirname $0)/../../../; pwd)}" cd $RIOTBASE @@ -14,6 +16,8 @@ cd $RIOTBASE EXIT_CODE=0 +github_annotate_setup + if tput colors &> /dev/null && [ $(tput colors) -ge 8 ]; then CERROR="\e[1;31m" CRESET="\e[0m" @@ -39,9 +43,24 @@ SQUASH_COMMITS="$(git log $(git merge-base HEAD "${RIOT_MASTER}")...HEAD --prett keyword_filter)" if [ -n "${SQUASH_COMMITS}" ]; then - echo -e "${CERROR}Pull request needs squashing:${CRESET}" 1>&2 - echo -e "${SQUASH_COMMITS}" + if github_annotate_is_on; then + echo "${SQUASH_COMMITS}" | while read commit; do + ANNOTATION="Commit needs to be squashed: \"${commit}\"" + ANNOTATION="${ANNOTATION}\n\nPLEASE ONLY SQUASH WHEN ASKED BY A " + ANNOTATION="${ANNOTATION}MAINTAINER!" + ANNOTATION="${ANNOTATION}\nSee: " + ANNOTATION="${ANNOTATION}https://github.com/RIOT-OS/RIOT/blob/master/CONTRIBUTING.md#squash-commits-after-review" + github_annotate_error_no_file "${ANNOTATION}" + done + else + echo -e "${CERROR}Pull request needs squashing:${CRESET}" 1>&2 + echo -e "${SQUASH_COMMITS}" + fi EXIT_CODE=1 fi +github_annotate_teardown + +github_annotate_report_last_run + exit ${EXIT_CODE}