Linter errors as annotations, even for fork PRs.
Wrap your linter invocations with Problem Matcher add/remove to let GitHub actions detect any errors and warnings and show them as annotations. As opposed to existing Actions which use the Checks API, this one works correctly even for Pull Requests from forks, which is otherwise problematic and probably isn't getting fixed any time soon.
Problem Matcher wrapper works differently (and happens to be much simpler):
- Tell GitHub Actions how to recognize errors in linter output
- Run the linter, any way you like (run command, docker, another action, …)
- Tell GitHub Actions to stop looking for errors of this particular linter so that we can safely run other linters
A screenshot and an example (further down) is worth a thousand words:
- name: flake8
uses: liskin/gh-problem-matcher-wrap@v1
with:
linters: flake8
run: flake8 src/
- name: mypy
uses: liskin/gh-problem-matcher-wrap@v1
with:
linters: mypy
run: mypy --show-column-numbers src/
- name: isort
uses: liskin/gh-problem-matcher-wrap@v1
with:
linters: isort
run: isort --check src/
- name: pytest
uses: liskin/gh-problem-matcher-wrap@v1
with:
linters: pytest
run: pytest
- uses: liskin/gh-problem-matcher-wrap@v1
with:
action: add
linters: flake8, mypy
- name: Lint
run: |
# possibly complex multiline shell script
flake8 src/
mypy --show-column-numbers src/
- uses: liskin/gh-problem-matcher-wrap@v1
with:
action: remove
linters: flake8, mypy
linters
- Comma or whitespace separated list of Problem Matchers to add/remove.
- (Required)
run
- Command to run.
- (Required unless
action
isadd
orremove
)
action
- If set to
add
orremove
, do not run any command, just add/remove Problem Matchers. - (Default:
run
)
- If set to
For details, sources and licenses of individual problem matchers, see problem-matchers/.
Pull Requests with additional linters welcome!