Skip to content

Invoke linters, detect errors/warnings, show them as annotations. Supports PRs from forks, unlike other Actions.

License

Notifications You must be signed in to change notification settings

jbrownsw/gh-problem-matcher-wrap

 
 

Repository files navigation

GitHub Action: Problem Matcher wrapper

GitHub License GitHub release (latest SemVer) GitHub commits since latest release (by SemVer)

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):

  1. Tell GitHub Actions how to recognize errors in linter output
  2. Run the linter, any way you like (run command, docker, another action, …)
  3. 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:

screenshot

Usage

    - 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

Parameters

  • linters
    • Comma or whitespace separated list of Problem Matchers to add/remove.
    • (Required)
  • run
    • Command to run.
    • (Required unless action is add or remove)
  • action
    • If set to add or remove, do not run any command, just add/remove Problem Matchers.
    • (Default: run)

Supported linters

For details, sources and licenses of individual problem matchers, see problem-matchers/.

Pull Requests with additional linters welcome!

About

Invoke linters, detect errors/warnings, show them as annotations. Supports PRs from forks, unlike other Actions.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 90.1%
  • Makefile 9.9%