Skip to content

Commit

Permalink
GitHub Gradle build improvements (microg#2224)
Browse files Browse the repository at this point in the history
* 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 86b7314)
  • Loading branch information
ale5000-git authored and WSTxda committed Mar 10, 2024
1 parent c53bbdd commit c8b62db
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/matchers/gradle-build-kotlin-error-matcher.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: none
SPDX-License-Identifier: CC0-1.0
16 changes: 16 additions & 0 deletions .github/matchers/gradle-build-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"problemMatcher": [
{
"owner": "gradle-build-matcher",
"pattern": [
{
"regexp": "^([^:]+):(\\d+):\\s(error|Error):\\s(.+)$",
"file": 1,
"line": 2,
"severity": 3,
"message": 4
}
]
}
]
}
2 changes: 2 additions & 0 deletions .github/matchers/gradle-build-matcher.json.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: none
SPDX-License-Identifier: CC0-1.0
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit c8b62db

Please sign in to comment.