Super-linter: LINTER_RULES_PATH has no effect running locally

Created on 11 Dec 2020  ·  7Comments  ·  Source: github/super-linter

Describe the bug

LINTER_RULES_PATH env variable has no effect running locally

Expected behavior

I expect to provide a custom path to the directory with linters rules

Steps to Reproduce

  1. Create a project directory
  2. Create custom/linters/.tflint.hcl with content
rule "terraform_documented_variables" {
  enabled = true
}
  1. Duplicate custom/linters/.tflint.hcl to .github/linters/.tflint.hcl
  2. Create variables.tf with content
variable "test" {}
  1. Run. (Expected failure, but endup with success)
docker run -it \
    -v "${PWD}:/tmp/lint" \
    -e "RUN_LOCAL=true" \
    -e "DEFAULT_WORKSPACE=/tmp/lint" \
    -e "LINTER_RULES_PATH=/tmp/lint/custom/linters" \
    github/super-linter:v3

The end of the log says, success. The expected behavior is FAIL, due to tf vars has no description tag.

2020-12-11 13:30:03 [NOTICE]   All file(s) linted successfully with no errors detected
2020-12-11 13:30:03 [INFO]   ----------------------------------------------
  1. Run without overriding LINTER_RULES_PATH (default: .github/linters) (Expected failure and end up with failure) 👍
docker run -it \
    -v "${PWD}:/tmp/lint" \
    -e "RUN_LOCAL=true" \
    -e "DEFAULT_WORKSPACE=/tmp/lint" \
    github/super-linter:v3

Logs

Log from the bullet - 5 ☝️

 ~/src/github.com/github/super-linter-issue  main ?1  docker run -it \                                                                                                                            ✔  4s  14:23:33 
>     -v "${PWD}:/tmp/lint" \
>     -e "RUN_LOCAL=true" \
>     -e "DEFAULT_WORKSPACE=/tmp/lint" \
>     -e "LINTER_RULES_PATH=/tmp/lint/custom/linters" \
>     github/super-linter:v3
--------------------------------------------------------------------------------

                              /@@#///////@@/(@//@%/(@.@(       @@
                          @@//////////////////////////////#*  @@@
                        @////@//(///////////@@@@@///@//@/@**//@@(
                      @///////@///////////////@@@@    (           @,
                     @/(&/@////////////////////                     @
                    @////////////////////////@@                      @
                  @%////////(//////////%/////&@            @@       *,@           ______________
             @@@@@/@/#/////(&//////////////////                       .@         /              \
        *@@@@@.    .%///(//@//////////////////&.   .@@,                 @%      / Don't mind me  \
      @@%           .&@&&/@.@//&/////(//////////    @@@@@@@@@         .. &@    / I'm just looking \
    @@%               @@@@@   @&/////////////////#   @/       V  @@/ ,@@@ @   <  for some trash... |
@@@%                   @@@@        .%@@@@//////#@ @   @@         @     .,.     \__________________/
                                          @@@/@(  (@@@@% @/\      %
                                           @@@@(    .     .@@/\   #
                                             @                  %@%

--------------------------------------------------------------------------------
2020-12-11 13:29:54 [INFO]   ---------------------------------------------
2020-12-11 13:29:54 [INFO]   --- GitHub Actions Multi Language Linter ----
2020-12-11 13:29:54 [INFO]    - Image Creation Date:[2020-12-07T15:01:16Z]
2020-12-11 13:29:54 [INFO]    - Image Revision:[6093426f1e70b397b1b470faac5af46d3ae5ad1d]
2020-12-11 13:29:54 [INFO]    - Image Version:[6093426f1e70b397b1b470faac5af46d3ae5ad1d]
2020-12-11 13:29:54 [INFO]   ---------------------------------------------
2020-12-11 13:29:54 [INFO]   ---------------------------------------------
2020-12-11 13:29:54 [INFO]   The Super-Linter source code can be found at:
2020-12-11 13:29:54 [INFO]    - https://github.com/github/super-linter
2020-12-11 13:29:54 [INFO]   ---------------------------------------------
2020-12-11 13:29:54 [INFO]   --------------------------------------------
2020-12-11 13:29:54 [INFO]   Gathering GitHub information...
2020-12-11 13:29:54 [INFO]   NOTE: ENV VAR [RUN_LOCAL] has been set to:[true]
2020-12-11 13:29:54 [INFO]   bypassing GitHub Actions variables...
2020-12-11 13:29:54 [INFO]   Linting all files in mapped directory:[/tmp/lint]
2020-12-11 13:29:54 [INFO]   Successfully found:[GITHUB_TOKEN]
2020-12-11 13:29:54 [INFO]   --------------------------------------------
2020-12-11 13:29:54 [INFO]   Gathering user validation information...
2020-12-11 13:29:58 [INFO]   ---------------------------------
2020-12-11 13:29:58 [INFO]   ------ File list to check: ------
2020-12-11 13:29:58 [INFO]   ---------------------------------
2020-12-11 13:29:58 [INFO]   ----------------------------------------------
2020-12-11 13:29:58 [INFO]   Successfully gathered list of files...
2020-12-11 13:30:00 [INFO]   
2020-12-11 13:30:00 [INFO]   ----------------------------------------------
2020-12-11 13:30:00 [INFO]   ----------------------------------------------
2020-12-11 13:30:00 [INFO]   Linting [MARKDOWN] files...
2020-12-11 13:30:00 [INFO]   ----------------------------------------------
2020-12-11 13:30:00 [INFO]   ----------------------------------------------
2020-12-11 13:30:00 [INFO]   ---------------------------
2020-12-11 13:30:00 [INFO]   File:[/tmp/lint/README.md]
2020-12-11 13:30:00 [INFO]    - File:[README.md] was linted with [markdownlint] successfully
2020-12-11 13:30:01 [INFO]   
2020-12-11 13:30:01 [INFO]   ----------------------------------------------
2020-12-11 13:30:01 [INFO]   ----------------------------------------------
2020-12-11 13:30:01 [INFO]   Linting [TERRAFORM] files...
2020-12-11 13:30:01 [INFO]   ----------------------------------------------
2020-12-11 13:30:01 [INFO]   ----------------------------------------------
2020-12-11 13:30:01 [INFO]   ---------------------------
2020-12-11 13:30:01 [INFO]   File:[/tmp/lint/variables.tf]
2020-12-11 13:30:01 [INFO]    - File:[variables.tf] was linted with [tflint] successfully
2020-12-11 13:30:01 [INFO]   
2020-12-11 13:30:01 [INFO]   ----------------------------------------------
2020-12-11 13:30:01 [INFO]   ----------------------------------------------
2020-12-11 13:30:01 [INFO]   Linting [TERRAFORM_TERRASCAN] files...
2020-12-11 13:30:01 [INFO]   ----------------------------------------------
2020-12-11 13:30:01 [INFO]   ----------------------------------------------
2020-12-11 13:30:01 [INFO]   ---------------------------
2020-12-11 13:30:01 [INFO]   File:[/tmp/lint/variables.tf]
2020-12-11 13:30:02 [INFO]    - File:[variables.tf] was linted with [terrascan] successfully
2020-12-11 13:30:03 [INFO]   
2020-12-11 13:30:03 [INFO]   ----------------------------------------------
2020-12-11 13:30:03 [INFO]   ----------------------------------------------
2020-12-11 13:30:03 [INFO]   Linting [XML] files...
2020-12-11 13:30:03 [INFO]   ----------------------------------------------
2020-12-11 13:30:03 [INFO]   ----------------------------------------------
2020-12-11 13:30:03 [INFO]   ---------------------------
2020-12-11 13:30:03 [INFO]   File:[/tmp/lint/.idea/misc.xml]
2020-12-11 13:30:03 [INFO]    - File:[misc.xml] was linted with [xmllint] successfully
2020-12-11 13:30:03 [INFO]   ---------------------------
2020-12-11 13:30:03 [INFO]   File:[/tmp/lint/.idea/modules.xml]
2020-12-11 13:30:03 [INFO]    - File:[modules.xml] was linted with [xmllint] successfully
2020-12-11 13:30:03 [INFO]   ---------------------------
2020-12-11 13:30:03 [INFO]   File:[/tmp/lint/.idea/vcs.xml]
2020-12-11 13:30:03 [INFO]    - File:[vcs.xml] was linted with [xmllint] successfully
2020-12-11 13:30:03 [INFO]   ---------------------------
2020-12-11 13:30:03 [INFO]   File:[/tmp/lint/.idea/workspace.xml]
2020-12-11 13:30:03 [INFO]    - File:[workspace.xml] was linted with [xmllint] successfully
2020-12-11 13:30:03 [INFO]   ----------------------------------------------
2020-12-11 13:30:03 [INFO]   ----------------------------------------------
2020-12-11 13:30:03 [INFO]   Generated reports:
2020-12-11 13:30:03 [INFO]   ----------------------------------------------
2020-12-11 13:30:03 [INFO]   ----------------------------------------------
2020-12-11 13:30:03 [INFO]   Reports generated in folder /tmp/lint/super-linter.report
2020-12-11 13:30:03 [WARN]   Report output folder (/tmp/lint/super-linter.report) does NOT exist.
2020-12-11 13:30:03 [INFO]   ----------------------------------------------
2020-12-11 13:30:03 [INFO]   ----------------------------------------------
2020-12-11 13:30:03 [INFO]   The script has completed
2020-12-11 13:30:03 [INFO]   ----------------------------------------------
2020-12-11 13:30:03 [INFO]   ----------------------------------------------
2020-12-11 13:30:03 [NOTICE]   All file(s) linted successfully with no errors detected
2020-12-11 13:30:03 [INFO]   ----------------------------------------------

Additional context

Test repository: https://github.com/zhenik/super-linter-LINTER_RULES_PATH-issue

bug

Most helpful comment

Hi @zhenik ! The LINTER_RULES_PATH is relative to DEFAULT_WORKSPACE, as seen in https://github.com/github/super-linter/blob/7943ce1f541fc84bcc0789028dc73aee047f72b3/lib/functions/linterRules.sh#L75 and https://github.com/github/super-linter/blob/7943ce1f541fc84bcc0789028dc73aee047f72b3/lib/functions/linterRules.sh#L99

To be fair, we don't point this out in the README, and, moreover, the guidance https://github.com/github/super-linter/blob/2a524ad1b0498ff81dc993b723429dfd357a9f30/docs/using-rules-files.md seems to imply that LINTER_RULES_PATH is an absolute path instead.

@admiralAwkbar I suppose there's room to improve the docs. Thoughts?

All 7 comments

Hi @zhenik ! The LINTER_RULES_PATH is relative to DEFAULT_WORKSPACE, as seen in https://github.com/github/super-linter/blob/7943ce1f541fc84bcc0789028dc73aee047f72b3/lib/functions/linterRules.sh#L75 and https://github.com/github/super-linter/blob/7943ce1f541fc84bcc0789028dc73aee047f72b3/lib/functions/linterRules.sh#L99

To be fair, we don't point this out in the README, and, moreover, the guidance https://github.com/github/super-linter/blob/2a524ad1b0498ff81dc993b723429dfd357a9f30/docs/using-rules-files.md seems to imply that LINTER_RULES_PATH is an absolute path instead.

@admiralAwkbar I suppose there's room to improve the docs. Thoughts?

@zhenik can you also run this again with setting ACTIONS_RUNNER_DEBUG=true? Thanks!

@zhenik can you also run this again with setting ACTIONS_RUNNER_DEBUG=true? Thanks!

There is quite a long output. I guess you are specifically interested in the env variable LINTER_RULES_PATH.

in the output, it has one entry

LINTER_RULES_PATH=/tmp/lint/custom/linters

when I executed

docker run -it \
    -v "${PWD}:/tmp/lint" \
    -e "RUN_LOCAL=true" \
    -e "DEFAULT_WORKSPACE=/tmp/lint" \
    -e "LINTER_RULES_PATH=/tmp/lint/custom/linters" \
    -e "ACTIONS_RUNNER_DEBUG=true" \
    github/super-linter:v3

Or you would like me to post the whole output as a gist?

Thanks for the output! Can you also include the part where super-linter picks up the configuration files, just before running the linters?

Thanks for the output! Can you also include the part where super-linter picks up the configuration files, just before running the linters?

I post the log in the gist here https://gist.github.com/zhenik/28631efb3f742bc0c7c89825d22eafc9#file-log-txt

Here's what's happening: https://gist.github.com/zhenik/28631efb3f742bc0c7c89825d22eafc9#file-log-txt-L1218

2020-12-12 09:07:54 [DEBUG]   Checking if the user-provided:[.tflint.hcl] and exists at:[/tmp/lint//tmp/lint/custom/linters/.tflint.hcl]
2020-12-12 09:07:54 [DEBUG]     -> Codebase does NOT have file:[/tmp/lint//tmp/lint/custom/linters/.tflint.hcl].
2020-12-12 09:07:54 [DEBUG]     -> Codebase does NOT have file:[/tmp/lint//tmp/lint/custom/linters/.tflint.hcl], nor the file:[], using Default rules at:[/action/lib/.automation/.tflint.hcl]

This is consistent with what I suggested above (LINTER_RULES_PATH is relative to the workspace). To solve your issue, try setting it to custom/linters.

I suppose we might keep this open as a reminder to possibly improve the docs. Thoughts? @admiralAwkbar

Thanks for input. It resolves my issue. Would be nice to have information about relative path in documentation.

@ferrarimarco I can give you a hand with documentation update, just let me know.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sergey-muntyanu picture sergey-muntyanu  ·  4Comments

ymd-h picture ymd-h  ·  3Comments

zkoppert picture zkoppert  ·  3Comments

MuhaddiMu picture MuhaddiMu  ·  3Comments

thehesiod picture thehesiod  ·  4Comments