Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 3
Message 1 of 2

problem matcher not found in Docker action

Solved! Go to Solution.

So I've created a github action that is Docker based and using the new(ish) problem matcher to handle some output from Rubocop.  The problem I have is that the command doesn't seem to be able to find the problem matcher json file yet it's inside the container.

 

The action is here: https://github.com/rewindio/github-action-rubocop

 

It is very straightforward:

 

Simple docker image that runs a shell script (entrypoint.sh):

 

 

RUN gem install rubocop --no-document

COPY entrypoint.sh /entrypoint.sh

COPY rubocop-problem-matcher.json /rubocop-problem-matcher.json

ENTRYPOINT ["/entrypoint.sh"]

 

The command in the entrypoint script then is just:

 

echo "::add-matcher::/rubocop-problem-matcher.json"   

The file must be there because the entrypoint file is and it's invoked.  However, when the action runs, it fails with:

 

Running Rubocop...
::add-matcher::/rubocop-problem-matcher.json
##[error]Unable to process command '::add-matcher::/rubocop-problem-matcher.json' successfully.
##[error]Could not find file '/rubocop-problem-matcher.json'.

Is there something different about using problem matchers in containers?  Alas, all of the examples (setup-node, setup-python) are JS actions which are not Docker based.  I feel I'm missing something about how it's trying to locate the file when it's container based.

 

1 Reply
Solution
Copilot Lvl 3
Message 2 of 2

Re: problem matcher not found in Docker action

Just solved this.  It's not obvious but the matcher config json must be available OUTSIDE the action container.  What I ended up doing was copying it into the current workspace. So in my entrypoint.sh file:

 

matcher_path=`pwd`/rubocop-problem-matcher.json

cp /rubocop-problem-matcher.json "$matcher_path"

echo "::add-matcher::rubocop-problem-matcher.json"   

(needs a bit of a cleanup).  The key thing is that the workspace path is mapped in the docker container so when you echo the add-matcher command, you cannot use the full path of the file (since that is inside the container).

 

But...it works!  Have to say, problem matchers are BRILLIANT and vastly simplify the process of getting annotations back to pull requests.