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 problem matcher config for pull request annotations #137

Open
nschonni opened this issue Feb 26, 2023 · 2 comments
Open

Add problem matcher config for pull request annotations #137

nschonni opened this issue Feb 26, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@nschonni
Copy link

See https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md for the basic JSON schema for the matcher and about the registration of the matcher

@jidicula
Copy link
Owner

This is a cool feature idea! On first glance, I'm thinking this would be useful to annotate each incorrectly formatted file in a PR diff - is this what you had in mind?

For a use-case, I'm trying to think through what scenarios would lead a user to this feature being useful - could you elaborate on that a bit more?

Here are my initial thoughts on such scenarios:

clang-format is notoriously hard to configure to ignore specific files (ignores can be set up for all files in a directory) without some wrapper scripting, so (to my knowledge) most projects would take the dive of just formatting their project all at once and/or configuring format-on-save for their editor's project settings, coupled with some per-directory .clang-format settings files if some parts of the project need to remain unformatted or formatted differently. So, annotations in a PR marking which files are unformatted aren't much use when the least error-prone flow is to run clang-format on the entire project (if you don't format on save) to fix a CI failure from my Action.

@jidicula jidicula added the enhancement New feature or request label Feb 26, 2023
@nschonni
Copy link
Author

The annotations are usually more useful in quickly surfacing what the issues are directly in the Files tab, instead of having to drill through to the CI log. I think the assumption of it being clean normally on a repo is true, but this is helpful for PRs.

Since clang-format does emit the position information, I think the config would look something like

{
  "problemMatcher": [
    {
      "owner": "eslint-compact",
      "pattern": [
        {
          "regexp": "^(.+):(\\d+):(\\d+):\\s(error)\\s:\\s(.+)\\s\\[(.+)\\]$",
          "file": 1,
          "line": 2,
          "column": 3,
          "severity": 4,
          "message": 5,
          "code": 6
        }
      ]
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants