Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-fail-on-error doesn't work. reviewdog returns zero as exit code even if warnings are found in input #1408

Open
suzuki-shunsuke opened this issue Apr 19, 2023 · 5 comments

Comments

@suzuki-shunsuke
Copy link

suzuki-shunsuke commented Apr 19, 2023

This is a bug report of -fail-on-error option. Even if warnings are found in input, reviewdog command returns zero as exit code.

  -fail-on-error
    	Returns 1 as exit code if any errors/warnings found in input

How to reproduce

$ reviewdog --version
0.14.1
$ tflint -v
TFLint version 0.46.0
+ ruleset.terraform (0.2.2-bundled)

main.tf

// hello
$ tflint --format checkstyle --module
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle>
  <file name="">
    <error rule="terraform_required_version" line="0" column="0" severity="warning" message="terraform &#34;required_version&#34; attribute is required" link="https://github.com/terraform-linters/tflint-ruleset-terraform/blob/v0.2.2/docs/rules/terraform_required_version.md"></error>
  </file>
</checkstyle>
$ tflint --format checkstyle --module |
            reviewdog \
              -f checkstyle \
              -name tflint \
              -filter-mode nofilter \
              -reporter github-pr-check \
              -level warning \
              -fail-on-error 1
reviewdog: Reporting results for "tflint"
Warning: [tflint] reported by reviewdog 🐶
terraform "required_version" attribute is required

Raw Output:
:0:0: warning: terraform "required_version" attribute is required ()

$ echo "$?"
0

Expected behaviour

The exit code of reviewdog command is not zero because warning is outputted.

Actual behaviour

The exit code of reviewdog command is zero.

@suzuki-shunsuke suzuki-shunsuke changed the title -fail-on-error doesn't work. reviewdog returns zero as exit code even if warnings are found in input -fail-on-error doesn't work. reviewdog returns zero as exit code even if warnings are found in input Apr 19, 2023
@dobesv
Copy link

dobesv commented Aug 23, 2023

I've been seeing the same thing, the output logs show errors but it doesn't exit 1. It doesn't even report the error to GitHub. It doesn't seem to be very consistent.

@fharper
Copy link

fharper commented Aug 23, 2023

I had the same issue, so I decided to run vale manually. Here's my workaround steps:

- name: Get latest version of Vale
  id: lastversion
  uses: dvershinin/lastversion-action@v0.0.3
  with:
    repository: errata-ai/vale

- name: Install Vale
  run: |
    wget https://github.com/errata-ai/vale/releases/download/v${{ steps.lastversion.outputs.last_version }}/vale_${{ steps.lastversion.outputs.last_version }}_Linux_64-bit.tar.gz -O vale.tar.gz
    tar -xvzf vale.tar.gz vale
    rm vale.tar.gz

- name: Validate the syntax
  run: ./vale --config=.vale.ini *.md

The vale command has the proper exit code, so the workflow will fail or succeed normally.

You can skip the first step, and wget the direct link if you want to use a specific version, instead of using the latest.

@dobesv
Copy link

dobesv commented Aug 24, 2023

Here's an example of how one format reports failure, the other doesn't:

Run with eslint output format:

/path/to/file
  14:3  error  Delete `··`  prettier/prettier

✖ 1 problem (1 error, 0 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.

  14:3  error  Delete `··`  prettier/prettier
reviewdog: input data has violations
ERROR: "lint:graphql" exited with 1.

Run with rdjson format:

{"source":{"name":"eslint","url":"https://eslint.org/"},"diagnostics":[{"message":"Delete `··`","location":{"path":"/home/dobes/projects/formative/app.fixups/packages/main/src/ui/client/teamMember/commandCenter/sections/ManageOneRosters/ManageOneRoster.graphql","range":{"start":{"line":14,"column":3},"end":{"line":14,"column":5}}},"severity":"ERROR","code":{"value":"prettier/prettier","url":"https://github.com/prettier/eslint-plugin-prettier#options"},"original_output":"{\"ruleId\":\"prettier/prettier\",\"severity\":2,\"message\":\"Delete `··`\",\"line\":14,\"column\":3,\"nodeType\":null,\"messageId\":\"delete\",\"endLine\":14,\"endColumn\":5,\"fix\":{\"range\":[220,222],\"text\":\"\"}}","suggestions":[{"range":{"start":{"line":14,"column":3},"end":{"line":14,"column":5}},"text":""}]}]}
ERROR: "lint:graphql" exited with 1.

@dobesv
Copy link

dobesv commented Aug 24, 2023

Actually, I think my comments above are inaccurate. I wasn't passing -format rdjson in those cases, so it wasn't parsing the linter output.

suzuki-shunsuke added a commit to suzuki-shunsuke/github-action-tfsec that referenced this issue Oct 22, 2023
suzuki-shunsuke added a commit to suzuki-shunsuke/trivy-config-action that referenced this issue Oct 22, 2023
suzuki-shunsuke added a commit to suzuki-shunsuke/github-action-tfsec that referenced this issue Oct 22, 2023
suzuki-shunsuke added a commit to suzuki-shunsuke/trivy-config-action that referenced this issue Oct 22, 2023
@ramonvermeulen
Copy link

ramonvermeulen commented Apr 9, 2024

Facing the same issue, using errata-ai/vale-action@reviewdog version 3.4.1 with reviewdog version 0.17.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants