diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 114871f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,21 +0,0 @@ -[*] -charset = utf-8 -indent_size = 4 -indent_style = space -insert_final_newline = true -max_line_length = 80 -trim_trailing_whitespace = true - -[{*.yaml,*.yml}] -indent_size = 2 -ij_visual_guides = none -ij_yaml_align_values_properties = do_not_align -ij_yaml_autoinsert_sequence_marker = true -ij_yaml_block_mapping_on_new_line = false -ij_yaml_indent_sequence_value = true -ij_yaml_keep_indents_on_empty_lines = false -ij_yaml_keep_line_breaks = true -ij_yaml_sequence_on_new_line = false -ij_yaml_space_before_colon = false -ij_yaml_spaces_within_braces = true -ij_yaml_spaces_within_brackets = true diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 0024d46..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -*.bat text eol=crlf -*.cmd text eol=crlf diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 9e4c020..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Please see the documentation for all configuration options: -# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates - -version: 2 -updates: - - package-ecosystem: "github-actions" - # Workflow files stored in the - # default location of `.github/workflows` - directory: "/" - schedule: - interval: "weekly" diff --git a/.github/workflows/asciidoctor-ghpages.yml b/.github/workflows/asciidoctor-ghpages.yml deleted file mode 100644 index 0f9493a..0000000 --- a/.github/workflows/asciidoctor-ghpages.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: GitHub Pages Publish - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - name: Publish GitHub Pages - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - # Includes the AsciiDoctor GitHub Pages Action to convert adoc files to - # html and publish to gh-pages branch. - - name: asciidoctor-ghpages - uses: manoelcampos/asciidoctor-ghpages-action@v2 - with: - pdf_build: true - # asciidoctor_params: --attribute=nofooter - asciidoctor_params: --attribute=allow-uri-read - # adoc_file_ext: .ascii # default is .adoc - # source_dir: docs/ # default is . - # slides_build: true - pre_build: | - git rm -rf -- .idea/ .editorconfig .gitignore .gitattributes CODE_OF_CONDUCT.md LICENSE *.yml - # post_build: diff --git a/.github/workflows/move-marketplace-tag.yml b/.github/workflows/move-marketplace-tag.yml deleted file mode 100644 index 67ca15e..0000000 --- a/.github/workflows/move-marketplace-tag.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Move the Marketplace tag - -on: - workflow_call: - inputs: - release-version: - required: true - type: string - -jobs: - dist: - name: Move the Marketplace tag - # See https://docs.github.com/en/actions/learn-github-actions/contexts#github-context - if: github.ref_type == 'tag' - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - id: tag - name: Tag name - run: | - VERSION_MAJOR="$(echo '${{ inputs.release-version }}' | sed -nE '/^([0-9]+)\.[^\.]+.*$/s//\1/p')" - echo "name=v${VERSION_MAJOR}" >>"${GITHUB_OUTPUT}" - shell: bash - - # The tag may not exist yet, so continue on error. - - name: Delete local tag - run: | - git tag -d '${{ steps.tag.outputs.name }}' - continue-on-error: true - shell: bash - - # The tag may not exist yet, so continue on error. - - name: Delete remote tag - run: | - git push --delete origin '${{ steps.tag.outputs.name }}' - continue-on-error: true - shell: bash - - - name: Create local tag - run: | - git tag '${{ steps.tag.outputs.name }}' - shell: bash - - - name: Push local tag - run: | - git push origin '${{ steps.tag.outputs.name }}' - shell: bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 5da3702..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Create a new release - -on: - workflow_dispatch: - pull_request: - push: - tags: - - 'v*.*' - # Ignore simple tags which are just "aliases" used by the Marketplace. - - '!v1' - - '!v2' - - '!v3' - - '!v4' - - '!v5' - - '!v6' - - '!v7' - - '!v8' - - '!v9' - -jobs: - version: - name: Calculate the release version - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - # Infer the release version. Assumes that tags are named `vX.Y.Z`. - - id: version - run: | - if [[ "${GITHUB_REF_TYPE}" == 'branch' ]] - then - RELEASE_VERSION="${GITHUB_SHA}" - else - RELEASE_VERSION="${GITHUB_REF#'refs/tags/v'}" - RELEASE_VERSION="${RELEASE_VERSION//'/'/_}" - fi - - echo "release-version=${RELEASE_VERSION}" >>"${GITHUB_OUTPUT}" - shell: bash - - - id: release - name: Create the release - if: ${{ github.ref_type == 'tag' }} - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ github.token }} - with: - tag_name: ${{ github.ref }} - release_name: v${{ steps.version.outputs.release-version }} - draft: false - prerelease: false - - outputs: - release-version: ${{ steps.version.outputs.release-version }} - upload-url: ${{ steps.release.outputs.upload_url }} - - move-tag: - name: Move the Marketplace tag - needs: [ version ] - uses: ./.github/workflows/move-marketplace-tag.yml - with: - release-version: ${{ needs.version.outputs.release-version }} - secrets: inherit diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 0e2b8aa..0000000 --- a/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/.idea/ -/#*# -*~ -/README.html -/README.pdf -*.swp diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 68ca042..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -Benedikt, a GitHub Action to check your code with diKTat diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 969e6ed..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,14 +0,0 @@ -# Code of Conduct - -This is a small code of conduct to have a good and friendly development in diKTat - -## Good behavior - -We expect everyone to love each other, be kind and polite. -Do not hate anyone for comments on the review or for bugs that he (or she) made in his code. - -## Unacceptable behavior - -But if you would like to bully some of our contributors - you are always welcome. -We love critics and do not like to be in comfort zone. -We can even organize some underground boxing match for you somewhere in Russia. \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index ef26969..0000000 --- a/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -The MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/README.adoc b/README.adoc deleted file mode 100644 index 6aeaf47..0000000 --- a/README.adoc +++ /dev/null @@ -1,261 +0,0 @@ -= A _GitHub Action_ to check your code with https://github.com/saveourtool/diktat[_diKTat_] -:toc: -:imagesdir: docs/images -:tip-caption: pass:[💡] - -[.float-group] --- -[.left] -image::https://img.shields.io/badge/License-MIT-yellow.svg[License: MIT,link="https://opensource.org/licenses/MIT"] - -[.left] -image::https://badgen.net/github/release/saveourtool/benedikt/latest?color=green[GitHub release,link=https://github.com/saveourtool/benedikt/releases/latest] - -[.left] -image::https://badgen.net/badge/icon/Ubuntu?icon=terminal&label&color=green[Ubuntu Linux] - -[.left] -image::https://badgen.net/badge/icon/macOS?icon=apple&label&color=green[macOS] - -[.left] -image::https://badgen.net/badge/icon/Windows?icon=windows&label&color=green[Windows] --- - -[TIP] -==== -An always updated version of this document is available -link:https://saveourtool.github.io/benedikt/ebook.pdf[here] as a PDF e-book. -==== - -== Features - -* Customizable `diktat-analysis.yml` xref:#config[location]. You can use the -rule set configuration with an alternate name or at a non-default location. - -* Customizable JVM xref:#java-setup[vendor and version]. You can run _diKTat_ -using a default JVM, or you can set up your own one. - -* Customizable xref:#reporter[reporter] (_SARIF_ or _Checkstyle_ XML). - -* Allows multiple xref:#input-paths[input paths]. If you have a multi-module -project and only wish to check certain directories or modules, you can configure -the action accordingly. - -* The last line of the log output reported to the summary page: -+ -image::check-summary.png[diKTat Check summary] - -== Usage - -In the simplest scenario, the action can be used without input parameters; you -just need to check out your code first, using -https://github.com/marketplace/actions/checkout[`actions/checkout`]: - -[source,yaml] ----- -jobs: - diktat_check: - name: 'diKTat Check' - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - uses: saveourtool/benedikt@v2 ----- - -== Configuration - -[#config] -=== `config`: custom configuration file - -* Default: `diktat-analysis.yml` -* Required: **no** - -You can override the name or the path of your YAML configuration file using the -`config` input parameter, e. g.: - -[source,yaml] ----- - - uses: saveourtool/benedikt@v2 - with: - config: path/to/diktat-analysis-custom.yml ----- - -[#reporter] -=== `reporter`: requesting a type of reporter - -If you wish, you can report errors in a different format. - -* Default: `sarif` -* Required: **no** -* Possible values: any of the following. - -** `sarif`: report errors in the -https://github.com/microsoft/sarif-tutorials/blob/main/docs/1-Introduction.md#what-is-sarif[_SARIF_] -format. The output file will be named `report.sarif` and automatically uploaded -to _GitHub_ using the https://github.com/github/codeql-action/tree/v2/upload-sarif[`upload-sarif`] -action. This will enable the check results to be shown as annotations in the -pull request: -+ -image::sarif-reporting-pr.png[diKTat SARIF reporting (Pull Request)] -+ -as well as in the _Code scanning alerts_ section of your repository: -+ -image::sarif-reporting-code-scanning-alerts.png[diKTat SARIF reporting (Code scanning alerts)] - -** `checkstyle`: this is the reporter of choice if you ever encounter issues -with the `sarif` reporter. Errors are reported in the -https://github.com/checkstyle/checkstyle[_Checkstyle-XML_] format to the file -named `checkstyle-report.xml`. The report is then consumed by the -https://github.com/reviewdog/reviewdog[`reviewdog`] tool and uploaded to -_GitHub_, resulting in code annotations similar to those produced by the `sarif` -reporter: -+ -image::checkstyle-xml-reporting.png[Checkstyle-XML reporting assisted by reviewdog] - -[#input-paths] -=== `input-paths`: custom source sets - -* Default: none -* Required: **no** - -One or more patterns which indicate the files or directories to check. Use a -multiline string to specify multiple inputs. - -* If an input is a path to a file, it is passed to _diKTat_ as-is: -+ -[source,yaml] ----- - - uses: saveourtool/benedikt@v2 - with: - input-paths: | - path/to/file.kt ----- - -* If an input is a path to a directory, the directory is recursively traversed, -and all `\*.kt` and `*.kts` files are passed to _diKTat_. -+ -[source,yaml] ----- - - uses: saveourtool/benedikt@v2 - with: - input-paths: | - src/main/kotlin - src/test/kotlin ----- -* If an input is an https://ant.apache.org/manual/dirtasks.html#patterns[_Ant_-style -path pattern] (such as `\\**/*.kt`), _diKTat_ expands it into the list of files -that match the path pattern. Path patterns may be negated, e. g.: -`!src/\**/*Test.kt` or `!src/\**/generated/**`. -+ -[source,yaml] ----- - - uses: saveourtool/benedikt@v2 - with: - input-paths: | - **/*.kt - **/*.kts - !**/generated/** ----- - -If this input parameter is not specified, this is equivalent to setting it to -`.`, meaning _diKTat_ will check all `\*.kt` and `*.kts` files in the project -directory unless configured otherwise. - -[#java-setup] -=== `java-distribution` and `java-version`: running _diKTat_ using a custom JVM - -It's possible to run _diKTat_ with a custom JVM using the -https://github.com/actions/setup-java[`actions/setup-java`] action. The -following input parameters may be specified: - -* `java-distribution`: the Java distribution, see the -https://github.com/actions/setup-java/blob/main/README.md#supported-distributions[list -of supported distributions]. - -** Default: `temurin` -** Required: **no** - -* `java-version`: the Java version to set up. Takes a whole or semver Java -version. See https://github.com/actions/setup-java/blob/main/README.md#supported-version-syntax[examples -of supported syntax]. - -** Default: none -** Required: **no** - -[NOTE] -Setting just the `java-distribution` property in order to use a custom -JDK is not sufficient: you'll need to set **both** `java-distribution` **and** -`java-version`: - -[source,yaml] ----- - - uses: saveourtool/benedikt@v2 - with: - java-distribution: 'temurin' - java-version: 17 ----- - -=== `fail-on-error`: suppressing lint errors - -* Default: `true` -* Required: **no** - -If `false`, the errors are still reported, but the step completes successfully. -If `true` (the default), then lint errors reported by _diKTat_ are considered -fatal (i.e. the current step terminates with a failure): - -[source,yaml] ----- - - uses: saveourtool/benedikt@v2 - with: - fail-on-error: true ----- - -[NOTE] - -This flag only affects the case when _diKTat_ exits with code **1**. Higher -link:https://diktat.saveourtool.com/diktat-cli/#exit-codes[exit -codes] are _always_ fatal. - -=== `debug`: enabling debug logging - -* Default: `false` -* Required: **no** - -Debug logging can be enabled by setting the `debug` input parameter to `true`: - -[source,yaml] ----- - - uses: saveourtool/benedikt@v2 - with: - debug: true ----- - -== Outputs - -The action returns the exit code of the command-line client using the -`exit-code` output parameter, e. g.: - -[source,yaml] ----- -jobs: - diktat_check: - name: 'diKTat Check' - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - id: diktat - uses: saveourtool/benedikt@v2 - - - name: 'Read the exit code of diKTat' - if: ${{ always() }} - run: echo "diKTat exited with code ${{ steps.diktat.outputs.exit-code }}" - shell: bash ----- - -The exit codes are documented -link:https://diktat.saveourtool.com/diktat-cli/#exit-codes[here]. diff --git a/README.html b/README.html new file mode 100644 index 0000000..5519a81 --- /dev/null +++ b/README.html @@ -0,0 +1,881 @@ + + + + + + + +A GitHub Action to check your code with diKTat + + + + + +
+
+
+
+
+
+
+License: MIT +
+
+
+
+GitHub release +
+
+
+
+Ubuntu Linux +
+
+
+
+macOS +
+
+
+
+Windows +
+
+
+
+
+ + + + + +
+
💡
+
+
+

An always updated version of this document is available +here as a PDF e-book.

+
+
+
+
+
+
+

Features

+
+
+
    +
  • +

    Customizable diktat-analysis.yml location. You can use the +rule set configuration with an alternate name or at a non-default location.

    +
  • +
  • +

    Customizable JVM vendor and version. You can run diKTat +using a default JVM, or you can set up your own one.

    +
  • +
  • +

    Customizable reporter (SARIF or Checkstyle XML).

    +
  • +
  • +

    Allows multiple input paths. If you have a multi-module +project and only wish to check certain directories or modules, you can configure +the action accordingly.

    +
  • +
  • +

    The last line of the log output reported to the summary page:

    +
    +
    +diKTat Check summary +
    +
    +
  • +
+
+
+
+
+

Usage

+
+
+

In the simplest scenario, the action can be used without input parameters; you +just need to check out your code first, using +actions/checkout:

+
+
+
+
jobs:
+  diktat_check:
+    name: 'diKTat Check'
+    runs-on: ubuntu-latest
+
+    steps:
+      - uses: actions/checkout@v4
+
+      - uses: saveourtool/benedikt@v2
+
+
+
+
+
+

Configuration

+
+
+

config: custom configuration file

+
+
    +
  • +

    Default: diktat-analysis.yml

    +
  • +
  • +

    Required: no

    +
  • +
+
+
+

You can override the name or the path of your YAML configuration file using the +config input parameter, e. g.:

+
+
+
+
      - uses: saveourtool/benedikt@v2
+        with:
+          config: path/to/diktat-analysis-custom.yml
+
+
+
+
+

reporter: requesting a type of reporter

+
+

If you wish, you can report errors in a different format.

+
+
+
    +
  • +

    Default: sarif

    +
  • +
  • +

    Required: no

    +
  • +
  • +

    Possible values: any of the following.

    +
    +
      +
    • +

      sarif: report errors in the +SARIF +format. The output file will be named report.sarif and automatically uploaded +to GitHub using the upload-sarif +action. This will enable the check results to be shown as annotations in the +pull request:

      +
      +
      +diKTat SARIF reporting (Pull Request) +
      +
      +
      +

      as well as in the Code scanning alerts section of your repository:

      +
      +
      +
      +diKTat SARIF reporting (Code scanning alerts) +
      +
      +
    • +
    • +

      checkstyle: this is the reporter of choice if you ever encounter issues +with the sarif reporter. Errors are reported in the +Checkstyle-XML format to the file +named checkstyle-report.xml. The report is then consumed by the +reviewdog tool and uploaded to +GitHub, resulting in code annotations similar to those produced by the sarif +reporter:

      +
      +
      +Checkstyle-XML reporting assisted by reviewdog +
      +
      +
    • +
    +
    +
  • +
+
+
+
+

input-paths: custom source sets

+
+
    +
  • +

    Default: none

    +
  • +
  • +

    Required: no

    +
  • +
+
+
+

One or more patterns which indicate the files or directories to check. Use a +multiline string to specify multiple inputs.

+
+
+
    +
  • +

    If an input is a path to a file, it is passed to diKTat as-is:

    +
    +
    +
          - uses: saveourtool/benedikt@v2
    +        with:
    +          input-paths: |
    +            path/to/file.kt
    +
    +
    +
  • +
  • +

    If an input is a path to a directory, the directory is recursively traversed, +and all *.kt and *.kts files are passed to diKTat.

    +
    +
    +
          - uses: saveourtool/benedikt@v2
    +        with:
    +          input-paths: |
    +            src/main/kotlin
    +            src/test/kotlin
    +
    +
    +
  • +
  • +

    If an input is an Ant-style +path pattern (such as **/*.kt), diKTat expands it into the list of files +that match the path pattern. Path patterns may be negated, e. g.: +!src/**/*Test.kt or !src/**/generated/**.

    +
    +
    +
          - uses: saveourtool/benedikt@v2
    +        with:
    +          input-paths: |
    +            **/*.kt
    +            **/*.kts
    +            !**/generated/**
    +
    +
    +
  • +
+
+
+

If this input parameter is not specified, this is equivalent to setting it to +., meaning diKTat will check all *.kt and *.kts files in the project +directory unless configured otherwise.

+
+
+
+

java-distribution and java-version: running diKTat using a custom JVM

+
+

It’s possible to run diKTat with a custom JVM using the +actions/setup-java action. The +following input parameters may be specified:

+
+
+
    +
  • +

    java-distribution: the Java distribution, see the +list +of supported distributions.

    +
    +
      +
    • +

      Default: temurin

      +
    • +
    • +

      Required: no

      +
    • +
    +
    +
  • +
  • +

    java-version: the Java version to set up. Takes a whole or semver Java +version. See examples +of supported syntax.

    +
    +
      +
    • +

      Default: none

      +
    • +
    • +

      Required: no

      +
    • +
    +
    +
  • +
+
+
+ + + + + +
+
Note
+
+Setting just the java-distribution property in order to use a custom +JDK is not sufficient: you’ll need to set both java-distribution and +java-version: +
+
+
+
+
      - uses: saveourtool/benedikt@v2
+        with:
+          java-distribution: 'temurin'
+          java-version: 17
+
+
+
+
+

fail-on-error: suppressing lint errors

+
+
    +
  • +

    Default: true

    +
  • +
  • +

    Required: no

    +
  • +
+
+
+

If false, the errors are still reported, but the step completes successfully. +If true (the default), then lint errors reported by diKTat are considered +fatal (i.e. the current step terminates with a failure):

+
+
+
+
      - uses: saveourtool/benedikt@v2
+        with:
+          fail-on-error: true
+
+
+
+ + + + + +
+
Note
+
+This flag only affects the case when diKTat exits with code 1. Higher +exit +codes are always fatal. +
+
+
+
+

debug: enabling debug logging

+
+
    +
  • +

    Default: false

    +
  • +
  • +

    Required: no

    +
  • +
+
+
+

Debug logging can be enabled by setting the debug input parameter to true:

+
+
+
+
      - uses: saveourtool/benedikt@v2
+        with:
+          debug: true
+
+
+
+
+
+
+

Outputs

+
+
+

The action returns the exit code of the command-line client using the +exit-code output parameter, e. g.:

+
+
+
+
jobs:
+  diktat_check:
+    name: 'diKTat Check'
+    runs-on: ubuntu-latest
+
+    steps:
+      - uses: actions/checkout@v4
+
+      - id: diktat
+        uses: saveourtool/benedikt@v2
+
+      - name: 'Read the exit code of diKTat'
+        if: ${{ always() }}
+        run: echo "diKTat exited with code ${{ steps.diktat.outputs.exit-code }}"
+        shell: bash
+
+
+
+

The exit codes are documented +here.

+
+
+
+
+ + + \ No newline at end of file diff --git a/action.yml b/action.yml deleted file mode 100644 index 58f7082..0000000 --- a/action.yml +++ /dev/null @@ -1,214 +0,0 @@ -# yaml-language-server: $schema=https://json.schemastore.org/github-action.json - -name: 'Benedi.kt' -author: 'The diKTat Team' -description: 'A GitHub Action to check your code with diKTat' - -# Note: when inverting the default values of boolean flags, be sure to also -# invert the values they're compared to, i.e. if a certain flag is `true` by -# default, then it should be compared with `false`, because `false` is the only -# value which users of our action can explicitly set. Cases when a flag is -# merely inset (i.e. is not equal to either `true` or `false`) are quite common. -inputs: - config: - description: > - The location of the YAML configuration file. By default, - diktat-analysis.yml in the current directory is used. - default: 'diktat-analysis.yml' - required: false - reporter: - description: > - The reporter to use, one of: "sarif" (the default) or "checkstyle". - default: 'sarif' - required: false - input-paths: - description: > - One or more patterns which indicate the files or directories to check. - Use a multiline string to specify multiple inputs. - - If an input is a path to a file, it is passed to diKTat as-is. - - If an input is a path to a directory, the directory is recursively - traversed, and all *.kt and *.kts files are passed to diKTat. - - If an input is an Ant-like path pattern (such as "**/*.kt"), diKTat - expands it into the list of files that match the path pattern. Path - patterns may be negated, e. g.: "!src/**/*Test.kt" or - "!src/**/generated/**". - required: false - java-distribution: - description: > - The Java distribution. See the list of supported distributions at - . - The default is "temurin". - - Note that setting just this property in order to use a custom JDK is not - sufficient: please set "java-version", too. - default: 'temurin' - required: false - java-version: - description: > - The Java version to set up. Takes a whole or semver Java version. See - examples of supported syntax at - . - required: false - debug: - description: > - Whether debug logging should be enabled - default: ${{ false }} - required: false - fail-on-error: - description: > - Whether linter errors are considered fatal (the default is true) - default: ${{ true }} - required: false - -outputs: - exit-code: - description: "The exit code of diKTat" - value: ${{ steps.diktat.outputs.exit-code }} - -runs: - using: "composite" - steps: - - id: setup-java - if: ${{ inputs.java-version != null }} - uses: actions/setup-java@v4 - with: - distribution: '${{ inputs.java-distribution }}' - java-version: ${{ inputs.java-version }} - - - id: download-diktat - uses: robinraju/release-downloader@v1.8 - with: - repository: "nulls/diktat" - tag: "v2.0.3" - 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 - # further processing. - # - # This step is always successful but records the exit code in the - # `steps.diktat.outputs.exit-code` variable. - - id: diktat - run: | - if [[ '${{ inputs.debug }}' == 'true' ]] - then - set -x - fi - DIKTAT_ARGS=('--config' '${{ inputs.config }}' '--reporter' '${{ inputs.reporter }}') - if [[ '${{ inputs.reporter }}' == 'sarif' ]] - then - report_file=${GITHUB_WORKSPACE}/report.sarif - elif [[ '${{ inputs.reporter }}' == 'checkstyle' ]] - then - report_file=${GITHUB_WORKSPACE}/checkstyle-report.xml - else - echo "`reporter` should be set to `sarif` or `checkstyle`" - exit 1 - fi - DIKTAT_ARGS+=('--output' '${report_file}') - - if [[ '${{ inputs.debug }}' == 'true' ]] - then - DIKTAT_ARGS+=('--log-level' 'DEBUG') - fi - - set -o pipefail - IFS=$'\n' - INPUT_PATHS=(${{ inputs.input-paths }}) - DIKTAT_CMD=${GITHUB_WORKSPACE}/diktat - chmod +x ${DIKTAT_CMD} - { ${DIKTAT_CMD} "${DIKTAT_ARGS[@]}" "${INPUT_PATHS[@]}" | tee diktat.log; } && exit_code=$? || exit_code=$? - total_lines=$(wc -l diktat.log | cut -d ' ' -f1) - summary_line_number=$(grep -n 'Summary error count (descending) by rule:' diktat.log | cut -d: -f1) - summary_line=$(tail -n $((total_lines - summary_line_number)) diktat.log | sed -e 's/^ //g' | awk '{ printf("%s,", $0) }' | sed -e 's/,$//g') - echo "summary-line=${summary_line}" >>$GITHUB_OUTPUT - rm -f diktat.log - echo "exit-code=${exit_code}" >>$GITHUB_OUTPUT - env: - GITHUB_TOKEN: ${{ github.token }} - shell: bash - - # Creates a summary report and fails the job if necessary. - # - # If `diktat` exited with code 1 (linter errors), return 0 or 1 depending - # on the value of the `fail-on-error` flag. If the exit code is 2 or - # greater, return it as-is, ignoring the flag. - # - # Note: BSD `awk` apparently doesn't understand `\\s`, that's why we're - # splitting on `: *` (a colon followed by a zero or more space characters). - - id: diktat-summary - if: ${{ always() }} - run: | - if (( ${{ steps.diktat.outputs.exit-code }} == 0 )) - then - status_icon=':heavy_check_mark:' - message='completed successfully' - else - status_icon=':x:' - message='exited with code **${{ steps.diktat.outputs.exit-code }}**' - fi - - diktat='[_diKTat_](https://github.com/saveourtool/diktat)' - - echo "${status_icon} ${diktat} ${message}" >>${GITHUB_STEP_SUMMARY} - - if (( ${{ steps.diktat.outputs.exit-code }} != 0 )) - then - echo '```console' >>${GITHUB_STEP_SUMMARY} - echo "${{ steps.diktat.outputs.summary-line }}" | xargs -d ',' -n1 echo >>${GITHUB_STEP_SUMMARY} - echo '```' >>${GITHUB_STEP_SUMMARY} - fi - - if (( ${{ steps.diktat.outputs.exit-code }} <= 1 )) - then - ${GITHUB_WORKSPACE}/diktat --version | awk '{ split($0, versions, ": *"); print " - _" versions[1] "_: **" versions[2] "**" }' >>${GITHUB_STEP_SUMMARY} - fi - - if (( ${{ steps.diktat.outputs.exit-code }} != 1 )) - then - exit ${{ steps.diktat.outputs.exit-code }} - elif [[ '${{ inputs.fail-on-error }}' != 'false' ]] - then - exit 1 - fi - shell: bash - - # When in SARIF reporting mode, upload SARIF reports to GitHub. - - id: upload-sarif - if: ${{ always() && steps.diktat.outputs.exit-code == 1 && inputs.reporter == 'sarif' }} - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: ${{ github.workspace }}/report.sarif - - # Alternatively, when in Checkstyle reporting mode, upload Checkstyle XML - # using `reviewdog`. - # - # `reviewdog` doesn't play well with manual runs (`workflow_dispatch`): - # it fails with - # - # post failed for %s: failed to create check: POST https://api.github.com/repos/%s/%s/check-runs: 422 No commit found for SHA: [] - - id: reviewdog-install - if: ${{ always() && steps.diktat.outputs.exit-code == 1 && inputs.reporter == 'checkstyle' && github.event_name != 'workflow_dispatch' }} - uses: reviewdog/action-setup@v1 - - - id: reviewdog - if: ${{ always() && steps.diktat.outputs.exit-code == 1 && inputs.reporter == 'checkstyle' && github.event_name != 'workflow_dispatch' }} - run: | - if [[ '${{ github.event_name }}' == 'pull_request' ]] - then - reviewdog_reporter='github-pr-check' - else - reviewdog_reporter='github-check' - fi - - reviewdog -f=checkstyle -fail-on-error=false -level=info -name='diKTat errors reported by reviewdog' -reporter="${reviewdog_reporter}" <${GITHUB_WORKSPACE}/checkstyle-report.xml - env: - REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }} - shell: bash - -branding: - icon: 'check-circle' - color: 'purple' diff --git a/ebook.pdf b/ebook.pdf new file mode 100644 index 0000000..20b5036 Binary files /dev/null and b/ebook.pdf differ diff --git a/index.html b/index.html new file mode 120000 index 0000000..b70e3e8 --- /dev/null +++ b/index.html @@ -0,0 +1 @@ +README.html \ No newline at end of file