reviewdog / action-tflint

Run tflint with reviewdog on pull requests to enforce best practices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected filter_mode behavior

jason-huling opened this issue Β· comments

I've done a little more research into this issue and think that there is either an issue with tflint's output and the reviewdog filter_mode, or I have a misunderstanding of how filter_mode is supposed to behave πŸ˜„ .

For troubleshooting I have forked and modified setup.sh here: https://github.com/jason-huling/action-tflint/blob/flag-bugfix/script.sh

I ended up creating some other errors at different tflint severities in the same file and even the same variable. At a high level I noticed that my flags: "--config=.tflint.hcl" was getting picked up correctly, but only the warnings from tflint were being output. I noticed the other issues from tflint were output as "Notices", which translated to info for checkstyle format. Based on this I set level: info but still didn't work.

Once I set filter_mode: nofilter it worked as expected, but I would expect that the default filter_mode: added would have worked as well.

Below is the GitHub Action output from my forked action:

> Run jason-huling/action-tflint@flag-bugfix
> 🐢 Installing reviewdog ... https://github.com/reviewdog/reviewdog
> Installing tflint ... https://github.com/terraform-linters/tflint
INPUT_LEVEL=info

> Running raw tflint ...
  3 issue(s) found:
  
  Notice: `foo` variable has no description (terraform_documented_variables)
  
    on variables.tf line 80:
    80: variable "foo" {
  
  Reference: https://github.com/terraform-linters/tflint/blob/v0.21.0/docs/rules/terraform_documented_variables.md
  
  Notice: `bar` variable has no description (terraform_documented_variables)
  
    on variables.tf line 86:
    86: variable "bar" {
  
  Reference: https://github.com/terraform-linters/tflint/blob/v0.21.0/docs/rules/terraform_documented_variables.md
  
  Warning: Single line comments should begin with # (terraform_comment_syntax)
  
    on variables.tf line 87:
    87:   // description = "bar description"
    88:   type    = string
  
  Reference: https://github.com/terraform-linters/tflint/blob/v0.21.0/docs/rules/terraform_comment_syntax.md

 Running tflint with reviewdog 🐢 ...
  <?xml version="1.0" encoding="UTF-8"?>
  <checkstyle>
    <file name="variables.tf">
      <error rule="terraform_documented_variables" line="80" column="1" severity="info" message="`foo` variable has no description" link="https://github.com/terraform-linters/tflint/blob/v0.21.0/docs/rules/terraform_documented_variables.md"></error>
      <error rule="terraform_documented_variables" line="86" column="1" severity="info" message="`bar` variable has no description" link="https://github.com/terraform-linters/tflint/blob/v0.21.0/docs/rules/terraform_documented_variables.md"></error>
      <error rule="terraform_comment_syntax" line="87" column="3" severity="warning" message="Single line comments should begin with #" link="https://github.com/terraform-linters/tflint/blob/v0.21.0/docs/rules/terraform_comment_syntax.md"></error>
    </file>
  </checkstyle>variables.tf:87:3: warning: Single line comments should begin with # ()
  reviewdog: input data has violations

Original Issue Description

I was testing this action and intentionally added a non-default violation that should trigger terraform_documented_variables.

When running locally with my .tflint.hcl file which has this enabled, the issue was found when setting --config=.tflint.hcl. It also was found when using --enable-rule=terraform_documented_variables. It was not found when these flags were not used.

This action never found issues when trying to use flags: "--enable-rule=terraform_documented_variables" or flags: "--config=.tflint.hcl".

I then tried causing a violation for an action that is enabled by default terraform_deprecated_interpolation, and the action found the issue.

I also tried using https://github.com/lablabs/setup-tflint and it worked as expected.

Hey @jason-huling !

Apologies for getting back to you so late, I had no time to allocate to this 😞 But I am back now! πŸŽ‰

Hm... this is indeed an weird one. I assume it's still valid? If that is the case, can you please re-create a PR on jason-huling/action-tflint so we can check it out together? GitHub Actions cleaned up the history on that repo and I can't see any actions.

Closing due to timeout. Feel free to re-open if it's still relevant!