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:
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.
Solved! Solved! Go to Solution.
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.