hadolint / hadolint-action

GitHub action for Hadolint, A Dockerfile linting tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[INVESTIGATED/TESTED] Configuration File Pathing Issue + Subsequent Issue

kgrv-me opened this issue · comments

Please refer to PR #59 for detailed solutions.

ISSUES

  • hadolint-action cannot receive configuration file properly
  • Conflict infomation betweenREADME.md and action.yml
    • inputs.config.default is empty in action.yml, while README.md states otherwise
    • Default path stated in README.md would still encounter the above issue
  • (Edited) the official hadolint/hadolint:latest container also suffers from configuration file issue

TEST CASES

  • All done within GitHub Actions workflow
  • All results in failure to receive configuration file
- uses: hadolint/hadolint-action@v2.1.0
  with:
    config: PATH

Substitute PATH with the followings:

hadolint.yaml
./hadolint.yaml
.hadolint.yaml
/home/runner/work/sandbox/sandbox/hadolint.yaml

INVESTIGATION

  1. hadolint looks for configuration files via
$PWD/.hadolint.yaml
$XDG_CONFIG_HOME/hadolint.yaml
$HOME/.config/hadolint.yaml
$HOME/.hadolint/hadolint.yaml or $HOME/hadolint/config.yaml
$HOME/.hadolint.yaml

NOTE hadolint-action utilizes Docker container for execution

  1. hadolint uses PWD and HOME environment variables
  2. action.yml maps inputs.config to HADOLINT_CONFIG
  3. Dockerfile points to hadolint.sh for entrypoint
  4. hadolint.sh appends -c ${HADOLINT_CONFIG} to hadolint command
  5. hadolint-action uses Docker with
docker run .. --workdir /github/workspace .. -v "/home/runner/work/sandbox/sandbox":"/github/workspace" ..
  1. PWD=/ and HOME=/root inside the container

CONCLUSION

  1. Since pwd inside the container isn't matching with PWD nor HOME, hadolint cannot find configuration file in usual places
  2. Knowing pwd and -v for the container, we can edit PATH to be /github/workspace/hadolint.yaml for hadolint-action to use

SUGGESTION

  • Document the usage in README.md accordingly (CONCLUSION.2)
    or
  • Change PWD/HOME in Dockerfile to accommodate the differences
    or
  • Prepend /github/workspace/ to the path of configuration file
    or preferably all of the above! :D
  • Please consider adding MAJOR_VERSION tag for the release (#47)

Thank you!

Would you like to submit a change with those fixes?

@lorenzo I could definitely do that! How would I proceed to do so?
EDIT: I have opened PR #59 for the solutions :D