Skip to content

Commit bf9b672

Browse files
authored
Merge pull request #22 from saveourtool/feature/migrate-diktat-2.x
Migrate to Diktat 2.0
2 parents b3fda22 + ddeb3f1 commit bf9b672

File tree

11 files changed

+21
-832
lines changed

11 files changed

+21
-832
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
*.bat text eol=crlf
22
*.cmd text eol=crlf
3-
/bin/diktat text eol=lf diff=bash

.github/workflows/asciidoctor-ghpages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616

1717
# Includes the AsciiDoctor GitHub Pages Action to convert adoc files to
1818
# html and publish to gh-pages branch.
@@ -26,5 +26,5 @@ jobs:
2626
# source_dir: docs/ # default is .
2727
# slides_build: true
2828
pre_build: |
29-
git rm -rf -- .idea/ bin/ .editorconfig .gitignore .gitattributes CODE_OF_CONDUCT.md LICENSE *.yml
29+
git rm -rf -- .idea/ .editorconfig .gitignore .gitattributes CODE_OF_CONDUCT.md LICENSE *.yml
3030
# post_build:

.github/workflows/bindist-full.yml

Lines changed: 0 additions & 90 deletions
This file was deleted.

.github/workflows/bindist-thin.yml

Lines changed: 0 additions & 78 deletions
This file was deleted.

.github/workflows/move-marketplace-tag.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1919

2020
- id: tag
2121
name: Tag name

.github/workflows/release.yml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
name: Calculate the release version
2323
runs-on: ubuntu-latest
2424
steps:
25-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v4
2626

2727
# Infer the release version. Assumes that tags are named `vX.Y.Z`.
2828
- id: version
@@ -54,27 +54,9 @@ jobs:
5454
release-version: ${{ steps.version.outputs.release-version }}
5555
upload-url: ${{ steps.release.outputs.upload_url }}
5656

57-
bindist-thin:
58-
name: Binary distribution (thin)
59-
needs: [ version ]
60-
uses: ./.github/workflows/bindist-thin.yml
61-
with:
62-
release-version: ${{ needs.version.outputs.release-version }}
63-
upload-url: ${{ needs.version.outputs.upload-url }}
64-
secrets: inherit
65-
66-
bindist-full:
67-
name: Binary distribution (full)
68-
needs: [ version, bindist-thin ]
69-
uses: ./.github/workflows/bindist-full.yml
70-
with:
71-
release-version: ${{ needs.version.outputs.release-version }}
72-
upload-url: ${{ needs.version.outputs.upload-url }}
73-
secrets: inherit
74-
7557
move-tag:
7658
name: Move the Marketplace tag
77-
needs: [ version, bindist-thin, bindist-full ]
59+
needs: [ version ]
7860
uses: ./.github/workflows/move-marketplace-tag.yml
7961
with:
8062
release-version: ${{ needs.version.outputs.release-version }}

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/bin/ktlint
2-
/bin/diktat-*.jar
3-
/bin/*.log
4-
/bin/*.sarif
51
/.idea/
62
/#*#
73
*~

README.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
runs-on: ubuntu-latest
6060
6161
steps:
62-
- uses: actions/checkout@v3
62+
- uses: actions/checkout@v4
6363
6464
- uses: saveourtool/benedikt@v1
6565
----
@@ -311,7 +311,7 @@ jobs:
311311
runs-on: ubuntu-latest
312312
313313
steps:
314-
- uses: actions/checkout@v3
314+
- uses: actions/checkout@v4
315315
316316
- id: diktat
317317
uses: saveourtool/benedikt@v1

action.yml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,17 @@ runs:
8585
steps:
8686
- id: setup-java
8787
if: ${{ inputs.java-version != null }}
88-
uses: actions/setup-java@v3
88+
uses: actions/setup-java@v4
8989
with:
9090
distribution: '${{ inputs.java-distribution }}'
9191
java-version: ${{ inputs.java-version }}
9292

93-
- run: echo '${{ github.action_path }}/bin' >>${GITHUB_PATH}
94-
shell: bash
93+
- id: download-diktat
94+
uses: robinraju/release-downloader@v1.8
95+
with:
96+
repository: "saveourtool/diktat"
97+
tag: "v2.0.0"
98+
fileName: "diktat"
9599

96100
# GitHub seems to set `-e` internally, so don't fail immediately if diKTat
97101
# returns a non-zero exit code but store the exit code in a variable for
@@ -101,15 +105,14 @@ runs:
101105
# `steps.diktat.outputs.exit-code` variable.
102106
- id: diktat
103107
run: |
104-
DIKTAT_ARGS=('--config=${{ inputs.config }}')
105-
DIKTAT_ARGS=('--reporter=${{ inputs.reporter }}')
108+
DIKTAT_ARGS=('--config', '${{ inputs.config }}', '--reporter', '${{ inputs.reporter }}')
106109
if [[ '${{ inputs.color }}' != 'false' ]]
107110
then
108-
DIKTAT_ARGS+=('--color')
111+
DIKTAT_ARGS+=('--color-name')
109112
fi
110113
if [[ '${{ inputs.debug }}' == 'true' ]]
111114
then
112-
DIKTAT_ARGS+=('--debug')
115+
DIKTAT_ARGS+=('--log-level DEBUG')
113116
fi
114117
if [[ '${{ inputs.relative-paths }}' != 'false' ]]
115118
then
@@ -119,7 +122,9 @@ runs:
119122
set -o pipefail
120123
IFS=$'\n'
121124
INPUT_PATHS=(${{ inputs.input-paths }})
122-
{ diktat --no-download-progress --verbose "${DIKTAT_ARGS[@]}" "${INPUT_PATHS[@]}" | tee diktat.log; } && exit_code=$? || exit_code=$?
125+
DIKTAT_CMD=${GITHUB_WORKSPACE}/diktat
126+
chmod +x ${DIKTAT_CMD}
127+
{ ${DIKTAT_CMD} "${DIKTAT_ARGS[@]}" "${INPUT_PATHS[@]}" | tee diktat.log; } && exit_code=$? || exit_code=$?
123128
echo "summary-line=$(tail -n1 diktat.log 2>/dev/null)" >>$GITHUB_OUTPUT
124129
rm -f diktat.log
125130
echo "exit-code=${exit_code}" >>$GITHUB_OUTPUT
@@ -160,7 +165,7 @@ runs:
160165
161166
if (( ${{ steps.diktat.outputs.exit-code }} <= 1 ))
162167
then
163-
diktat --version | awk '{ split($0, versions, ": *"); print " - _" versions[1] "_: **" versions[2] "**" }' >>${GITHUB_STEP_SUMMARY}
168+
${GITHUB_WORKSPACE}/diktat --version | awk '{ split($0, versions, ": *"); print " - _" versions[1] "_: **" versions[2] "**" }' >>${GITHUB_STEP_SUMMARY}
164169
fi
165170
166171
if (( ${{ steps.diktat.outputs.exit-code }} != 1 ))
@@ -172,17 +177,6 @@ runs:
172177
fi
173178
shell: bash
174179

175-
# We only need this step to run if diKTat failed to download external
176-
# files (3), and we need to publish the logs.
177-
- uses: actions/upload-artifact@v3
178-
if: ${{ failure() && steps.diktat.outputs.exit-code == 3 }}
179-
with:
180-
name: download-logs
181-
path: |
182-
${{ github.action_path }}/bin/*-download.log
183-
if-no-files-found: ignore
184-
retention-days: 1
185-
186180
# When in SARIF reporting mode, upload SARIF reports to GitHub.
187181
- id: upload-sarif
188182
if: ${{ always() && steps.diktat.outputs.exit-code == 1 && inputs.reporter == 'sarif' }}

0 commit comments

Comments
 (0)