From e69617a49368fa4f0214ad96172c6186c005bf19 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Thu, 17 Dec 2020 12:46:29 +0100 Subject: [PATCH 1/4] dist/tools/pr_check: rename check script to common name --- dist/tools/pr_check/README.md | 2 +- dist/tools/pr_check/{pr_check.sh => check.sh} | 0 dist/tools/pr_check/check_labels.sh | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename dist/tools/pr_check/{pr_check.sh => check.sh} (100%) diff --git a/dist/tools/pr_check/README.md b/dist/tools/pr_check/README.md index 2215399652..149ad0d660 100644 --- a/dist/tools/pr_check/README.md +++ b/dist/tools/pr_check/README.md @@ -6,7 +6,7 @@ another Pull Request. # Usage ```bash -./pr_check.sh [] +./check.sh [] ``` The optional `` parameter refers to the branch the pull request's diff --git a/dist/tools/pr_check/pr_check.sh b/dist/tools/pr_check/check.sh similarity index 100% rename from dist/tools/pr_check/pr_check.sh rename to dist/tools/pr_check/check.sh diff --git a/dist/tools/pr_check/check_labels.sh b/dist/tools/pr_check/check_labels.sh index aa7ee7a1a9..6034a6ef65 100644 --- a/dist/tools/pr_check/check_labels.sh +++ b/dist/tools/pr_check/check_labels.sh @@ -8,7 +8,7 @@ # # The following script part has been moved here from: -# ./dist/tools/pr_check/pr_check.sh +# ./dist/tools/pr_check/check.sh GITHUB_API_HOST="https://api.github.com" GITHUB_REPO="RIOT-OS/RIOT" From 44b48e6c2d3375432939d04c2acfc1232dc5d0a9 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Fri, 4 Dec 2020 17:00:30 +0100 Subject: [PATCH 2/4] gh-actions: move PR checks from static tests to own workflow --- .github/workflows/check-labels.yml | 15 ------------ .github/workflows/check-pr.yml | 39 ++++++++++++++++++++++++++++++ dist/tools/ci/static_tests.sh | 2 -- 3 files changed, 39 insertions(+), 17 deletions(-) delete mode 100644 .github/workflows/check-labels.yml create mode 100644 .github/workflows/check-pr.yml diff --git a/.github/workflows/check-labels.yml b/.github/workflows/check-labels.yml deleted file mode 100644 index cc4a4f26b5..0000000000 --- a/.github/workflows/check-labels.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: check-labels -on: - pull_request: - types: [opened, reopened, labeled, unlabeled, synchronize] - pull_request_review: - types: [submitted, dismissed] -jobs: - check-labels: - runs-on: ubuntu-latest - steps: - - uses: RIOT-OS/check-labels-action@v1.0.0 - with: - access_token: ${{ secrets.GITHUB_TOKEN }} - unset_labels: 'CI: needs squashing,State: waiting for other PR' - cond_labels: '(Process: needs >1 ACK,review.approvals>1),(Area: RDM,review.approvals>2)' diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml new file mode 100644 index 0000000000..7ba7cc1ddf --- /dev/null +++ b/.github/workflows/check-pr.yml @@ -0,0 +1,39 @@ +name: check-pr +on: + pull_request: + types: [opened, reopened, labeled, unlabeled, synchronize] + pull_request_review: + types: [submitted, dismissed] +jobs: + check-labels: + runs-on: ubuntu-latest + steps: + - uses: RIOT-OS/check-labels-action@v1.0.0 + with: + access_token: ${{ secrets.GITHUB_TOKEN }} + unset_labels: 'CI: needs squashing,State: waiting for other PR' + cond_labels: '(Process: needs >1 ACK,review.approvals>1),(Area: RDM,review.approvals>2)' + check-commits: + runs-on: ubuntu-latest + if: ${{ github.base_ref }} + strategy: + fail-fast: false + matrix: + check: [commit-msg, pr_check] + steps: + - uses: actions/checkout@master + with: + # Use the SHA of the PR branch as-is, not the PR branch merged + # in master (default behavior in GH actions) + # See https://github.com/actions/checkout#checkout-pull-request-head-commit-instead-of-merge-commit + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + - name: Fetch base branch + 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/ci/static_tests.sh b/dist/tools/ci/static_tests.sh index b9f701a9ea..862ee1f3b1 100755 --- a/dist/tools/ci/static_tests.sh +++ b/dist/tools/ci/static_tests.sh @@ -103,7 +103,6 @@ fi export BASE_BRANCH="${CI_BASE_BRANCH}" -run ./dist/tools/commit-msg/check.sh "${BASE_BRANCH}" run ./dist/tools/whitespacecheck/check.sh "${BASE_BRANCH}" DIFFFILTER="MR" ERROR_EXIT_CODE=0 run ./dist/tools/licenses/check.sh DIFFFILTER="AC" run ./dist/tools/licenses/check.sh @@ -111,7 +110,6 @@ run ./dist/tools/doccheck/check.sh run ./dist/tools/externc/check.sh run ./dist/tools/cppcheck/check.sh run ./dist/tools/vera++/check.sh -run ./dist/tools/pr_check/pr_check.sh "${BASE_BRANCH}" run ./dist/tools/coccinelle/check.sh run ./dist/tools/flake8/check.sh run ./dist/tools/headerguards/check.sh From e5f5f3c0b3db3c20385a7accd7ad4d4f47966443 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Thu, 17 Dec 2020 12:58:35 +0100 Subject: [PATCH 3/4] gh-actions: static-tests: remove ref from checkout That parameter was solely needed for the commit checks that are now moved to the `check-pr` workflow. The only other test using git is the whitespace check and that works just fine on the merge commit. --- .github/workflows/static-test.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/static-test.yml b/.github/workflows/static-test.yml index 208bca7e76..5b48f11adc 100644 --- a/.github/workflows/static-test.yml +++ b/.github/workflows/static-test.yml @@ -18,10 +18,6 @@ jobs: steps: - uses: actions/checkout@v2 with: - # Use the SHA of the PR branch as-is, not the PR branch merged - # in master (default behavior in GH actions) - # See https://github.com/actions/checkout#checkout-pull-request-head-commit-instead-of-merge-commit - ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 - name: Setup git run: | From 6208515a86780a6d6b658dcc149bc9e12c5be480 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Fri, 8 Jan 2021 12:08:33 +0100 Subject: [PATCH 4/4] dist/whitespacecheck: use result of piped command for return value --- dist/tools/whitespacecheck/check.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/tools/whitespacecheck/check.sh b/dist/tools/whitespacecheck/check.sh index 37f9938518..6d8e9a6425 100755 --- a/dist/tools/whitespacecheck/check.sh +++ b/dist/tools/whitespacecheck/check.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Copyright 2015 Oliver Hahm # @@ -38,7 +38,7 @@ fi git -c core.whitespace="tab-in-indent,tabwidth=4" \ diff --check "$(git merge-base "${BRANCH}" HEAD)" -- *.[ch] ${IGNORE} \ | ${LOG} -RESULT=$? +RESULT=${PIPESTATUS[0]} # Git regards any trailing white space except `\n` as an error so `\r` is # checked here, too @@ -46,7 +46,7 @@ git -c core.whitespace="trailing-space" \ diff --check "$(git merge-base "${BRANCH}" HEAD)" -- . ${IGNORE} \ | ${LOG} -TRAILING_RESULT=$? +TRAILING_RESULT=${PIPESTATUS[0]} github_annotate_parse_log_default