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

"add-matcher" doesn't work from within a Docker container #305

Closed
TrueBrain opened this issue Nov 7, 2019 · 5 comments
Closed

"add-matcher" doesn't work from within a Docker container #305

TrueBrain opened this issue Nov 7, 2019 · 5 comments
Assignees

Comments

@TrueBrain
Copy link

Describe the bug
#56 (comment) suggests that "add-matcher" works from within a Docker container. I couldn't find a way to get this to work. "add-matcher" always uses the host file-system to lookup the file, and can't read a file from the Docker container (that I could find).

To Reproduce
See https://github.com/TrueBrain/actions-flake8/blob/initial_work/entrypoint.sh#L5.
Removing the cp on line 4 and use flake8-matcher.json instead of the full path on line 5. This will result in a "file not found" error.

Expected behavior
"add-matcher" to work from within a Docker container.

Additional context
Honestly, I can fully understand that "add-matcher" uses the host file-system. So maybe this is not a bug or unexpected.

The main thing that is puzzling me a bit, is that the comment linked suggests it should work. But I couldn't find any example of this, and the documentation doesn't talk about this. So I am not sure. As a result: this ticket, in the hope one of you can shed some light on this topic :)

If the cp is the expected solution, I would love to get some pointers what a good folder is to copy this to. Using the workflow folder for this feels a bit ugly.
Or possibly my solution is just completely bananas, and you have a much better solution in mind.

Tnx!

@TrueBrain TrueBrain changed the title "add-matcher" doesn't work from within a Docker "add-matcher" doesn't work from within a Docker container Nov 7, 2019
@ericsciple ericsciple self-assigned this Nov 12, 2019
@dnorth98
Copy link

I had exactly the same problem when I was putting together an action for Rubocop (https://github.com/rewindio/github-action-rubocop). I ended up having to copy the matcher json to the host in my script:

# With problem matchers in a container, the matcher config MUST be available outside the container on the VM
# So we will just copy it into the workspace

matcher_path=`pwd`/rubocop-problem-matcher.json
cp /rubocop-problem-matcher.json "$matcher_path"

# Note here that we do not use the matcher-path since this is a bind mount into the container
# and is not the same path outside the container on the VM.  Instead, just use current dir
echo "::add-matcher::rubocop-problem-matcher.json"   

It works but feels a bit hacky. Would sure be nice if the matcher could be read inside the container.

@bbugh
Copy link

bbugh commented Nov 22, 2019

@dnorth98 thank you so much for this tip. I was banging my head against the wall trying every configuration I could think of to get it to find the file. It would be better not to hack it, and I'm happy to just have the action working for now.

@ericsciple ericsciple transferred this issue from actions/toolkit Jan 13, 2020
@ericsciple
Copy link
Contributor

$RUNNER_TEMP should also work. Basically it has to be copied to one of the mapped directories since the runner is running on the host.

@ericsciple ericsciple transferred this issue from actions/runner Jan 13, 2020
@ericsciple
Copy link
Contributor

ericsciple commented Feb 13, 2020

Updated docs too early #341 with the guidance:

cp /eslint-compact.json "$HOME/"
echo "::add-matcher::$HOME/eslint-compact.json

However, bug in the runner preventing that from working. Fixed the bug just now actions/runner#331 . After the new runner rolls out (sometime over next couple weeks), will restore guidance in docs.

@TrueBrain
Copy link
Author

Been a while, but I finally got to testing the $HOME solution. Works like a charm :) Thank you very much!

mblottiere added a commit to mblottiere/hadolint-action that referenced this issue Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
@bbugh @TrueBrain @dnorth98 @ericsciple and others