From 8bb0abd40b32bb493e6f0166a941a30d5c30c873 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 2 May 2022 20:41:49 +0900 Subject: [PATCH 01/46] README: Add "permissions" field to example of usage To request explicitly the minimum required permissions for this action to GitHub Actions, this adds "permissions" field to the example of job definition. This does not request users to make their default setting permisssive. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 631baef..0ab03ef 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,9 @@ You can create [RuboCop Configuration](https://docs.rubocop.org/rubocop/configur ```yml name: reviewdog on: [pull_request] +permissions: + contents: read + pull-requests: write jobs: rubocop: name: runner / rubocop From 371f34460c9acf4784909a8cfe8536ca1de18667 Mon Sep 17 00:00:00 2001 From: Bertrand Paquet Date: Thu, 2 Jun 2022 22:36:30 +0200 Subject: [PATCH 02/46] Avoid nil pointer exception with correctable offense without corrector This can happen when the offense is in rubocop cache or in parallel mode --- rdjson_formatter/rdjson_formatter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdjson_formatter/rdjson_formatter.rb b/rdjson_formatter/rdjson_formatter.rb index c3607eb..161da38 100644 --- a/rdjson_formatter/rdjson_formatter.rb +++ b/rdjson_formatter/rdjson_formatter.rb @@ -56,7 +56,7 @@ def build_diagnostic(file, offense) original_output: offense.to_s } - diagnostic[:suggestions] = build_suggestions(offense) if offense.correctable? + diagnostic[:suggestions] = build_suggestions(offense) if offense.correctable? && offense.corrector diagnostic end From 0264fa15698a9018bb4efcd58416f4ca9b0ec563 Mon Sep 17 00:00:00 2001 From: ydah <13041216+ydah@users.noreply.github.com> Date: Sat, 7 Jan 2023 21:17:11 +0900 Subject: [PATCH 03/46] Fix an indentation for script.sh This PR is fx an indentation for script.sh --- script.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/script.sh b/script.sh index 6d9e36b..0aa6fbf 100755 --- a/script.sh +++ b/script.sh @@ -28,15 +28,15 @@ if [ "${INPUT_SKIP_INSTALL}" = "false" ]; then # left it empty otherwise, so no version will be passed if [ -n "$RUBOCOP_GEMFILE_VERSION" ]; then RUBOCOP_VERSION=$RUBOCOP_GEMFILE_VERSION - else - printf "Cannot get the rubocop's version from Gemfile.lock. The latest version will be installed." - fi else - printf 'Gemfile.lock not found. The latest version will be installed.' - fi + printf "Cannot get the rubocop's version from Gemfile.lock. The latest version will be installed." + fi else - # set desired rubocop version - RUBOCOP_VERSION=$INPUT_RUBOCOP_VERSION + printf 'Gemfile.lock not found. The latest version will be installed.' + fi + else + # set desired rubocop version + RUBOCOP_VERSION=$INPUT_RUBOCOP_VERSION fi gem install -N rubocop --version "${RUBOCOP_VERSION}" @@ -58,11 +58,11 @@ if [ "${INPUT_SKIP_INSTALL}" = "false" ]; then # left it empty otherwise, so no version will be passed if [ -n "$RUBOCOP_EXTENSION_GEMFILE_VERSION" ]; then RUBOCOP_EXTENSION_VERSION=$RUBOCOP_EXTENSION_GEMFILE_VERSION - else - printf "Cannot get the rubocop extension version from Gemfile.lock. The latest version will be installed." - fi else - printf 'Gemfile.lock not found. The latest version will be installed.' + printf "Cannot get the rubocop extension version from Gemfile.lock. The latest version will be installed." + fi + else + printf 'Gemfile.lock not found. The latest version will be installed.' fi else # set desired rubocop extension version From 81ea5390222e14456b6355f2c7c2866e48d626a8 Mon Sep 17 00:00:00 2001 From: Sergey Semyonov Date: Wed, 11 Jan 2023 01:16:36 +0400 Subject: [PATCH 04/46] Change `original_output` in `RdjsonFormatter` Change `original_output`, adding file. The field is printed by reviewdog on running the action with github-pr-review reporter. Before, it did not contain file, thus messages were not fully informative. E.g. ``` C: 30: 54: Rails/AttributeDefaultBlockValue: Pass method in a block to `:default` option. ``` This change fixes the field, adding file: ``` app/models/user.rb:30:54: C: Rails/AttributeDefaultBlockValue: Pass method in a block to `:default` option. ``` --- rdjson_formatter/rdjson_formatter.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/rdjson_formatter/rdjson_formatter.rb b/rdjson_formatter/rdjson_formatter.rb index 161da38..c003357 100644 --- a/rdjson_formatter/rdjson_formatter.rb +++ b/rdjson_formatter/rdjson_formatter.rb @@ -3,6 +3,8 @@ # https://docs.rubocop.org/rubocop/formatters.html # rubocop:disable Metrics/AbcSize, Metrics/MethodLength class RdjsonFormatter < RuboCop::Formatter::BaseFormatter + include RuboCop::PathUtil + def started(_target_files) @rdjson = { source: { @@ -53,7 +55,7 @@ def build_diagnostic(file, offense) code: { value: code }, - original_output: offense.to_s + original_output: build_original_output(file, offense) } diagnostic[:suggestions] = build_suggestions(offense) if offense.correctable? && offense.corrector @@ -119,5 +121,19 @@ def convert_path(path) path end end + + # @param [String] file + # @param [RuboCop::Cop::Offense] offense + # @return [String] + def build_original_output(file, offense) + format( + '%s:%d:%d: %s: %s', + path: smart_path(file), + line: offense.line, + column: offense.real_column, + severity: offense.severity.code, + message: offense.message + ) + end end # rubocop:enable Metrics/AbcSize, Metrics/MethodLength From 02246e326a5e660b3f84419750cb6c99a63cf7fc Mon Sep 17 00:00:00 2001 From: Sergey Semyonov Date: Wed, 11 Jan 2023 12:13:54 +0400 Subject: [PATCH 05/46] Fix test/rdjson_formatter/test.sh --- test/rdjson_formatter/testdata/result.ok | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/rdjson_formatter/testdata/result.ok b/test/rdjson_formatter/testdata/result.ok index 314ca72..29c5682 100644 --- a/test/rdjson_formatter/testdata/result.ok +++ b/test/rdjson_formatter/testdata/result.ok @@ -23,7 +23,7 @@ "code": { "value": "Style/FrozenStringLiteralComment" }, - "original_output": "C: 1: 1: Style/FrozenStringLiteralComment: Missing frozen string literal comment.", + "original_output": "test/rdjson_formatter/testdata/correctable_offenses.rb:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.", "suggestions": [ { "range": { @@ -59,7 +59,7 @@ "code": { "value": "Layout/SpaceAfterComma" }, - "original_output": "C: 1: 12: Layout/SpaceAfterComma: Space missing after comma.", + "original_output": "test/rdjson_formatter/testdata/correctable_offenses.rb:1:12: C: Layout/SpaceAfterComma: Space missing after comma.", "suggestions": [ { "range": { @@ -95,7 +95,7 @@ "code": { "value": "Layout/ExtraSpacing" }, - "original_output": "C: 2: 4: Layout/ExtraSpacing: Unnecessary spacing detected.", + "original_output": "test/rdjson_formatter/testdata/correctable_offenses.rb:2:4: C: Layout/ExtraSpacing: Unnecessary spacing detected.", "suggestions": [ { "range": { @@ -131,7 +131,7 @@ "code": { "value": "Layout/SpaceAroundOperators" }, - "original_output": "C: 2: 13: Layout/SpaceAroundOperators: Surrounding space missing for operator `+`.", + "original_output": "test/rdjson_formatter/testdata/correctable_offenses.rb:2:13: C: Layout/SpaceAroundOperators: Surrounding space missing for operator `+`.", "suggestions": [ { "range": { @@ -167,7 +167,7 @@ "code": { "value": "Layout/ExtraSpacing" }, - "original_output": "C: 2: 14: Layout/ExtraSpacing: Unnecessary spacing detected.", + "original_output": "test/rdjson_formatter/testdata/correctable_offenses.rb:2:14: C: Layout/ExtraSpacing: Unnecessary spacing detected.", "suggestions": [ { "range": { @@ -203,7 +203,7 @@ "code": { "value": "Style/Semicolon" }, - "original_output": "C: 2: 20: Style/Semicolon: Do not use semicolons to terminate expressions.", + "original_output": "test/rdjson_formatter/testdata/correctable_offenses.rb:2:20: C: Style/Semicolon: Do not use semicolons to terminate expressions.", "suggestions": [ { "range": { @@ -239,7 +239,7 @@ "code": { "value": "Style/RedundantReturn" }, - "original_output": "C: 3: 3: Style/RedundantReturn: Redundant `return` detected.", + "original_output": "test/rdjson_formatter/testdata/correctable_offenses.rb:3:3: C: Style/RedundantReturn: Redundant `return` detected.", "suggestions": [ { "range": { @@ -275,7 +275,7 @@ "code": { "value": "Layout/ExtraSpacing" }, - "original_output": "C: 3: 9: Layout/ExtraSpacing: Unnecessary spacing detected.", + "original_output": "test/rdjson_formatter/testdata/correctable_offenses.rb:3:9: C: Layout/ExtraSpacing: Unnecessary spacing detected.", "suggestions": [ { "range": { @@ -311,7 +311,7 @@ "code": { "value": "Naming/MethodParameterName" }, - "original_output": "C: 4: 15: Naming/MethodParameterName: Method parameter must be at least 3 characters long." + "original_output": "test/rdjson_formatter/testdata/not_correctable_offenses.rb:4:15: C: Naming/MethodParameterName: Method parameter must be at least 3 characters long." }, { "message": "Method parameter must be at least 3 characters long.", @@ -332,7 +332,7 @@ "code": { "value": "Naming/MethodParameterName" }, - "original_output": "C: 4: 18: Naming/MethodParameterName: Method parameter must be at least 3 characters long." + "original_output": "test/rdjson_formatter/testdata/not_correctable_offenses.rb:4:18: C: Naming/MethodParameterName: Method parameter must be at least 3 characters long." }, { "message": "Useless assignment to variable - `c`.", @@ -353,7 +353,7 @@ "code": { "value": "Lint/UselessAssignment" }, - "original_output": "W: 5: 5: Lint/UselessAssignment: Useless assignment to variable - `c`." + "original_output": "test/rdjson_formatter/testdata/not_correctable_offenses.rb:5:5: W: Lint/UselessAssignment: Useless assignment to variable - `c`." } ] } From ee0ad9cb810baad6ed547f659d89945be3192927 Mon Sep 17 00:00:00 2001 From: Reid Beels Date: Tue, 30 May 2023 11:43:16 -0700 Subject: [PATCH 06/46] Fix rubocop -> reviewdog severity conversion RuboCop's severity levels are represented by RuboCop::Cop::Severity obejcts, not symbols. Internally, this objects holds a symbol in its `name` attribute an implements comparison methods. Sadly, these comparisons aren't reversable: `severity === :info => true`, but `:info === severity => false`. The ruby case statement performs tripple-equals comparisons with the argument to the `when` clause as the first operand, so the existing case statement always returned `UNKNOWN_SEVERITY`. --- rdjson_formatter/rdjson_formatter.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rdjson_formatter/rdjson_formatter.rb b/rdjson_formatter/rdjson_formatter.rb index c003357..c76c443 100644 --- a/rdjson_formatter/rdjson_formatter.rb +++ b/rdjson_formatter/rdjson_formatter.rb @@ -91,12 +91,12 @@ def build_suggestions(offense) # @param [Symbol] severity # @return [String] def convert_severity(severity) - case severity - when :info + case severity.to_s + when 'info' 'INFO' - when :warning + when 'warning' 'WARNING' - when :error + when 'error' 'ERROR' else 'UNKNOWN_SEVERITY' From 41bd29b7a7ea014ab519d9b0cb3d213ecabcd4b2 Mon Sep 17 00:00:00 2001 From: Reid Beels Date: Tue, 30 May 2023 11:44:05 -0700 Subject: [PATCH 07/46] Map RuboCop's extra 'convention' and 'refactor' severity levels to 'INFO' --- rdjson_formatter/rdjson_formatter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdjson_formatter/rdjson_formatter.rb b/rdjson_formatter/rdjson_formatter.rb index c76c443..e652102 100644 --- a/rdjson_formatter/rdjson_formatter.rb +++ b/rdjson_formatter/rdjson_formatter.rb @@ -92,7 +92,7 @@ def build_suggestions(offense) # @return [String] def convert_severity(severity) case severity.to_s - when 'info' + when 'info', 'refactor', 'convention' 'INFO' when 'warning' 'WARNING' From 09fe5f9812ba923db92f760f14bb455077dcf368 Mon Sep 17 00:00:00 2001 From: Reid Beels Date: Tue, 30 May 2023 13:41:06 -0700 Subject: [PATCH 08/46] Use RuboCop fail-level option to set overall severity in RDFormat JSON --- rdjson_formatter/rdjson_formatter.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/rdjson_formatter/rdjson_formatter.rb b/rdjson_formatter/rdjson_formatter.rb index e652102..b2db60b 100644 --- a/rdjson_formatter/rdjson_formatter.rb +++ b/rdjson_formatter/rdjson_formatter.rb @@ -22,6 +22,8 @@ def file_finished(file, offenses) @rdjson[:diagnostics] << build_diagnostic(file, offense) end + + @rdjson[:severity] = overall_severity(offenses) end def finished(_inspected_files) @@ -30,6 +32,24 @@ def finished(_inspected_files) private + def overall_severity(offenses) + if offenses.any? { |o| o.severity >= minimum_severity_to_fail } + 'ERROR' + elsif offenses.all? { |o| convert_severity(o.severity) == 'INFO' } + 'INFO' + else + 'WARNING' + end + end + + def minimum_severity_to_fail + @minimum_severity_to_fail ||= begin + # Unless given explicitly as `fail_level`, `:info` severity offenses do not fail + name = options.fetch(:fail_level, :refactor) + RuboCop::Cop::Severity.new(name) + end + end + # @param [String] file # @param [RuboCop::Cop::Offense] offense # @return [Hash] From 7a1968c3e0ca867ca6033a8b68b2be3c76df6e17 Mon Sep 17 00:00:00 2001 From: Reid Beels Date: Fri, 2 Jun 2023 14:02:27 -0700 Subject: [PATCH 09/46] Update rdjson testdata with corrected severity values --- test/rdjson_formatter/testdata/result.ok | 25 ++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/test/rdjson_formatter/testdata/result.ok b/test/rdjson_formatter/testdata/result.ok index 29c5682..b44c534 100644 --- a/test/rdjson_formatter/testdata/result.ok +++ b/test/rdjson_formatter/testdata/result.ok @@ -19,7 +19,7 @@ } } }, - "severity": "UNKNOWN_SEVERITY", + "severity": "INFO", "code": { "value": "Style/FrozenStringLiteralComment" }, @@ -55,7 +55,7 @@ } } }, - "severity": "UNKNOWN_SEVERITY", + "severity": "INFO", "code": { "value": "Layout/SpaceAfterComma" }, @@ -91,7 +91,7 @@ } } }, - "severity": "UNKNOWN_SEVERITY", + "severity": "INFO", "code": { "value": "Layout/ExtraSpacing" }, @@ -127,7 +127,7 @@ } } }, - "severity": "UNKNOWN_SEVERITY", + "severity": "INFO", "code": { "value": "Layout/SpaceAroundOperators" }, @@ -163,7 +163,7 @@ } } }, - "severity": "UNKNOWN_SEVERITY", + "severity": "INFO", "code": { "value": "Layout/ExtraSpacing" }, @@ -199,7 +199,7 @@ } } }, - "severity": "UNKNOWN_SEVERITY", + "severity": "INFO", "code": { "value": "Style/Semicolon" }, @@ -235,7 +235,7 @@ } } }, - "severity": "UNKNOWN_SEVERITY", + "severity": "INFO", "code": { "value": "Style/RedundantReturn" }, @@ -271,7 +271,7 @@ } } }, - "severity": "UNKNOWN_SEVERITY", + "severity": "INFO", "code": { "value": "Layout/ExtraSpacing" }, @@ -307,7 +307,7 @@ } } }, - "severity": "UNKNOWN_SEVERITY", + "severity": "INFO", "code": { "value": "Naming/MethodParameterName" }, @@ -328,7 +328,7 @@ } } }, - "severity": "UNKNOWN_SEVERITY", + "severity": "INFO", "code": { "value": "Naming/MethodParameterName" }, @@ -349,11 +349,12 @@ } } }, - "severity": "UNKNOWN_SEVERITY", + "severity": "WARNING", "code": { "value": "Lint/UselessAssignment" }, "original_output": "test/rdjson_formatter/testdata/not_correctable_offenses.rb:5:5: W: Lint/UselessAssignment: Useless assignment to variable - `c`." } - ] + ], + "severity": "ERROR" } From ecd2fc7073c43aa6835d2624f880b95d23020168 Mon Sep 17 00:00:00 2001 From: Reid Beels Date: Fri, 2 Jun 2023 14:03:45 -0700 Subject: [PATCH 10/46] Disable Metrics/ClassLength for RdjsonFormatter --- rdjson_formatter/rdjson_formatter.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rdjson_formatter/rdjson_formatter.rb b/rdjson_formatter/rdjson_formatter.rb index b2db60b..161183a 100644 --- a/rdjson_formatter/rdjson_formatter.rb +++ b/rdjson_formatter/rdjson_formatter.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # https://docs.rubocop.org/rubocop/formatters.html -# rubocop:disable Metrics/AbcSize, Metrics/MethodLength +# rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/ClassLength class RdjsonFormatter < RuboCop::Formatter::BaseFormatter include RuboCop::PathUtil @@ -156,4 +156,4 @@ def build_original_output(file, offense) ) end end -# rubocop:enable Metrics/AbcSize, Metrics/MethodLength +# rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/ClassLength From ff0e80aec51da950bac85ca7a95b1d7a7f150410 Mon Sep 17 00:00:00 2001 From: Reid Beels Date: Tue, 6 Jun 2023 11:38:54 -0700 Subject: [PATCH 11/46] Update testdata with newer rubocop version --- test/rdjson_formatter/testdata/result.ok | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/rdjson_formatter/testdata/result.ok b/test/rdjson_formatter/testdata/result.ok index b44c534..ba2b016 100644 --- a/test/rdjson_formatter/testdata/result.ok +++ b/test/rdjson_formatter/testdata/result.ok @@ -353,7 +353,22 @@ "code": { "value": "Lint/UselessAssignment" }, - "original_output": "test/rdjson_formatter/testdata/not_correctable_offenses.rb:5:5: W: Lint/UselessAssignment: Useless assignment to variable - `c`." + "original_output": "test/rdjson_formatter/testdata/not_correctable_offenses.rb:5:5: W: Lint/UselessAssignment: Useless assignment to variable - `c`.", + "suggestions": [ + { + "range": { + "start": { + "line": 5, + "column": 5 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "text": "a + b" + } + ] } ], "severity": "ERROR" From 04001f07be8a84f5256ce89a4ade00515a2e7006 Mon Sep 17 00:00:00 2001 From: Masaya Suzuki Date: Fri, 9 Jun 2023 21:45:29 +0900 Subject: [PATCH 12/46] Update actions/checkout --- .github/workflows/ci.yml | 2 +- .github/workflows/depup.yml | 2 +- .github/workflows/release.yml | 4 ++-- .github/workflows/reviewdog.yml | 6 +++--- .github/workflows/test_rdjson_formatter.yml | 2 +- README.md | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0dde91..e8332ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: env: BUNDLE_GEMFILE: ${{ github.workspace }}/test/using_bundler/Gemfile steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3.5.2 - uses: ruby/setup-ruby@v1 with: ruby-version: 2.6 diff --git a/.github/workflows/depup.yml b/.github/workflows/depup.yml index 89deb5a..cafe3c9 100644 --- a/.github/workflows/depup.yml +++ b/.github/workflows/depup.yml @@ -9,7 +9,7 @@ jobs: reviewdog: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3.5.2 - uses: haya14busa/action-depup@v1 id: depup with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf70348..da0f104 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: if: github.event.action != 'labeled' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3.5.2 # Bump version on merging Pull Requests with specific labels. # (bump:major,bump:minor,bump:patch) @@ -54,6 +54,6 @@ jobs: if: github.event.action == 'labeled' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3.5.2 - name: Post bumpr status comment uses: haya14busa/action-bumpr@v1 diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 90f66d6..fe4bda6 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -6,7 +6,7 @@ jobs: name: check / misspell runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3.5.2 - name: misspell uses: reviewdog/action-misspell@v1 with: @@ -19,7 +19,7 @@ jobs: name: runner / shellcheck runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3.5.2 - name: shellcheck uses: reviewdog/action-shellcheck@v1 with: @@ -33,7 +33,7 @@ jobs: name: check / yamllint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3.5.2 - name: yamllint uses: reviewdog/action-yamllint@v1 with: diff --git a/.github/workflows/test_rdjson_formatter.yml b/.github/workflows/test_rdjson_formatter.yml index 86d1b61..09fa588 100644 --- a/.github/workflows/test_rdjson_formatter.yml +++ b/.github/workflows/test_rdjson_formatter.yml @@ -8,7 +8,7 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3.5.2 - uses: ruby/setup-ruby@v1 with: ruby-version: 3.0.2 diff --git a/README.md b/README.md index 0ab03ef..35f8d72 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v1 + uses: actions/checkout@v3.5.2 - uses: ruby/setup-ruby@v1 with: ruby-version: 3.0.0 From 050f69d6508ea39ef7df6db13421aa6b8df765e6 Mon Sep 17 00:00:00 2001 From: Masaya Suzuki Date: Fri, 9 Jun 2023 22:57:16 +0900 Subject: [PATCH 13/46] Specify major version --- .github/workflows/ci.yml | 2 +- .github/workflows/depup.yml | 2 +- .github/workflows/release.yml | 4 ++-- .github/workflows/reviewdog.yml | 6 +++--- .github/workflows/test_rdjson_formatter.yml | 2 +- README.md | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8332ee..9eba2f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: env: BUNDLE_GEMFILE: ${{ github.workspace }}/test/using_bundler/Gemfile steps: - - uses: actions/checkout@v3.5.2 + - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: ruby-version: 2.6 diff --git a/.github/workflows/depup.yml b/.github/workflows/depup.yml index cafe3c9..c0b7ffe 100644 --- a/.github/workflows/depup.yml +++ b/.github/workflows/depup.yml @@ -9,7 +9,7 @@ jobs: reviewdog: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.5.2 + - uses: actions/checkout@v3 - uses: haya14busa/action-depup@v1 id: depup with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index da0f104..f7537b1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: if: github.event.action != 'labeled' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.5.2 + - uses: actions/checkout@v3 # Bump version on merging Pull Requests with specific labels. # (bump:major,bump:minor,bump:patch) @@ -54,6 +54,6 @@ jobs: if: github.event.action == 'labeled' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.5.2 + - uses: actions/checkout@v3 - name: Post bumpr status comment uses: haya14busa/action-bumpr@v1 diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index fe4bda6..9719c91 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -6,7 +6,7 @@ jobs: name: check / misspell runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.5.2 + - uses: actions/checkout@v3 - name: misspell uses: reviewdog/action-misspell@v1 with: @@ -19,7 +19,7 @@ jobs: name: runner / shellcheck runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.5.2 + - uses: actions/checkout@v3 - name: shellcheck uses: reviewdog/action-shellcheck@v1 with: @@ -33,7 +33,7 @@ jobs: name: check / yamllint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.5.2 + - uses: actions/checkout@v3 - name: yamllint uses: reviewdog/action-yamllint@v1 with: diff --git a/.github/workflows/test_rdjson_formatter.yml b/.github/workflows/test_rdjson_formatter.yml index 09fa588..187abb5 100644 --- a/.github/workflows/test_rdjson_formatter.yml +++ b/.github/workflows/test_rdjson_formatter.yml @@ -8,7 +8,7 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.5.2 + - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: ruby-version: 3.0.2 diff --git a/README.md b/README.md index 35f8d72..cb26f9d 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v3.5.2 + uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: ruby-version: 3.0.0 From cd735b9b957e5a55f583c6c55ccef66f2b355685 Mon Sep 17 00:00:00 2001 From: Masaya Suzuki Date: Mon, 12 Jun 2023 07:19:22 +0900 Subject: [PATCH 14/46] Update peter-evans/create-pull-request --- .github/workflows/depup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/depup.yml b/.github/workflows/depup.yml index c0b7ffe..1ae70b7 100644 --- a/.github/workflows/depup.yml +++ b/.github/workflows/depup.yml @@ -18,7 +18,7 @@ jobs: repo: reviewdog/reviewdog - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.GITHUB_TOKEN }} title: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}" From 45002caca8ab79183566bfcefe3215b7421c7691 Mon Sep 17 00:00:00 2001 From: review-dog Date: Mon, 19 Jun 2023 11:27:53 +0000 Subject: [PATCH 15/46] chore(deps): update reviewdog to 0.14.2 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index b9c66e0..e84f3ab 100644 --- a/action.yml +++ b/action.yml @@ -52,7 +52,7 @@ runs: - run: $GITHUB_ACTION_PATH/script.sh shell: sh env: - REVIEWDOG_VERSION: v0.14.1 + REVIEWDOG_VERSION: v0.14.2 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} From 78b99fafea48ca24f35e1f7e185bb45d51b1a033 Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Tue, 20 Jun 2023 22:35:06 +0900 Subject: [PATCH 16/46] ci: replace 'create-release action' with gh cli --- .github/workflows/release.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f7537b1..aced269 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,17 +38,13 @@ jobs: if_false: ${{ steps.bumpr.outputs.next_version }} # Create release. - - uses: actions/create-release@v1 - if: "steps.tag.outputs.value != ''" + - if: "steps.tag.outputs.value != ''" env: - # This token is provided by Actions, you do not need to create your own token + TAG_NAME: ${{ steps.tag.outputs.value }} + BODY: ${{ steps.bumpr.outputs.message }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.tag.outputs.value }} - release_name: Release ${{ steps.tag.outputs.value }} - body: ${{ steps.bumpr.outputs.message }} - draft: false - prerelease: false + run: | + gh release create "${TAG_NAME}" -t "Release ${TAG_NAME/refs\/tags\//}" --notes "${BODY}" release-check: if: github.event.action == 'labeled' From 266e85e07a973b2961a7e487e2865ace8162e09d Mon Sep 17 00:00:00 2001 From: review-dog Date: Wed, 6 Sep 2023 05:37:34 +0000 Subject: [PATCH 17/46] chore(deps): update reviewdog to 0.15.0 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index e84f3ab..4c0a37b 100644 --- a/action.yml +++ b/action.yml @@ -52,7 +52,7 @@ runs: - run: $GITHUB_ACTION_PATH/script.sh shell: sh env: - REVIEWDOG_VERSION: v0.14.2 + REVIEWDOG_VERSION: v0.15.0 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} From 388601999867f60f06b9ccddf2f1a60b87049be4 Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Thu, 7 Sep 2023 21:08:54 +0900 Subject: [PATCH 18/46] bump actions/checkout v4 --- .github/workflows/ci.yml | 2 +- .github/workflows/depup.yml | 2 +- .github/workflows/release.yml | 4 ++-- .github/workflows/reviewdog.yml | 6 +++--- .github/workflows/test_rdjson_formatter.yml | 2 +- README.md | 18 ++++++++++-------- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9eba2f0..61280dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: env: BUNDLE_GEMFILE: ${{ github.workspace }}/test/using_bundler/Gemfile steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: 2.6 diff --git a/.github/workflows/depup.yml b/.github/workflows/depup.yml index 1ae70b7..2f7eda4 100644 --- a/.github/workflows/depup.yml +++ b/.github/workflows/depup.yml @@ -9,7 +9,7 @@ jobs: reviewdog: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: haya14busa/action-depup@v1 id: depup with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aced269..fe431ac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: if: github.event.action != 'labeled' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Bump version on merging Pull Requests with specific labels. # (bump:major,bump:minor,bump:patch) @@ -50,6 +50,6 @@ jobs: if: github.event.action == 'labeled' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Post bumpr status comment uses: haya14busa/action-bumpr@v1 diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 9719c91..8d6bccf 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -6,7 +6,7 @@ jobs: name: check / misspell runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: misspell uses: reviewdog/action-misspell@v1 with: @@ -19,7 +19,7 @@ jobs: name: runner / shellcheck runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: shellcheck uses: reviewdog/action-shellcheck@v1 with: @@ -33,7 +33,7 @@ jobs: name: check / yamllint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: yamllint uses: reviewdog/action-yamllint@v1 with: diff --git a/.github/workflows/test_rdjson_formatter.yml b/.github/workflows/test_rdjson_formatter.yml index 187abb5..23190bc 100644 --- a/.github/workflows/test_rdjson_formatter.yml +++ b/.github/workflows/test_rdjson_formatter.yml @@ -8,7 +8,7 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: 3.0.2 diff --git a/README.md b/README.md index cb26f9d..1bfb3b3 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,10 @@ With `reporter: github-pr-review` a comment is added to the Pull Request Convers ### `rubocop_version` Optional. Set rubocop version. Possible values: -* empty or omit: install latest version -* `gemfile`: install version from Gemfile (`Gemfile.lock` should be presented, otherwise it will fallback to latest bundler version) -* version (e.g. `0.90.0`): install said version + +- empty or omit: install latest version +- `gemfile`: install version from Gemfile (`Gemfile.lock` should be presented, otherwise it will fallback to latest bundler version) +- version (e.g. `0.90.0`): install said version ### `rubocop_extensions` @@ -45,9 +46,10 @@ By default install `rubocop-rails`, `rubocop-performance`, `rubocop-rspec`, `rub Provide desired version delimited by `:` (e.g. `rubocop-rails:1.7.1`) Possible version values: -* empty or omit (`rubocop-rails rubocop-rspec`): install latest version -* `rubocop-rails:gemfile rubocop-rspec:gemfile`: install version from Gemfile (`Gemfile.lock` should be presented, otherwise it will fallback to latest bundler version) -* version (e.g. `rubocop-rails:1.7.1 rubocop-rspec:2.0.0`): install said version + +- empty or omit (`rubocop-rails rubocop-rspec`): install latest version +- `rubocop-rails:gemfile rubocop-rspec:gemfile`: install version from Gemfile (`Gemfile.lock` should be presented, otherwise it will fallback to latest bundler version) +- version (e.g. `rubocop-rails:1.7.1 rubocop-rspec:2.0.0`): install said version You can combine `gemfile`, fixed and latest bundle version as you want to. @@ -77,7 +79,7 @@ Default is `added`. ### `fail_on_error` -Optional. Exit code for reviewdog when errors are found [`true`, `false`]. +Optional. Exit code for reviewdog when errors are found [`true`, `false`]. Default is `false`. ### `reviewdog_flags` @@ -112,7 +114,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: 3.0.0 From 459ba5d2e98ccba1c9a5615d630d21b278614a87 Mon Sep 17 00:00:00 2001 From: review-dog Date: Tue, 19 Dec 2023 05:05:25 +0000 Subject: [PATCH 19/46] chore(deps): update reviewdog to 0.16.0 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 4c0a37b..2c0a73c 100644 --- a/action.yml +++ b/action.yml @@ -52,7 +52,7 @@ runs: - run: $GITHUB_ACTION_PATH/script.sh shell: sh env: - REVIEWDOG_VERSION: v0.15.0 + REVIEWDOG_VERSION: v0.16.0 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} From 94882d93f3caeb98ec88e05acd29cf6630d087c6 Mon Sep 17 00:00:00 2001 From: review-dog Date: Mon, 22 Jan 2024 12:30:55 +0000 Subject: [PATCH 20/46] chore(deps): update reviewdog to 0.17.0 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 2c0a73c..72cbe1a 100644 --- a/action.yml +++ b/action.yml @@ -52,7 +52,7 @@ runs: - run: $GITHUB_ACTION_PATH/script.sh shell: sh env: - REVIEWDOG_VERSION: v0.16.0 + REVIEWDOG_VERSION: v0.17.0 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} From e313ba8637713721552772fb710b3381f5507351 Mon Sep 17 00:00:00 2001 From: review-dog Date: Thu, 8 Feb 2024 16:05:04 +0000 Subject: [PATCH 21/46] chore(deps): update reviewdog to 0.17.1 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 72cbe1a..67b5591 100644 --- a/action.yml +++ b/action.yml @@ -52,7 +52,7 @@ runs: - run: $GITHUB_ACTION_PATH/script.sh shell: sh env: - REVIEWDOG_VERSION: v0.17.0 + REVIEWDOG_VERSION: v0.17.1 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} From 53401726feff8cfe2342d0d85f3c1406bbf5ba93 Mon Sep 17 00:00:00 2001 From: Javier Julio Date: Wed, 28 Feb 2024 12:18:13 -0500 Subject: [PATCH 22/46] Update example to use Bundler (#97) Since Rubocop has multiple gems, it's best to rely on Bundler to install them rather than not. Other popular gems like Rails use this same feature to optimize their rubocop workflows. https://github.com/rails/rails/blob/main/.github/workflows/rubocop.yml --- README.md | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 1bfb3b3..1ae8817 100644 --- a/README.md +++ b/README.md @@ -100,11 +100,24 @@ Optional. Run Rubocop with bundle exec. Default: `false`. ## Example usage -You can create [RuboCop Configuration](https://docs.rubocop.org/rubocop/configuration.html) and this action uses that config too. +This action will use your [RuboCop Configuration](https://docs.rubocop.org/rubocop/configuration.html) automatically. + +In your `Gemfile`, ensure all Rubocop gems are in a named (e.g. rubocop) group: + +```ruby +group :development, :rubocop do + gem 'rubocop', require: false + gem 'rubocop-rails', require: false + # ... +end +``` + +Create the following workflow. The `BUNDLE_ONLY` environment variable will tell Bundler to only install the specified group. ```yml name: reviewdog -on: [pull_request] +on: + pull_request: permissions: contents: read pull-requests: write @@ -112,18 +125,19 @@ jobs: rubocop: name: runner / rubocop runs-on: ubuntu-latest + env: + BUNDLE_ONLY: rubocop steps: - - name: Check out code - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: 3.0.0 - - name: rubocop - uses: reviewdog/action-rubocop@v2 + ruby-version: '3.3' + bundler-cache: true + - uses: reviewdog/action-rubocop@v2 with: - rubocop_version: gemfile - rubocop_extensions: rubocop-rails:gemfile rubocop-rspec:gemfile reporter: github-pr-review # Default is github-pr-check + skip_install: true + use_bundler: true ``` ## Sponsor From 91c617267deb547c2c735c2f5eadb71cfd7edcd9 Mon Sep 17 00:00:00 2001 From: review-dog Date: Mon, 11 Mar 2024 06:11:12 +0000 Subject: [PATCH 23/46] chore(deps): update reviewdog to 0.17.2 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 67b5591..9e4c662 100644 --- a/action.yml +++ b/action.yml @@ -52,7 +52,7 @@ runs: - run: $GITHUB_ACTION_PATH/script.sh shell: sh env: - REVIEWDOG_VERSION: v0.17.1 + REVIEWDOG_VERSION: v0.17.2 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} From 1406b2dcc0f0d130126f4b40b75b6185da50a0ac Mon Sep 17 00:00:00 2001 From: review-dog Date: Mon, 15 Apr 2024 11:17:04 +0000 Subject: [PATCH 24/46] chore(deps): update reviewdog to 0.17.3 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 9e4c662..f7ccc6c 100644 --- a/action.yml +++ b/action.yml @@ -52,7 +52,7 @@ runs: - run: $GITHUB_ACTION_PATH/script.sh shell: sh env: - REVIEWDOG_VERSION: v0.17.2 + REVIEWDOG_VERSION: v0.17.3 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} From 8e3a35a39e1e536aab47b647928e45c221e49bb2 Mon Sep 17 00:00:00 2001 From: review-dog Date: Fri, 19 Apr 2024 15:02:50 +0000 Subject: [PATCH 25/46] chore(deps): update reviewdog to 0.17.4 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index f7ccc6c..7cd76cc 100644 --- a/action.yml +++ b/action.yml @@ -52,7 +52,7 @@ runs: - run: $GITHUB_ACTION_PATH/script.sh shell: sh env: - REVIEWDOG_VERSION: v0.17.3 + REVIEWDOG_VERSION: v0.17.4 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} From ca4815236840893fb7556a086366c97d9e4d9a0c Mon Sep 17 00:00:00 2001 From: Pavel Buchart Date: Wed, 24 Apr 2024 16:08:04 +0200 Subject: [PATCH 26/46] Fix relative_path_from error --- rdjson_formatter/rdjson_formatter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdjson_formatter/rdjson_formatter.rb b/rdjson_formatter/rdjson_formatter.rb index 161183a..2eea86b 100644 --- a/rdjson_formatter/rdjson_formatter.rb +++ b/rdjson_formatter/rdjson_formatter.rb @@ -136,7 +136,7 @@ def convert_path(path) base_path = Dir.pwd begin - Pathname.new(File.expand_path(path)).relative_path_from(base_path).to_s + Pathname.new(File.expand_path(path)).relative_path_from(Pathname.new(base_path)).to_s rescue ArgumentError path end From 8d644c0bec100610e92c9fafa1fe114a8ae66c36 Mon Sep 17 00:00:00 2001 From: Ivan Kuchin Date: Mon, 6 May 2024 19:16:58 +0200 Subject: [PATCH 27/46] Remove unused version function in script.sh (#104) version function is not used since 06c2574b1129256ab42c95f3b9aeb8261a49d728 --- script.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/script.sh b/script.sh index 0aa6fbf..81a06bc 100755 --- a/script.sh +++ b/script.sh @@ -1,9 +1,4 @@ #!/bin/sh -e -version() { - if [ -n "$1" ]; then - echo "-v $1" - fi -} cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" From 6c175bc9c565fc6177d1600cfbab98b6c3ac4500 Mon Sep 17 00:00:00 2001 From: Ivan Kuchin Date: Wed, 15 May 2024 18:57:13 +0200 Subject: [PATCH 28/46] Order inputs alphabetically (#102) * order inputs alphabetically * add a comment requesting to keep alphabetical order * Better wording in comments requesting to maintain alphabetical order of inputs Co-authored-by: Javier Julio --------- Co-authored-by: Javier Julio --- README.md | 68 ++++++++++++++++++++++++++++-------------------------- action.yml | 64 +++++++++++++++++++++++++------------------------- 2 files changed, 68 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index 1ae8817..551328c 100644 --- a/README.md +++ b/README.md @@ -26,17 +26,35 @@ With `reporter: github-pr-review` a comment is added to the Pull Request Convers ## Inputs + + +### `fail_on_error` + +Optional. Exit code for reviewdog when errors are found [`true`, `false`]. +Default is `false`. + +### `filter_mode` + +Optional. Filtering mode for the reviewdog command [`added`, `diff_context`, `file`, `nofilter`]. +Default is `added`. + ### `github_token` `GITHUB_TOKEN`. Default is `${{ github.token }}`. -### `rubocop_version` +### `level` -Optional. Set rubocop version. Possible values: +Optional. Report level for reviewdog [`info`, `warning`, `error`]. +It's same as `-level` flag of reviewdog. -- empty or omit: install latest version -- `gemfile`: install version from Gemfile (`Gemfile.lock` should be presented, otherwise it will fallback to latest bundler version) -- version (e.g. `0.90.0`): install said version +### `reporter` + +Optional. Reporter of reviewdog command [`github-pr-check`, `github-check`, `github-pr-review`]. +The default is `github-pr-check`. + +### `reviewdog_flags` + +Optional. Additional reviewdog flags. ### `rubocop_extensions` @@ -57,47 +75,31 @@ You can combine `gemfile`, fixed and latest bundle version as you want to. Optional. Rubocop flags. (rubocop ``). -### `tool_name` - -Optional. Tool name to use for reviewdog reporter. Useful when running multiple -actions with different config. - -### `level` - -Optional. Report level for reviewdog [`info`, `warning`, `error`]. -It's same as `-level` flag of reviewdog. +### `rubocop_version` -### `reporter` +Optional. Set rubocop version. Possible values: -Optional. Reporter of reviewdog command [`github-pr-check`, `github-check`, `github-pr-review`]. -The default is `github-pr-check`. +- empty or omit: install latest version +- `gemfile`: install version from Gemfile (`Gemfile.lock` should be presented, otherwise it will fallback to latest bundler version) +- version (e.g. `0.90.0`): install said version -### `filter_mode` +### `skip_install` -Optional. Filtering mode for the reviewdog command [`added`, `diff_context`, `file`, `nofilter`]. -Default is `added`. +Optional. Do not install Rubocop or its extensions. Default: `false`. -### `fail_on_error` +### `tool_name` -Optional. Exit code for reviewdog when errors are found [`true`, `false`]. -Default is `false`. +Optional. Tool name to use for reviewdog reporter. Useful when running multiple +actions with different config. -### `reviewdog_flags` +### `use_bundler` -Optional. Additional reviewdog flags. +Optional. Run Rubocop with bundle exec. Default: `false`. ### `workdir` Optional. The directory from which to look for and run Rubocop. Default `.`. -### `skip_install` - -Optional. Do not install Rubocop or its extensions. Default: `false`. - -### `use_bundler` - -Optional. Run Rubocop with bundle exec. Default: `false`. - ## Example usage This action will use your [RuboCop Configuration](https://docs.rubocop.org/rubocop/configuration.html) automatically. diff --git a/action.yml b/action.yml index 7cd76cc..8999993 100644 --- a/action.yml +++ b/action.yml @@ -2,20 +2,20 @@ name: 'Run rubocop with reviewdog' description: '🐶 Run rubocop with reviewdog on pull requests to improve code review experience.' author: 'mgrachev (reviewdog)' inputs: + # Please maintain inputs in alphabetical order + fail_on_error: + description: | + Exit code for reviewdog when errors are found [true,false] + Default is `false`. + default: 'false' + filter_mode: + description: | + Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. + Default is added. + default: 'added' github_token: description: 'GITHUB_TOKEN' default: ${{ github.token }} - rubocop_version: - description: 'Rubocop version' - rubocop_extensions: - description: 'Rubocop extensions' - default: 'rubocop-rails rubocop-performance rubocop-rspec rubocop-i18n rubocop-rake' - rubocop_flags: - description: 'Rubocop flags. (rubocop )' - default: '' - tool_name: - description: 'Tool name to use for reviewdog reporter' - default: 'rubocop' level: description: 'Report level for reviewdog [info,warning,error]' default: 'error' @@ -24,28 +24,29 @@ inputs: Reporter of reviewdog command [github-pr-check,github-check,github-pr-review]. Default is github-pr-check. default: 'github-pr-check' - filter_mode: - description: | - Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. - Default is added. - default: 'added' - fail_on_error: - description: | - Exit code for reviewdog when errors are found [true,false] - Default is `false`. - default: 'false' reviewdog_flags: description: 'Additional reviewdog flags' default: '' - workdir: - description: "The directory from which to look for and run Rubocop. Default '.'" - default: '.' + rubocop_extensions: + description: 'Rubocop extensions' + default: 'rubocop-rails rubocop-performance rubocop-rspec rubocop-i18n rubocop-rake' + rubocop_flags: + description: 'Rubocop flags. (rubocop )' + default: '' + rubocop_version: + description: 'Rubocop version' skip_install: description: "Do not install Rubocop or its extensions. Default: `false`" default: 'false' + tool_name: + description: 'Tool name to use for reviewdog reporter' + default: 'rubocop' use_bundler: description: "Run Rubocop with bundle exec. Default: `false`" default: 'false' + workdir: + description: "The directory from which to look for and run Rubocop. Default '.'" + default: '.' runs: using: 'composite' steps: @@ -55,19 +56,20 @@ runs: REVIEWDOG_VERSION: v0.17.4 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 + # Please maintain inputs in alphabetical order + INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }} + INPUT_FILTER_MODE: ${{ inputs.filter_mode }} INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} - INPUT_RUBOCOP_VERSION: ${{ inputs.rubocop_version }} - INPUT_RUBOCOP_EXTENSIONS: ${{ inputs.rubocop_extensions }} - INPUT_RUBOCOP_FLAGS: ${{ inputs.rubocop_flags }} - INPUT_TOOL_NAME: ${{ inputs.tool_name }} INPUT_LEVEL: ${{ inputs.level }} INPUT_REPORTER: ${{ inputs.reporter }} - INPUT_FILTER_MODE: ${{ inputs.filter_mode }} - INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }} INPUT_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }} - INPUT_WORKDIR: ${{ inputs.workdir }} + INPUT_RUBOCOP_EXTENSIONS: ${{ inputs.rubocop_extensions }} + INPUT_RUBOCOP_FLAGS: ${{ inputs.rubocop_flags }} + INPUT_RUBOCOP_VERSION: ${{ inputs.rubocop_version }} INPUT_SKIP_INSTALL: ${{ inputs.skip_install }} + INPUT_TOOL_NAME: ${{ inputs.tool_name }} INPUT_USE_BUNDLER: ${{ inputs.use_bundler }} + INPUT_WORKDIR: ${{ inputs.workdir }} branding: icon: 'check-circle' color: 'red' From 801d4d79997d73d424acb50d7bc5e92f768e38f6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 23:50:05 +0900 Subject: [PATCH 29/46] chore(deps): update reviewdog to 0.17.5 (#105) Co-authored-by: review-dog --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 8999993..74fd4bb 100644 --- a/action.yml +++ b/action.yml @@ -53,7 +53,7 @@ runs: - run: $GITHUB_ACTION_PATH/script.sh shell: sh env: - REVIEWDOG_VERSION: v0.17.4 + REVIEWDOG_VERSION: v0.17.5 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 # Please maintain inputs in alphabetical order From 221ac551c86d828013584c0488cc43a140cd0e90 Mon Sep 17 00:00:00 2001 From: Masaya Suzuki <15100604+massongit@users.noreply.github.com> Date: Sun, 9 Jun 2024 08:57:48 +0900 Subject: [PATCH 30/46] Update peter-evans/create-pull-request (#106) --- .github/workflows/depup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/depup.yml b/.github/workflows/depup.yml index 2f7eda4..3a9f433 100644 --- a/.github/workflows/depup.yml +++ b/.github/workflows/depup.yml @@ -18,7 +18,7 @@ jobs: repo: reviewdog/reviewdog - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@v6 with: token: ${{ secrets.GITHUB_TOKEN }} title: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}" From ef5cc7ad48053f1b53e0a7c7779b04aeb3cf34b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 9 Jun 2024 09:00:31 +0900 Subject: [PATCH 31/46] Bump rexml from 3.2.5 to 3.2.8 in /test/using_bundler (#107) Bumps [rexml](https://github.com/ruby/rexml) from 3.2.5 to 3.2.8. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.2.5...v3.2.8) --- updated-dependencies: - dependency-name: rexml dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/using_bundler/Gemfile.lock | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/using_bundler/Gemfile.lock b/test/using_bundler/Gemfile.lock index 8b9e7fe..1692780 100644 --- a/test/using_bundler/Gemfile.lock +++ b/test/using_bundler/Gemfile.lock @@ -7,7 +7,8 @@ GEM ast (~> 2.4.1) rainbow (3.0.0) regexp_parser (2.1.1) - rexml (3.2.5) + rexml (3.2.8) + strscan (>= 3.0.9) rubocop (1.18.1) parallel (~> 1.10) parser (>= 3.0.0.0) @@ -20,6 +21,7 @@ GEM rubocop-ast (1.9.0) parser (>= 3.0.1.1) ruby-progressbar (1.11.0) + strscan (3.1.0) unicode-display_width (2.0.0) PLATFORMS From 34a84a7c5ec11b0e990fcc837e37d6d3ee076bff Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 18 Jun 2024 00:13:14 +0900 Subject: [PATCH 32/46] chore(deps): update reviewdog to 0.18.0 (#108) Co-authored-by: review-dog <22892449+review-dog@users.noreply.github.com> --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 74fd4bb..7324566 100644 --- a/action.yml +++ b/action.yml @@ -53,7 +53,7 @@ runs: - run: $GITHUB_ACTION_PATH/script.sh shell: sh env: - REVIEWDOG_VERSION: v0.17.5 + REVIEWDOG_VERSION: v0.18.0 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 # Please maintain inputs in alphabetical order From 1346d2bf532497b4ef3a8241dd4eadbc4656b05d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 23 Jun 2024 01:03:00 +0900 Subject: [PATCH 33/46] chore(deps): update reviewdog to 0.18.1 (#109) Co-authored-by: review-dog <22892449+review-dog@users.noreply.github.com> --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 7324566..bb27bcc 100644 --- a/action.yml +++ b/action.yml @@ -53,7 +53,7 @@ runs: - run: $GITHUB_ACTION_PATH/script.sh shell: sh env: - REVIEWDOG_VERSION: v0.18.0 + REVIEWDOG_VERSION: v0.18.1 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 # Please maintain inputs in alphabetical order From 2fe5a0f7bc39ceb259e0d5395630272a3d9e3d5d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 7 Jul 2024 09:24:19 +0900 Subject: [PATCH 34/46] chore(deps): update reviewdog to 0.19.0 (#112) Co-authored-by: review-dog <22892449+review-dog@users.noreply.github.com> --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index bb27bcc..eb33de9 100644 --- a/action.yml +++ b/action.yml @@ -53,7 +53,7 @@ runs: - run: $GITHUB_ACTION_PATH/script.sh shell: sh env: - REVIEWDOG_VERSION: v0.18.1 + REVIEWDOG_VERSION: v0.19.0 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 # Please maintain inputs in alphabetical order From 4e3af4bbf94fe89f42f1f088be89f2918f21cc5e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 7 Jul 2024 10:10:34 +0900 Subject: [PATCH 35/46] chore(deps): update reviewdog to 0.20.0 (#113) Co-authored-by: review-dog <22892449+review-dog@users.noreply.github.com> --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index eb33de9..e552ebe 100644 --- a/action.yml +++ b/action.yml @@ -53,7 +53,7 @@ runs: - run: $GITHUB_ACTION_PATH/script.sh shell: sh env: - REVIEWDOG_VERSION: v0.19.0 + REVIEWDOG_VERSION: v0.20.0 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 # Please maintain inputs in alphabetical order From e44fb2cc5488dfc11a37c12910bcb0d44d028b04 Mon Sep 17 00:00:00 2001 From: Ivan Kuchin Date: Sun, 14 Jul 2024 14:51:02 +0200 Subject: [PATCH 36/46] add only_changed input to run rubocop only against changed files (#103) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add only_changed input to run rubocop only against changed files Switch to bash for process substitution and working with arrays. Ignore if there are more than 100. Protecting from possibly hitting the command line length limit, it can be much higher and can be calculated or also extracted as one more input if needed. The effect from limiting number of files processed by rubocop is also smaller. Fix ci workflow to fetch all commits for pr branch plus head commit of base branch to be able to find changed files. Co-authored-by: Oliver Günther * automatically fetch the tip of the base branch if it is not available * don't hide the name of the CI job * test only_changed --------- Co-authored-by: Oliver Günther --- .github/workflows/ci.yml | 53 ++++++++++++++++++- README.md | 8 +++ action.yml | 9 ++++ script.sh | 44 ++++++++++++++- test/only_changed/few_relevant/files/a.rb | 1 + test/only_changed/few_relevant/files/a.txt | 1 + .../few_relevant/mock_bins/rubocop | 18 +++++++ .../only_changed/nothing_relevant/files/a.txt | 1 + .../nothing_relevant/mock_bins/rubocop | 11 ++++ test/only_changed/shared_mock_bins/bundle | 9 ++++ test/only_changed/shared_mock_bins/curl | 8 +++ test/only_changed/shared_mock_bins/reviewdog | 10 ++++ .../too_many_relevant/mock_bins/rubocop | 17 ++++++ 13 files changed, 187 insertions(+), 3 deletions(-) create mode 100644 test/only_changed/few_relevant/files/a.rb create mode 100644 test/only_changed/few_relevant/files/a.txt create mode 100755 test/only_changed/few_relevant/mock_bins/rubocop create mode 100644 test/only_changed/nothing_relevant/files/a.txt create mode 100755 test/only_changed/nothing_relevant/mock_bins/rubocop create mode 100755 test/only_changed/shared_mock_bins/bundle create mode 100755 test/only_changed/shared_mock_bins/curl create mode 100755 test/only_changed/shared_mock_bins/reviewdog create mode 100755 test/only_changed/too_many_relevant/mock_bins/rubocop diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61280dd..6a26232 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,6 @@ name: CI on: [pull_request] jobs: test-skip-install-and-use-bundler: - name: runner / rubocop runs-on: ubuntu-latest defaults: run: @@ -22,3 +21,55 @@ jobs: skip_install: 'true' use_bundler: 'true' - run: test "$(bundle exec rubocop --version)" == "1.18.1" + test-only_changed: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + env: + INPUT_ONLY_CHANGED: 'true' + steps: + - uses: actions/checkout@v4 + - name: setup + run: | + git config user.email "workflow@github.com" + git config user.name "I am an automated workflow" + - name: Check when there are relevant files + run: | + git checkout ${{ github.sha }} + rm -f test/only_changed/reviewdog-was-called + + cp test/only_changed/few_relevant/files/* . + git add * + git commit -m auto + + export PATH=test/only_changed/few_relevant/mock_bins:test/only_changed/shared_mock_bins:$PATH + BASE_REF=$(git rev-parse HEAD~) HEAD_REF=$(git rev-parse HEAD) ./script.sh + + [ -f test/only_changed/reviewdog-was-called ] + - name: Check when there are no relevant files + run: | + git checkout ${{ github.sha }} + rm -f test/only_changed/reviewdog-was-called + + cp test/only_changed/nothing_relevant/files/* . + git add * + git commit -m auto + + export PATH=test/only_changed/nothing_relevant/mock_bins:test/only_changed/shared_mock_bins:$PATH + BASE_REF=$(git rev-parse HEAD~) HEAD_REF=$(git rev-parse HEAD) ./script.sh + + [ ! -f test/only_changed/reviewdog-was-called ] + - name: Check when there are too many relevant files + run: | + git checkout ${{ github.sha }} + rm -f test/only_changed/reviewdog-was-called + + touch a{00..100}.rb + git add * + git commit -m auto + + export PATH=test/only_changed/too_many_relevant/mock_bins:test/only_changed/shared_mock_bins:$PATH + BASE_REF=$(git rev-parse HEAD~) HEAD_REF=$(git rev-parse HEAD) ./script.sh + + [ -f test/only_changed/reviewdog-was-called ] diff --git a/README.md b/README.md index 551328c..7fc2719 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,14 @@ Default is `added`. Optional. Report level for reviewdog [`info`, `warning`, `error`]. It's same as `-level` flag of reviewdog. +### `only_changed` + +Optional. Run Rubocop only on changed (and added) files, for speedup [`true`, `false`]. +Default: `false`. + +Will fetch the tip of the base branch with depth 1 from remote origin if it is not available. +If you use different remote name or customize the checkout otherwise, make the tip of the base branch available before this action + ### `reporter` Optional. Reporter of reviewdog command [`github-pr-check`, `github-check`, `github-pr-review`]. diff --git a/action.yml b/action.yml index e552ebe..530a5c1 100644 --- a/action.yml +++ b/action.yml @@ -19,6 +19,12 @@ inputs: level: description: 'Report level for reviewdog [info,warning,error]' default: 'error' + only_changed: + description: | + Run Rubocop only on changed (and added) files, for speedup [`true`, `false`]. + Will fetch the tip of the base branch with depth 1 from remote origin if it is not available. + If you use different remote name or customize the checkout otherwise, make the tip of the base branch available before this action. + default: 'false' reporter: description: | Reporter of reviewdog command [github-pr-check,github-check,github-pr-review]. @@ -61,6 +67,7 @@ runs: INPUT_FILTER_MODE: ${{ inputs.filter_mode }} INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} INPUT_LEVEL: ${{ inputs.level }} + INPUT_ONLY_CHANGED: ${{ inputs.only_changed }} INPUT_REPORTER: ${{ inputs.reporter }} INPUT_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }} INPUT_RUBOCOP_EXTENSIONS: ${{ inputs.rubocop_extensions }} @@ -70,6 +77,8 @@ runs: INPUT_TOOL_NAME: ${{ inputs.tool_name }} INPUT_USE_BUNDLER: ${{ inputs.use_bundler }} INPUT_WORKDIR: ${{ inputs.workdir }} + BASE_REF: ${{ github.event.pull_request.base.sha }} + HEAD_REF: ${{ github.sha }} branding: icon: 'check-circle' color: 'red' diff --git a/script.sh b/script.sh index 81a06bc..b34f6b6 100755 --- a/script.sh +++ b/script.sh @@ -1,4 +1,7 @@ -#!/bin/sh -e +#!/usr/bin/env bash + +set -e +set -o pipefail cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}" @@ -85,9 +88,46 @@ else BUNDLE_EXEC="bundle exec " fi +if [ "${INPUT_ONLY_CHANGED}" = "true" ]; then + echo '::group:: Getting changed files list' + + # check if commit is present in repository, otherwise fetch it + if ! git cat-file -e "${BASE_REF}"; then + git fetch --depth 1 origin "${BASE_REF}" + fi + + # get intersection of changed files (excluding deleted) with target files for + # rubocop as an array + # shellcheck disable=SC2086 + readarray -t CHANGED_FILES < <( + comm -12 \ + <(git diff --diff-filter=d --name-only "${BASE_REF}..${HEAD_REF}" | sort || kill $$) \ + <(${BUNDLE_EXEC}rubocop --list-target-files | sort || kill $$) + ) + + if (( ${#CHANGED_FILES[@]} == 0 )); then + echo "No relevant files for rubocop, skipping" + exit 0 + fi + + printf '%s\n' "${CHANGED_FILES[@]}" + + if (( ${#CHANGED_FILES[@]} > 100 )); then + echo "More than 100 changed files (${#CHANGED_FILES[@]}), running rubocop on all files" + unset CHANGED_FILES + fi + + echo '::endgroup::' +fi + echo '::group:: Running rubocop with reviewdog 🐶 ...' # shellcheck disable=SC2086 -${BUNDLE_EXEC}rubocop ${INPUT_RUBOCOP_FLAGS} --require ${GITHUB_ACTION_PATH}/rdjson_formatter/rdjson_formatter.rb --format RdjsonFormatter \ +${BUNDLE_EXEC}rubocop \ + ${INPUT_RUBOCOP_FLAGS} \ + --require ${GITHUB_ACTION_PATH}/rdjson_formatter/rdjson_formatter.rb \ + --format RdjsonFormatter \ + --fail-level error \ + "${CHANGED_FILES[@]}" \ | reviewdog -f=rdjson \ -name="${INPUT_TOOL_NAME}" \ -reporter="${INPUT_REPORTER}" \ diff --git a/test/only_changed/few_relevant/files/a.rb b/test/only_changed/few_relevant/files/a.rb new file mode 100644 index 0000000..5460224 --- /dev/null +++ b/test/only_changed/few_relevant/files/a.rb @@ -0,0 +1 @@ +puts "Hello, " + "world!" diff --git a/test/only_changed/few_relevant/files/a.txt b/test/only_changed/few_relevant/files/a.txt new file mode 100644 index 0000000..5460224 --- /dev/null +++ b/test/only_changed/few_relevant/files/a.txt @@ -0,0 +1 @@ +puts "Hello, " + "world!" diff --git a/test/only_changed/few_relevant/mock_bins/rubocop b/test/only_changed/few_relevant/mock_bins/rubocop new file mode 100755 index 0000000..bcd0014 --- /dev/null +++ b/test/only_changed/few_relevant/mock_bins/rubocop @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +case ARGV +when %w[ + --list-target-files +] + puts Dir['**/*.rb'] +when %W[ + --require #{ENV['GITHUB_ACTION_PATH']}/rdjson_formatter/rdjson_formatter.rb + --format RdjsonFormatter + --fail-level error + a.rb +] + puts 'Mock message for reviewdog' +else + abort "rubocop mock called with unexpected arguments:\n#{ARGV.join("\n")}" +end diff --git a/test/only_changed/nothing_relevant/files/a.txt b/test/only_changed/nothing_relevant/files/a.txt new file mode 100644 index 0000000..5460224 --- /dev/null +++ b/test/only_changed/nothing_relevant/files/a.txt @@ -0,0 +1 @@ +puts "Hello, " + "world!" diff --git a/test/only_changed/nothing_relevant/mock_bins/rubocop b/test/only_changed/nothing_relevant/mock_bins/rubocop new file mode 100755 index 0000000..8b60d86 --- /dev/null +++ b/test/only_changed/nothing_relevant/mock_bins/rubocop @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +case ARGV +when %w[ + --list-target-files +] + puts Dir['**/*.rb'] +else + abort "rubocop mock called with unexpected arguments:\n#{ARGV.join("\n")}" +end diff --git a/test/only_changed/shared_mock_bins/bundle b/test/only_changed/shared_mock_bins/bundle new file mode 100755 index 0000000..0a28632 --- /dev/null +++ b/test/only_changed/shared_mock_bins/bundle @@ -0,0 +1,9 @@ +#!/bin/bash + +if [ "$1" = "exec" ]; then + shift + eval "$@" +else + echo "Only 'exec' command is supported" + exit 1 +fi diff --git a/test/only_changed/shared_mock_bins/curl b/test/only_changed/shared_mock_bins/curl new file mode 100755 index 0000000..3c5bc23 --- /dev/null +++ b/test/only_changed/shared_mock_bins/curl @@ -0,0 +1,8 @@ +#!/bin/bash + +arguments="$*" + +if [ "$arguments" != "-sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh" ]; then + echo "curl mock got unexpected arguments: $arguments" + exit 1 +fi diff --git a/test/only_changed/shared_mock_bins/reviewdog b/test/only_changed/shared_mock_bins/reviewdog new file mode 100755 index 0000000..5334ef7 --- /dev/null +++ b/test/only_changed/shared_mock_bins/reviewdog @@ -0,0 +1,10 @@ +#!/bin/bash + +touch test/only_changed/reviewdog-was-called + +read -r input + +if [ "$input" != "Mock message for reviewdog" ]; then + echo "reviewdog mock got unexpected input: $input" + exit 1 +fi diff --git a/test/only_changed/too_many_relevant/mock_bins/rubocop b/test/only_changed/too_many_relevant/mock_bins/rubocop new file mode 100755 index 0000000..1a2a540 --- /dev/null +++ b/test/only_changed/too_many_relevant/mock_bins/rubocop @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +case ARGV +when %w[ + --list-target-files +] + puts Dir['**/*.rb'] +when %W[ + --require #{ENV['GITHUB_ACTION_PATH']}/rdjson_formatter/rdjson_formatter.rb + --format RdjsonFormatter + --fail-level error +] + puts 'Mock message for reviewdog' +else + abort "rubocop mock called with unexpected arguments:\n#{ARGV.join("\n")}" +end From 7ef50b200dba9fb54c97392337ac7e82d692c4bd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 14 Jul 2024 21:52:03 +0900 Subject: [PATCH 37/46] chore(deps): update reviewdog to 0.20.1 (#116) Co-authored-by: review-dog <22892449+review-dog@users.noreply.github.com> --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 530a5c1..2d32da2 100644 --- a/action.yml +++ b/action.yml @@ -59,7 +59,7 @@ runs: - run: $GITHUB_ACTION_PATH/script.sh shell: sh env: - REVIEWDOG_VERSION: v0.20.0 + REVIEWDOG_VERSION: v0.20.1 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 # Please maintain inputs in alphabetical order From 044a6c9a65c50fffab4f9e029bb9063e49e6c2d4 Mon Sep 17 00:00:00 2001 From: Masaya Suzuki <15100604+massongit@users.noreply.github.com> Date: Sat, 20 Jul 2024 16:54:00 +0900 Subject: [PATCH 38/46] Update ruby and rubocop (#117) --- .github/workflows/ci.yml | 4 +- .rubocop.yml | 208 ++++++++++++++++++++++++++++++++ test/using_bundler/Gemfile.lock | 40 +++--- 3 files changed, 233 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a26232..e0f1587 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.6 + ruby-version: 3.3 bundler-cache: true - name: rubocop with skip install and using bundler uses: ./ @@ -20,7 +20,7 @@ jobs: github_token: ${{ secrets.github_token }} skip_install: 'true' use_bundler: 'true' - - run: test "$(bundle exec rubocop --version)" == "1.18.1" + - run: test "$(bundle exec rubocop --version)" == "1.65.0" test-only_changed: runs-on: ubuntu-latest defaults: diff --git a/.rubocop.yml b/.rubocop.yml index 2e515ce..b4afcae 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,3 +2,211 @@ AllCops: Exclude: - 'test/rdjson_formatter/**/*' - 'vendor/**/*' +Gemspec/AddRuntimeDependency: # new in 1.65 + Enabled: true +Gemspec/DeprecatedAttributeAssignment: # new in 1.30 + Enabled: true +Gemspec/DevelopmentDependencies: # new in 1.44 + Enabled: true +Gemspec/RequireMFA: # new in 1.23 + Enabled: true +Layout/LineContinuationLeadingSpace: # new in 1.31 + Enabled: true +Layout/LineContinuationSpacing: # new in 1.31 + Enabled: true +Layout/LineEndStringConcatenationIndentation: # new in 1.18 + Enabled: true +Layout/SpaceBeforeBrackets: # new in 1.7 + Enabled: true +Lint/AmbiguousAssignment: # new in 1.7 + Enabled: true +Lint/AmbiguousOperatorPrecedence: # new in 1.21 + Enabled: true +Lint/AmbiguousRange: # new in 1.19 + Enabled: true +Lint/ConstantOverwrittenInRescue: # new in 1.31 + Enabled: true +Lint/DeprecatedConstants: # new in 1.8 + Enabled: true +Lint/DuplicateBranch: # new in 1.3 + Enabled: true +Lint/DuplicateMagicComment: # new in 1.37 + Enabled: true +Lint/DuplicateMatchPattern: # new in 1.50 + Enabled: true +Lint/DuplicateRegexpCharacterClassElement: # new in 1.1 + Enabled: true +Lint/EmptyBlock: # new in 1.1 + Enabled: true +Lint/EmptyClass: # new in 1.3 + Enabled: true +Lint/EmptyInPattern: # new in 1.16 + Enabled: true +Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21 + Enabled: true +Lint/ItWithoutArgumentsInBlock: # new in 1.59 + Enabled: true +Lint/LambdaWithoutLiteralBlock: # new in 1.8 + Enabled: true +Lint/LiteralAssignmentInCondition: # new in 1.58 + Enabled: true +Lint/MixedCaseRange: # new in 1.53 + Enabled: true +Style/NumberedParameters: # new in 1.22 + Enabled: true +Style/NumberedParametersLimit: # new in 1.22 + Enabled: true +Style/ObjectThen: # new in 1.28 + Enabled: true +Style/OpenStructUse: # new in 1.23 + Enabled: true +Style/OperatorMethodCall: # new in 1.37 + Enabled: true +Style/QuotedSymbols: # new in 1.16 + Enabled: true +Style/RedundantArgument: # new in 1.4 + Enabled: true +Style/RedundantArrayConstructor: # new in 1.52 + Enabled: true +Style/RedundantConstantBase: # new in 1.40 + Enabled: true +Style/RedundantCurrentDirectoryInPath: # new in 1.53 + Enabled: true +Style/RedundantDoubleSplatHashBraces: # new in 1.41 + Enabled: true +Style/RedundantEach: # new in 1.38 + Enabled: true +Style/RedundantFilterChain: # new in 1.52 + Enabled: true +Style/RedundantHeredocDelimiterQuotes: # new in 1.45 + Enabled: true +Style/RedundantInitialize: # new in 1.27 + Enabled: true +Style/RedundantLineContinuation: # new in 1.49 + Enabled: true +Style/RedundantRegexpArgument: # new in 1.53 + Enabled: true +Style/RedundantRegexpConstructor: # new in 1.52 + Enabled: true +Style/RedundantSelfAssignmentBranch: # new in 1.19 + Enabled: true +Style/RedundantStringEscape: # new in 1.37 + Enabled: true +Style/ReturnNilInPredicateMethodDefinition: # new in 1.53 + Enabled: true +Style/SelectByRegexp: # new in 1.22 + Enabled: true +Style/SendWithLiteralMethodName: # new in 1.64 + Enabled: true +Style/SingleLineDoEndBlock: # new in 1.57 + Enabled: true +Style/StringChars: # new in 1.12 + Enabled: true +Style/SuperArguments: # new in 1.64 + Enabled: true +Style/SuperWithArgsParentheses: # new in 1.58 + Enabled: true +Style/SwapValues: # new in 1.1 + Enabled: true +Style/YAMLFileRead: # new in 1.53 + Enabled: true +Lint/NoReturnInBeginEndBlocks: # new in 1.2 + Enabled: true +Lint/NonAtomicFileOperation: # new in 1.31 + Enabled: true +Lint/NumberedParameterAssignment: # new in 1.9 + Enabled: true +Lint/OrAssignmentToConstant: # new in 1.9 + Enabled: true +Lint/RedundantDirGlobSort: # new in 1.8 + Enabled: true +Lint/RedundantRegexpQuantifiers: # new in 1.53 + Enabled: true +Lint/RefinementImportMethods: # new in 1.27 + Enabled: true +Lint/RequireRangeParentheses: # new in 1.32 + Enabled: true +Lint/RequireRelativeSelfPath: # new in 1.22 + Enabled: true +Lint/SymbolConversion: # new in 1.9 + Enabled: true +Lint/ToEnumArguments: # new in 1.1 + Enabled: true +Lint/TripleQuotes: # new in 1.9 + Enabled: true +Lint/UnexpectedBlockArity: # new in 1.5 + Enabled: true +Lint/UnmodifiedReduceAccumulator: # new in 1.1 + Enabled: true +Lint/UselessRescue: # new in 1.43 + Enabled: true +Lint/UselessRuby2Keywords: # new in 1.23 + Enabled: true +Metrics/CollectionLiteralLength: # new in 1.47 + Enabled: true +Naming/BlockForwarding: # new in 1.24 + Enabled: true +Security/CompoundHash: # new in 1.28 + Enabled: true +Security/IoMethods: # new in 1.22 + Enabled: true +Style/ArgumentsForwarding: # new in 1.1 + Enabled: true +Style/ArrayIntersect: # new in 1.40 + Enabled: true +Style/CollectionCompact: # new in 1.2 + Enabled: true +Style/ComparableClamp: # new in 1.44 + Enabled: true +Style/ConcatArrayLiterals: # new in 1.41 + Enabled: true +Style/DataInheritance: # new in 1.49 + Enabled: true +Style/DirEmpty: # new in 1.48 + Enabled: true +Style/DocumentDynamicEvalDefinition: # new in 1.1 + Enabled: true +Style/EmptyHeredoc: # new in 1.32 + Enabled: true +Style/EndlessMethod: # new in 1.8 + Enabled: true +Style/EnvHome: # new in 1.29 + Enabled: true +Style/ExactRegexpMatch: # new in 1.51 + Enabled: true +Style/FetchEnvVar: # new in 1.28 + Enabled: true +Style/FileEmpty: # new in 1.48 + Enabled: true +Style/FileRead: # new in 1.24 + Enabled: true +Style/FileWrite: # new in 1.24 + Enabled: true +Style/HashConversion: # new in 1.10 + Enabled: true +Style/HashExcept: # new in 1.7 + Enabled: true +Style/IfWithBooleanLiteralBranches: # new in 1.9 + Enabled: true +Style/InPatternThen: # new in 1.16 + Enabled: true +Style/MagicCommentFormat: # new in 1.35 + Enabled: true +Style/MapCompactWithConditionalBlock: # new in 1.30 + Enabled: true +Style/MapIntoArray: # new in 1.63 + Enabled: true +Style/MapToHash: # new in 1.24 + Enabled: true +Style/MapToSet: # new in 1.42 + Enabled: true +Style/MinMaxComparison: # new in 1.42 + Enabled: true +Style/MultilineInPatternThen: # new in 1.16 + Enabled: true +Style/NegatedIfElseCondition: # new in 1.2 + Enabled: true +Style/NestedFileDirname: # new in 1.26 + Enabled: true +Style/NilLambda: # new in 1.3 + Enabled: true diff --git a/test/using_bundler/Gemfile.lock b/test/using_bundler/Gemfile.lock index 1692780..802cd8b 100644 --- a/test/using_bundler/Gemfile.lock +++ b/test/using_bundler/Gemfile.lock @@ -2,27 +2,33 @@ GEM remote: https://rubygems.org/ specs: ast (2.4.2) - parallel (1.20.1) - parser (3.0.2.0) + json (2.7.2) + language_server-protocol (3.17.0.3) + parallel (1.25.1) + parser (3.3.4.0) ast (~> 2.4.1) - rainbow (3.0.0) - regexp_parser (2.1.1) - rexml (3.2.8) - strscan (>= 3.0.9) - rubocop (1.18.1) + racc + racc (1.8.0) + rainbow (3.1.1) + regexp_parser (2.9.2) + rexml (3.3.2) + strscan + rubocop (1.65.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.0.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.7.0, < 2.0) + regexp_parser (>= 2.4, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.9.0) - parser (>= 3.0.1.1) - ruby-progressbar (1.11.0) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + ruby-progressbar (1.13.0) strscan (3.1.0) - unicode-display_width (2.0.0) + unicode-display_width (2.5.0) PLATFORMS x86_64-linux @@ -31,4 +37,4 @@ DEPENDENCIES rubocop BUNDLED WITH - 2.2.25 + 2.5.11 From 5755da67f323b882957a2fe319f53aa61639abd9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 Aug 2024 22:38:23 -0400 Subject: [PATCH 39/46] Bump rexml from 3.3.2 to 3.3.3 in /test/using_bundler (#118) Bumps [rexml](https://github.com/ruby/rexml) from 3.3.2 to 3.3.3. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.3.2...v3.3.3) --- updated-dependencies: - dependency-name: rexml dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/using_bundler/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/using_bundler/Gemfile.lock b/test/using_bundler/Gemfile.lock index 802cd8b..5963c13 100644 --- a/test/using_bundler/Gemfile.lock +++ b/test/using_bundler/Gemfile.lock @@ -11,7 +11,7 @@ GEM racc (1.8.0) rainbow (3.1.1) regexp_parser (2.9.2) - rexml (3.3.2) + rexml (3.3.3) strscan rubocop (1.65.0) json (~> 2.3) From a162a8e8976d8b3b7141c2147d7d79eed7cc8c4c Mon Sep 17 00:00:00 2001 From: moznion Date: Wed, 21 Aug 2024 12:13:53 +0900 Subject: [PATCH 40/46] Put `${INPUT_RUBOCOP_FLAGS}` at the end of the other flags (#120) Since PR #103 introduced the default --fail-level flag, the severity level has become unchangeable due to this modification. Ideally, this flag (and others) should be overridable, but the RuboCop command prioritizes the flags that are specified last. This commit moves the user-specified flags to the end of the hard-coded flags, allowing them to be overridden. Signed-off-by: moznion --- script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.sh b/script.sh index b34f6b6..9693ca0 100755 --- a/script.sh +++ b/script.sh @@ -123,10 +123,10 @@ fi echo '::group:: Running rubocop with reviewdog 🐶 ...' # shellcheck disable=SC2086 ${BUNDLE_EXEC}rubocop \ - ${INPUT_RUBOCOP_FLAGS} \ --require ${GITHUB_ACTION_PATH}/rdjson_formatter/rdjson_formatter.rb \ --format RdjsonFormatter \ --fail-level error \ + ${INPUT_RUBOCOP_FLAGS} \ "${CHANGED_FILES[@]}" \ | reviewdog -f=rdjson \ -name="${INPUT_TOOL_NAME}" \ From 830b07373152096b81f0dffe86ac14702ab0daa3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Aug 2024 10:28:51 -0400 Subject: [PATCH 41/46] Bump rexml from 3.3.3 to 3.3.6 in /test/using_bundler (#121) Bumps [rexml](https://github.com/ruby/rexml) from 3.3.3 to 3.3.6. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.3.3...v3.3.6) --- updated-dependencies: - dependency-name: rexml dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/using_bundler/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/using_bundler/Gemfile.lock b/test/using_bundler/Gemfile.lock index 5963c13..842e32e 100644 --- a/test/using_bundler/Gemfile.lock +++ b/test/using_bundler/Gemfile.lock @@ -11,7 +11,7 @@ GEM racc (1.8.0) rainbow (3.1.1) regexp_parser (2.9.2) - rexml (3.3.3) + rexml (3.3.6) strscan rubocop (1.65.0) json (~> 2.3) From d89ceac67134c1587b4bc0ad8b55007c533c9c3f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 12:35:14 +0900 Subject: [PATCH 42/46] chore(deps): update reviewdog to 0.20.2 (#122) Co-authored-by: review-dog <22892449+review-dog@users.noreply.github.com> --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 2d32da2..b7f08da 100644 --- a/action.yml +++ b/action.yml @@ -59,7 +59,7 @@ runs: - run: $GITHUB_ACTION_PATH/script.sh shell: sh env: - REVIEWDOG_VERSION: v0.20.1 + REVIEWDOG_VERSION: v0.20.2 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 # Please maintain inputs in alphabetical order From 5e23bb67d79c93e5eb45bdae6d08b04052afec35 Mon Sep 17 00:00:00 2001 From: Pieter C Date: Thu, 19 Sep 2024 12:51:24 +0200 Subject: [PATCH 43/46] Support offenses with no location (#123) --- rdjson_formatter/rdjson_formatter.rb | 30 ++++++++++++++---------- test/rdjson_formatter/testdata/result.ok | 11 +++++++++ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/rdjson_formatter/rdjson_formatter.rb b/rdjson_formatter/rdjson_formatter.rb index 2eea86b..14f1429 100644 --- a/rdjson_formatter/rdjson_formatter.rb +++ b/rdjson_formatter/rdjson_formatter.rb @@ -18,8 +18,6 @@ def started(_target_files) def file_finished(file, offenses) offenses.each do |offense| - next if offense.location == RuboCop::Cop::Offense::NO_LOCATION - @rdjson[:diagnostics] << build_diagnostic(file, offense) end @@ -59,17 +57,7 @@ def build_diagnostic(file, offense) diagnostic = { message: message, location: { - path: convert_path(file), - range: { - start: { - line: offense.location.begin.line, - column: offense.location.begin.column + 1 - }, - end: { - line: offense.location.end.line, - column: offense.location.end.column + 1 - } - } + path: convert_path(file) }, severity: convert_severity(offense.severity), code: { @@ -77,12 +65,28 @@ def build_diagnostic(file, offense) }, original_output: build_original_output(file, offense) } + diagnostic[:location][:range] = build_range(offense) if offense.location != RuboCop::Cop::Offense::NO_LOCATION diagnostic[:suggestions] = build_suggestions(offense) if offense.correctable? && offense.corrector diagnostic end + # @param [RuboCop::Cop::Offense] offense + # @return [Hash] + def build_range(offense) + { + start: { + line: offense.location.begin.line, + column: offense.location.begin.column + 1 + }, + end: { + line: offense.location.end.line, + column: offense.location.end.column + 1 + } + } + end + # @param [RuboCop::Cop::Offense] offense # @return [Array{Hash}] def build_suggestions(offense) diff --git a/test/rdjson_formatter/testdata/result.ok b/test/rdjson_formatter/testdata/result.ok index ba2b016..51116c8 100644 --- a/test/rdjson_formatter/testdata/result.ok +++ b/test/rdjson_formatter/testdata/result.ok @@ -292,6 +292,17 @@ } ] }, + { + "message": "Empty file detected.", + "location": { + "path": "test/rdjson_formatter/testdata/global_offenses.rb" + }, + "severity": "WARNING", + "code": { + "value": "Lint/EmptyFile" + }, + "original_output": "test/rdjson_formatter/testdata/global_offenses.rb:1:1: W: Lint/EmptyFile: Empty file detected." + }, { "message": "Method parameter must be at least 3 characters long.", "location": { From 4018bd7eb1d4ad6d7c0f6e66fac65890aebf7454 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 11:43:02 -0400 Subject: [PATCH 44/46] Bump rexml from 3.3.6 to 3.3.9 in /test/using_bundler (#128) Bumps [rexml](https://github.com/ruby/rexml) from 3.3.6 to 3.3.9. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.3.6...v3.3.9) --- updated-dependencies: - dependency-name: rexml dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- test/using_bundler/Gemfile.lock | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/using_bundler/Gemfile.lock b/test/using_bundler/Gemfile.lock index 842e32e..2a75b52 100644 --- a/test/using_bundler/Gemfile.lock +++ b/test/using_bundler/Gemfile.lock @@ -11,8 +11,7 @@ GEM racc (1.8.0) rainbow (3.1.1) regexp_parser (2.9.2) - rexml (3.3.6) - strscan + rexml (3.3.9) rubocop (1.65.0) json (~> 2.3) language_server-protocol (>= 3.17.0) @@ -27,7 +26,6 @@ GEM rubocop-ast (1.31.3) parser (>= 3.3.1.0) ruby-progressbar (1.13.0) - strscan (3.1.0) unicode-display_width (2.5.0) PLATFORMS From ef7ea4380fa10c72a1671f16f4fa37927c75f42c Mon Sep 17 00:00:00 2001 From: Bilka Date: Mon, 2 Dec 2024 12:29:46 +0100 Subject: [PATCH 45/46] Added input for fail-level reviewdog flag to later replace deprecated fail-on-error reviewdog flag (#124) * Replace deprecated fail-on-error flag with fail-level * Restore fail-on-error flag * Update doc with suggestions --- README.md | 7 +++++++ action.yml | 9 +++++++++ script.sh | 1 + 3 files changed, 17 insertions(+) diff --git a/README.md b/README.md index 7fc2719..e45c49e 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,15 @@ With `reporter: github-pr-review` a comment is added to the Pull Request Convers +### `fail_level` + +Optional. If set to `none`, always use exit code 0 for reviewdog. Otherwise, exit code 1 for reviewdog if it finds at least 1 issue with severity greater than or equal to the given level. +Possible values: [`none`, `any`, `info`, `warning`, `error`] +Default is `none`. + ### `fail_on_error` +Deprecated, use `fail_level` instead. Optional. Exit code for reviewdog when errors are found [`true`, `false`]. Default is `false`. diff --git a/action.yml b/action.yml index b7f08da..b36a557 100644 --- a/action.yml +++ b/action.yml @@ -3,11 +3,19 @@ description: '🐶 Run rubocop with reviewdog on pull requests to improve code r author: 'mgrachev (reviewdog)' inputs: # Please maintain inputs in alphabetical order + fail_level: + description: | + If set to `none`, always use exit code 0 for reviewdog. Otherwise, exit code 1 for reviewdog if it finds at least 1 issue with severity greater than or equal to the given level. + Possible values: [none,any,info,warning,error] + Default is `none`. + default: 'none' fail_on_error: description: | + Deprecated, use `fail_level` instead. Exit code for reviewdog when errors are found [true,false] Default is `false`. default: 'false' + deprecationMessage: Deprecated, use `fail_level` instead. filter_mode: description: | Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. @@ -63,6 +71,7 @@ runs: # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 # Please maintain inputs in alphabetical order + INPUT_FAIL_LEVEL: ${{ inputs.fail_level }} INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }} INPUT_FILTER_MODE: ${{ inputs.filter_mode }} INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} diff --git a/script.sh b/script.sh index 9693ca0..2a69a4c 100755 --- a/script.sh +++ b/script.sh @@ -132,6 +132,7 @@ ${BUNDLE_EXEC}rubocop \ -name="${INPUT_TOOL_NAME}" \ -reporter="${INPUT_REPORTER}" \ -filter-mode="${INPUT_FILTER_MODE}" \ + -fail-level="${INPUT_FAIL_LEVEL}" \ -fail-on-error="${INPUT_FAIL_ON_ERROR}" \ -level="${INPUT_LEVEL}" \ ${INPUT_REVIEWDOG_FLAGS} From cd8c2943f425b54f97095777109ae9f1f2d79a61 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 08:34:15 +0900 Subject: [PATCH 46/46] chore(deps): update reviewdog to 0.20.3 (#131) Co-authored-by: review-dog <22892449+review-dog@users.noreply.github.com> --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index b36a557..accc82d 100644 --- a/action.yml +++ b/action.yml @@ -67,7 +67,7 @@ runs: - run: $GITHUB_ACTION_PATH/script.sh shell: sh env: - REVIEWDOG_VERSION: v0.20.2 + REVIEWDOG_VERSION: v0.20.3 # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 # Please maintain inputs in alphabetical order