Skip to content

Commit

Permalink
Merge pull request #22 from saveourtool/feature/migrate-diktat-2.x
Browse files Browse the repository at this point in the history
Migrate to Diktat 2.0
  • Loading branch information
nulls committed Dec 14, 2023
2 parents b3fda22 + ddeb3f1 commit bf9b672
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 832 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
*.bat text eol=crlf
*.cmd text eol=crlf
/bin/diktat text eol=lf diff=bash
4 changes: 2 additions & 2 deletions .github/workflows/asciidoctor-ghpages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# Includes the AsciiDoctor GitHub Pages Action to convert adoc files to
# html and publish to gh-pages branch.
Expand All @@ -26,5 +26,5 @@ jobs:
# source_dir: docs/ # default is .
# slides_build: true
pre_build: |
git rm -rf -- .idea/ bin/ .editorconfig .gitignore .gitattributes CODE_OF_CONDUCT.md LICENSE *.yml
git rm -rf -- .idea/ .editorconfig .gitignore .gitattributes CODE_OF_CONDUCT.md LICENSE *.yml
# post_build:
90 changes: 0 additions & 90 deletions .github/workflows/bindist-full.yml

This file was deleted.

78 changes: 0 additions & 78 deletions .github/workflows/bindist-thin.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/move-marketplace-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- id: tag
name: Tag name
Expand Down
22 changes: 2 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
name: Calculate the release version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

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

bindist-thin:
name: Binary distribution (thin)
needs: [ version ]
uses: ./.github/workflows/bindist-thin.yml
with:
release-version: ${{ needs.version.outputs.release-version }}
upload-url: ${{ needs.version.outputs.upload-url }}
secrets: inherit

bindist-full:
name: Binary distribution (full)
needs: [ version, bindist-thin ]
uses: ./.github/workflows/bindist-full.yml
with:
release-version: ${{ needs.version.outputs.release-version }}
upload-url: ${{ needs.version.outputs.upload-url }}
secrets: inherit

move-tag:
name: Move the Marketplace tag
needs: [ version, bindist-thin, bindist-full ]
needs: [ version ]
uses: ./.github/workflows/move-marketplace-tag.yml
with:
release-version: ${{ needs.version.outputs.release-version }}
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/bin/ktlint
/bin/diktat-*.jar
/bin/*.log
/bin/*.sarif
/.idea/
/#*#
*~
Expand Down
4 changes: 2 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: saveourtool/benedikt@v1
----
Expand Down Expand Up @@ -311,7 +311,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- id: diktat
uses: saveourtool/benedikt@v1
Expand Down
34 changes: 14 additions & 20 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,17 @@ runs:
steps:
- id: setup-java
if: ${{ inputs.java-version != null }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: '${{ inputs.java-distribution }}'
java-version: ${{ inputs.java-version }}

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

# GitHub seems to set `-e` internally, so don't fail immediately if diKTat
# returns a non-zero exit code but store the exit code in a variable for
Expand All @@ -101,15 +105,14 @@ runs:
# `steps.diktat.outputs.exit-code` variable.
- id: diktat
run: |
DIKTAT_ARGS=('--config=${{ inputs.config }}')
DIKTAT_ARGS=('--reporter=${{ inputs.reporter }}')
DIKTAT_ARGS=('--config', '${{ inputs.config }}', '--reporter', '${{ inputs.reporter }}')
if [[ '${{ inputs.color }}' != 'false' ]]
then
DIKTAT_ARGS+=('--color')
DIKTAT_ARGS+=('--color-name')
fi
if [[ '${{ inputs.debug }}' == 'true' ]]
then
DIKTAT_ARGS+=('--debug')
DIKTAT_ARGS+=('--log-level DEBUG')
fi
if [[ '${{ inputs.relative-paths }}' != 'false' ]]
then
Expand All @@ -119,7 +122,9 @@ runs:
set -o pipefail
IFS=$'\n'
INPUT_PATHS=(${{ inputs.input-paths }})
{ diktat --no-download-progress --verbose "${DIKTAT_ARGS[@]}" "${INPUT_PATHS[@]}" | tee diktat.log; } && exit_code=$? || exit_code=$?
DIKTAT_CMD=${GITHUB_WORKSPACE}/diktat
chmod +x ${DIKTAT_CMD}
{ ${DIKTAT_CMD} "${DIKTAT_ARGS[@]}" "${INPUT_PATHS[@]}" | tee diktat.log; } && exit_code=$? || exit_code=$?
echo "summary-line=$(tail -n1 diktat.log 2>/dev/null)" >>$GITHUB_OUTPUT
rm -f diktat.log
echo "exit-code=${exit_code}" >>$GITHUB_OUTPUT
Expand Down Expand Up @@ -160,7 +165,7 @@ runs:
if (( ${{ steps.diktat.outputs.exit-code }} <= 1 ))
then
diktat --version | awk '{ split($0, versions, ": *"); print " - _" versions[1] "_: **" versions[2] "**" }' >>${GITHUB_STEP_SUMMARY}
${GITHUB_WORKSPACE}/diktat --version | awk '{ split($0, versions, ": *"); print " - _" versions[1] "_: **" versions[2] "**" }' >>${GITHUB_STEP_SUMMARY}
fi
if (( ${{ steps.diktat.outputs.exit-code }} != 1 ))
Expand All @@ -172,17 +177,6 @@ runs:
fi
shell: bash

# We only need this step to run if diKTat failed to download external
# files (3), and we need to publish the logs.
- uses: actions/upload-artifact@v3
if: ${{ failure() && steps.diktat.outputs.exit-code == 3 }}
with:
name: download-logs
path: |
${{ github.action_path }}/bin/*-download.log
if-no-files-found: ignore
retention-days: 1

# When in SARIF reporting mode, upload SARIF reports to GitHub.
- id: upload-sarif
if: ${{ always() && steps.diktat.outputs.exit-code == 1 && inputs.reporter == 'sarif' }}
Expand Down
Loading

0 comments on commit bf9b672

Please sign in to comment.