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

hadolint_output is empty #147

Open
pascalgulikers opened this issue Feb 20, 2024 · 6 comments
Open

hadolint_output is empty #147

pascalgulikers opened this issue Feb 20, 2024 · 6 comments
Assignees
Labels
type: bug Something isn't working as expected

Comments

@pascalgulikers
Copy link

pascalgulikers commented Feb 20, 2024

- uses: jbergstroem/hadolint-gh-action@v1
  id: hadolint
  with:
    dockerfile: ./Dockerfile
    #output_format: sarif

- name: Debug
  shell: bash
  run: |
    echo "${{ steps.hadolint.outputs.hadolint_version }}"
    echo "${{ steps.hadolint.outputs.hadolint_gh_action_version }}"
    echo "${{ steps.hadolint.outputs.hadolint_output }}"

Produces:
Run echo "2.12.0"
echo "2.12.0"
echo "1.12.0"
echo ""

In other words: the hadolint_output output variable is empty, no matter which output_format is specified.
It looks like it's being caused by:

echo "hadolint_output=${OUTPUT//$'\n'/'%0A'} >> \$GITHUB_OUTPUT"

Possible solution:
change
echo "hadolint_output=${OUTPUT//$'\n'/'%0A'} >> \$GITHUB_OUTPUT"
to
echo "hadolint_output=${OUTPUT//$'\n'/'%0A'}" >> "${GITHUB_OUTPUT}"

@jbergstroem
Copy link
Owner

Thanks for the bug report. Will look at it tonight!

@jbergstroem jbergstroem self-assigned this Feb 20, 2024
@jbergstroem jbergstroem added the type: bug Something isn't working as expected label Feb 20, 2024
@jbergstroem
Copy link
Owner

jbergstroem commented Feb 20, 2024

Was able to repro with the draft PR as a e2e test. Here's the problem:

++ eval hadolint --no-fail --no-color '' -f json test/fixtures/Dockerfile-warning
+++ hadolint --no-fail --no-color -f json test/fixtures/Dockerfile-warning
+ OUTPUT='[{"code":"DL3018","column":1,"file":"test/fixtures/Dockerfile-warning","level":"warning","line":3,"message":"Pin versions in apk add. Instead of `apk add <package>` use `apk add <package>=<version>`"}]'
+ echo 'hadolint_output=[{"code":"DL3018","column":1,"file":"test/fixtures/Dockerfile-warning","level":"warning","line":3,"message":"Pin versions in apk add. Instead of `apk add <package>` use `apk add <package>=<version>`"}] >> /dev/null'
hadolint_output=[{"code":"DL3018","column":1,"file":"test/fixtures/Dockerfile-warning","level":"warning","line":3,"message":"Pin versions in apk add. Instead of `apk add <package>` use `apk add <package>=<version>`"}] >> /dev/null

Note: the e2e test is incorrect as well.

@jbergstroem
Copy link
Owner

Been chasing this for a bit. I believe that parsing %0A (newline escaping) might have changed in github actions.

@pascalgulikers
Copy link
Author

Any update on this?

@jbergstroem
Copy link
Owner

Any update on this?

Been busy with work; will make an re-attempt at the fix this week. Sorry for the delay.

@pascalgulikers
Copy link
Author

Sorry, is there any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

2 participants