From c8b62dbe52c595168a50340dd1577637c474b40c Mon Sep 17 00:00:00 2001 From: ale5000 <15793015+ale5000-git@users.noreply.github.com> Date: Sun, 10 Mar 2024 16:39:02 +0100 Subject: [PATCH] GitHub Gradle build improvements (#2224) * Added Gradle Wrapper validation to detect malicious or corrupted Gradlew wrappers. Added problem matcher to automatically add GitHub annotations for build errors (especially useful for PR). * Added a second problem matcher to detect build errors of Kotlin (apparently they are displayed differently from Java errors) (cherry picked from commit 86b73143265b418468e49bba932b8bf0bc02ced0) --- .../gradle-build-kotlin-error-matcher.json | 17 +++++++++++++++++ ...le-build-kotlin-error-matcher.json.license | 2 ++ .github/matchers/gradle-build-matcher.json | 16 ++++++++++++++++ .../gradle-build-matcher.json.license | 2 ++ .github/workflows/build.yml | 19 +++++++++++++++++++ 5 files changed, 56 insertions(+) create mode 100644 .github/matchers/gradle-build-kotlin-error-matcher.json create mode 100644 .github/matchers/gradle-build-kotlin-error-matcher.json.license create mode 100644 .github/matchers/gradle-build-matcher.json create mode 100644 .github/matchers/gradle-build-matcher.json.license diff --git a/.github/matchers/gradle-build-kotlin-error-matcher.json b/.github/matchers/gradle-build-kotlin-error-matcher.json new file mode 100644 index 0000000000..bd9e87622d --- /dev/null +++ b/.github/matchers/gradle-build-kotlin-error-matcher.json @@ -0,0 +1,17 @@ +{ + "problemMatcher": [ + { + "owner": "gradle-build-kotlin-error-matcher", + "severity": "error", + "pattern": [ + { + "regexp": "^e:\\sfile:\/\/([^:]+):(\\d+):(\\d+)\\s(.+)$", + "file": 1, + "line": 2, + "column": 3, + "message": 4 + } + ] + } + ] +} diff --git a/.github/matchers/gradle-build-kotlin-error-matcher.json.license b/.github/matchers/gradle-build-kotlin-error-matcher.json.license new file mode 100644 index 0000000000..f24ebfe55b --- /dev/null +++ b/.github/matchers/gradle-build-kotlin-error-matcher.json.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: none +SPDX-License-Identifier: CC0-1.0 diff --git a/.github/matchers/gradle-build-matcher.json b/.github/matchers/gradle-build-matcher.json new file mode 100644 index 0000000000..e22f22eac4 --- /dev/null +++ b/.github/matchers/gradle-build-matcher.json @@ -0,0 +1,16 @@ +{ + "problemMatcher": [ + { + "owner": "gradle-build-matcher", + "pattern": [ + { + "regexp": "^([^:]+):(\\d+):\\s(error|Error):\\s(.+)$", + "file": 1, + "line": 2, + "severity": 3, + "message": 4 + } + ] + } + ] +} diff --git a/.github/matchers/gradle-build-matcher.json.license b/.github/matchers/gradle-build-matcher.json.license new file mode 100644 index 0000000000..f24ebfe55b --- /dev/null +++ b/.github/matchers/gradle-build-matcher.json.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: none +SPDX-License-Identifier: CC0-1.0 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f60c53f21b..67c506394b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,26 @@ jobs: with: distribution: "temurin" java-version: "17" + - name: "Gradle Wrapper validation" + uses: gradle/wrapper-validation-action@v2 - name: "Setup Gradle" uses: gradle/actions/setup-gradle@v3 + - name: "Setup matchers" + run: | + # Setting up matchers... + + matchers_dir='${{ github.workspace }}/.github/matchers' + matcher_list() + { + echo 'gradle-build-matcher.json' + echo 'gradle-build-kotlin-error-matcher.json' + } + + matcher_list | while IFS='' read -r NAME; do + if test -f "${matchers_dir:?}/${NAME:?}"; then + echo "::add-matcher::${matchers_dir:?}/${NAME:?}" + echo "Matcher configured: ${NAME:?}" + fi + done - name: "Execute Gradle build" run: "./gradlew --no-daemon build"