aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows
diff options
context:
space:
mode:
authorRoman / Linnea Gräf <roman.graef@gmail.com>2023-07-06 01:53:07 +0200
committerGitHub <noreply@github.com>2023-07-06 09:53:07 +1000
commit3aa6d8ce069902f81a341ccb5d33fc76f7274935 (patch)
treeeae5ef2fd69dc8c81ab2c4c5d183dd5d7d91d9fe /.github/workflows
parent3ee496ecb794c4b7073d77e2074644104d0a5eeb (diff)
downloadNotEnoughUpdates-3aa6d8ce069902f81a341ccb5d33fc76f7274935.tar.gz
NotEnoughUpdates-3aa6d8ce069902f81a341ccb5d33fc76f7274935.tar.bz2
NotEnoughUpdates-3aa6d8ce069902f81a341ccb5d33fc76f7274935.zip
Add detekt rules (#750)
Diffstat (limited to '.github/workflows')
-rw-r--r--.github/workflows/build.yml5
-rw-r--r--.github/workflows/detekt.yml33
2 files changed, 36 insertions, 2 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d610b4d5..0cb85ac0 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -43,9 +43,10 @@ jobs:
with:
java-version: 17
distribution: temurin
- cache: gradle
+ - name: Set up gradle cache
+ uses: gradle/gradle-build-action@v2
- name: Build with Gradle
- run: chmod +x ./gradlew && ./gradlew clean test remapJar --no-daemon
+ run: ./gradlew clean test remapJar --no-daemon
- uses: actions/upload-artifact@v3
with:
path: build/libs/*-dep.jar
diff --git a/.github/workflows/detekt.yml b/.github/workflows/detekt.yml
new file mode 100644
index 00000000..a3ae8eaf
--- /dev/null
+++ b/.github/workflows/detekt.yml
@@ -0,0 +1,33 @@
+name: Detekt
+
+on:
+ - pull_request
+ - push
+permissions: {}
+jobs:
+ detektering:
+ runs-on: ubuntu-latest
+ if: "!contains(github.event.head_commit.message, '[no infer]')"
+ steps:
+ - uses: actions/checkout@v3
+ name: Checkout feature
+ - name: Set up JDK 17
+ uses: actions/setup-java@v3
+ with:
+ java-version: 17
+ distribution: temurin
+ cache: gradle
+ - name: Set up gradle cache
+ uses: gradle/gradle-build-action@v2
+ - name: Run detekt
+ run: |
+ ./gradlew :detektMain --stacktrace
+ - name: Generate report
+ run: |
+ jq -r '.runs[].results[]|select(.level != "error")|{"message":.message.text, "locations":.locations[].physicalLocation}|("::warning file="+(.locations.artifactLocation.uri|sub("^'"$(readlink -f .)"'"; ""))+",line="+(.locations.region.startLine|tostring)+",endLine="+(.locations.region.endLine|tostring)+",col="+(.locations.region.startColumn|tostring)+",endColumn="+(.locations.region.endColumn|tostring)+"::"+.message)' <build/reports/detekt/main.sarif
+ jq -r '.runs[].results[]|select(.level == "error")|{"message":.message.text, "locations":.locations[].physicalLocation}|("::error file="+(.locations.artifactLocation.uri|sub("^'"$(readlink -f .)"'"; ""))+",line="+(.locations.region.startLine|tostring)+",endLine="+(.locations.region.endLine|tostring)+",col="+(.locations.region.startColumn|tostring)+",endColumn="+(.locations.region.endColumn|tostring)+"::"+.message)' <build/reports/detekt/main.sarif
+ bugcount=$(jq -r '[.runs[].results[]] | length ' <build/reports/detekt/main.sarif)
+ echo "> This PR introduces **$bugcount** potential bug(s)." >>$GITHUB_STEP_SUMMARY
+ echo >>$GITHUB_STEP_SUMMARY
+ cat <build/reports/detekt/main.md >>$GITHUB_STEP_SUMMARY
+ [[ $bugcount != 0 ]] && exit 1 || echo ok.