From 8fce67fe9c5192724b7091f6983261d92ceea21e Mon Sep 17 00:00:00 2001 From: Alexey Egin <10329086+alaegin@users.noreply.github.com> Date: Fri, 15 Jul 2022 15:05:00 +0300 Subject: [PATCH] Detekt 1.21.0-RC2 (#40) * Add --build-upon-default-config and --all-rules arguments * Update detekt version Co-authored-by: Alexey Egin --- Dockerfile | 4 ++-- README.md | 32 ++++++++++++++++++++++++++++---- action.yml | 10 ++++++++++ entrypoint.sh | 9 ++++++++- 4 files changed, 48 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index e7f591b..ba7cd86 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ FROM alpine:3.13.1 # https://github.com/detekt/detekt/releases -ARG DETEKT_VERSION="1.20.0" +ARG DETEKT_VERSION="1.21.0-RC2" # https://github.com/reviewdog/reviewdog/releases -ARG REVIEWDOG_VERSION="0.14.0" +ARG REVIEWDOG_VERSION="0.14.1" ARG DETEKT_FILE_NAME="detekt-cli-${DETEKT_VERSION}-all.jar" ARG DETEKT_URL="https://github.com/detekt/detekt/releases/download/v${DETEKT_VERSION}/${DETEKT_FILE_NAME}" diff --git a/README.md b/README.md index 7645bfc..bf6380f 100644 --- a/README.md +++ b/README.md @@ -2,17 +2,21 @@ ![GitHub release (latest by date)](https://img.shields.io/github/v/release/alaegin/Detekt-Action) -This action allows running [detekt](https://github.com/detekt/detekt) with [reviewdog](https://github.com/reviewdog/reviewdog) on pull requests +This action allows running [detekt](https://github.com/detekt/detekt) +with [reviewdog](https://github.com/reviewdog/reviewdog) on pull requests ## Examples ### `github-pr-check` - used by default + `reviewdog_reporter: github-pr-check` -`github-pr-check` reporter reports results to [GitHub Checks](https://github.com/reviewdog/reviewdog#reporter-github-checks--reportergithub-pr-check) +`github-pr-check` reporter reports results +to [GitHub Checks](https://github.com/reviewdog/reviewdog#reporter-github-checks--reportergithub-pr-check) ![Example comment made by the action with github-pr-check](./assets/screenshot_pr_check.png) ### `github-pr-review` + `reviewdog_reporter: github-pr-review` `github-pr-review` reporter reports results to GitHub PullRequest review comments. @@ -89,13 +93,31 @@ To enable declare `detekt_parallel: true` [Read more](https://detekt.github.io/detekt/cli.html) +### `detekt_build_upon_default_config` + +Optional. Preconfigures detekt with a bunch of rules and some opinionated defaults +for you. +Allows additional provided configurations to override the +defaults. +To enable declare `detekt_build_upon_default_config: true` + +[Read more](https://detekt.github.io/detekt/cli.html) + +### `detekt_all_rules` + +Optional. Activates all available (even unstable) rules. +The default value is empty. +To enable declare `detekt_all_rules: true` + +[Read more](https://detekt.github.io/detekt/cli.html) + ## Usage Following example runs detekt with ```yml name: reviewdog -on: [pull_request] +on: [ pull_request ] jobs: detekt: @@ -110,14 +132,16 @@ jobs: ref: ${{ github.head_ref }} - name: detekt - uses: alaegin/Detekt-Action@v1.20.0 + uses: alaegin/Detekt-Action@v1.21.0-RC2 with: github_token: ${{ secrets.github_token }} detekt_config: detekt-config.yml # Change config path ``` ## License + [MIT](LICENSE) ## Inspiration + * [action-ktlint](https://github.com/ScaCap/action-ktlint) - Action for running ktlint with reviewdog diff --git a/action.yml b/action.yml index 7f2a5ad..e2eba41 100644 --- a/action.yml +++ b/action.yml @@ -46,6 +46,14 @@ inputs: detekt_parallel: description: 'Executes detekt in parallel' required: false + detekt_build_upon_default_config: + description: 'Preconfigures detekt with a bunch of rules and some opinionated defaults + for you. Allows additional provided configurations to override the + defaults.' + required: false + detekt_all_rules: + description: 'Activates all available (even unstable) rules.' + required: false runs: using: 'docker' image: 'Dockerfile' @@ -60,6 +68,8 @@ runs: - ${{ inputs.detekt_plugins }} - ${{ inputs.detekt_baseline }} - ${{ inputs.detekt_parallel }} + - ${{ inputs.detekt_build_upon_default_config }} + - ${{ inputs.detekt_all_rules }} branding: icon: 'check-square' color: 'orange' diff --git a/entrypoint.sh b/entrypoint.sh index a963100..0b6eb15 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -14,7 +14,6 @@ fi export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" detekt_command="java -jar /opt/detekt.jar " -detekt_command+="--fail-fast " detekt_command+="--config ${INPUT_DETEKT_CONFIG} " detekt_command+="--report xml:detekt_report.xml " detekt_command+="--excludes ${INPUT_DETEKT_EXCLUDES} " @@ -33,6 +32,14 @@ if [ -n "$INPUT_DETEKT_PARALLEL" ]; then detekt_command+="--parallel " fi +if [ -n "$DETEKT_INPUT_BUILD_UPON_DEFAULT_CONFIG" ]; then + detekt_command+="--build-upon-default-config " +fi + +if [ -n "$DETEKT_ALL_RULES" ]; then + detekt_command+="--all-rules " +fi + echo "$detekt_command" eval "$detekt_command"