Skip to content

Commit

Permalink
ci(detekt): update to java and add reviewdog
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron-Ritter committed Jan 22, 2024
1 parent 7bf0e8e commit 7e10c5e
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions .github/workflows/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ on:
env:
# Release tag associated with version of Detekt to be installed
# SARIF support (required for this workflow) was introduced in Detekt v1.15.0
DETEKT_RELEASE_TAG: 1.23.4
DETEKT_RELEASE_TAG: "1.23.4"
DETEKT_FILE_NAME: "detekt-cli-${DETEKT_VERSION}-all.jar"
DETEKT_URL: "https://github.com/detekt/detekt/releases/download/v${DETEKT_VERSION}/${DETEKT_FILE_NAME}"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand All @@ -48,27 +50,33 @@ jobs:
contents: read
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Sets up JDK
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

# Sets up the detekt cli
- name: Setup Detekt
run: |
dest=$( mktemp -d )
curl --request GET \
--url https://github.com/detekt/detekt/releases/download/v$DETEKT_RELEASE_TAG/detekt-cli-$DETEKT_RELEASE_TAG.zip \
--url ${DETEKT_URL} \
--silent \
--location \
--output $dest/detekt-cli-$DETEKT_RELEASE_TAG.zip
unzip $dest/detekt-cli-$DETEKT_RELEASE_TAG.zip -d $dest/
chmod a+x $dest/detekt-cli-$DETEKT_RELEASE_TAG/bin/detekt-cli
echo $dest/detekt-cli-$DETEKT_RELEASE_TAG/bin/ >> $GITHUB_PATH
--output $dest/${DETEKT_FILE_NAME}
mv $dest/${DETEKT_FILE_NAME} -d $dest/detekt.jar
# Performs static analysis using Detekt
- name: Run Detekt
continue-on-error: true
run: |
detekt-cli --input ${{ github.workspace }} --report sarif:${{ github.workspace }}/detekt.sarif.json
java -jar $dest/detekt.jar --input ${{ github.workspace }} --report sarif:${{ github.workspace }}/detekt.sarif.json
# Modifies the SARIF output produced by Detekt so that absolute URIs are relative
# This is so we can easily map results onto their source files
Expand All @@ -83,6 +91,16 @@ jobs:
${{ github.workspace }}/detekt.sarif.json
)" > ${{ github.workspace }}/detekt.sarif.json
# Sets up the reviewdog cli
- name: Setup reviewdog
uses: reviewdog/action-setup@v1

- name: Show reviewdog version
run: reviewdog -version

- name: Run reviewdog
run: reviewdog -f=sarif -diff="git diff" -name="detekt" < ${{ github.workspace }}/detekt.sarif.json

# Uploads results to GitHub repository using the upload-sarif action
- uses: github/codeql-action/upload-sarif@v3
with:
Expand Down

0 comments on commit 7e10c5e

Please sign in to comment.