rbialon / flake8-annotations

Flake8 Problem Matcher / Annotations for Github Checks
MIT License
17 stars 8 forks source link

does not annotate the Pull Request - only the whole repo #5

Open securestep9 opened 4 years ago

securestep9 commented 4 years ago

when running the GitHub action on a pull request annotations are generated for the whole repo and PR is marked as failed due to errors elsewhere. The action should add annotations on a PR only - on files modified by the PR

rbialon commented 4 years ago

Thanks for the suggestion! I'm not quite sure if this is possible using the Github Action's regex parser (or problem matcher, as they call it), as we simply specify which part of flake8 output should be used for which part of the annotations. There is no configuration from which files the output should be used. It is searching through flake8's whole output and not acting on single files.

To keep this annotator universal, I'd suggest restricting flake8 to the files changed within the PR so that only the changed parts will be linted. One way to achieve this is presented in this Medium article, the variables might have to be changed:

DIFF=$(git diff --name-only --diff-filter=b $(git merge-base HEAD $BRANCH))
flake8 $DIFF