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 reporter for outputing Reviewdog JSONL format #377
Conversation
92ee288
to
553fc49
Compare
Great, i'll have a look :) |
Seems promising ! I'd like to avoid as much as possible to have direct references to linters in core Mega-Linter architecture, and it would be easier to maintain than having a method for each linter ^^ |
That sounds sensible- I can look into doing that, yeah. I think the 2 convertors I have made so far will be pretty re-usable as one is for unified diff and the other is a pretty simple pattern matching sort of thing. |
To clarify, before I go down some 🐰 🕳️, do you mean adding a |
Sorry for the delay... lot of work on the job that pays my rent ^^ We can have linter reporters and mega-linter reporter, so for example we could collect/transform all data after each linter, then send the whole package at the end And for me reviewdog reporter could itself receive "reviewdog_processor" from .yml descriptors (it can become a standard yml attribute, reviewdog looks so great that it deserves it ^^ ) |
Same for me. Don't worry about slow replies, great to have this level of engagement from a project maintainer 😄 I have been primarily focused on looking at reviewdog from a github perspective (will have to investigate bitbucket and gitlab at some point). I think there are pros and cons to each approach. If we call it once for the overal result of all linters (this was what I was thinking would be the best approach) we will get a single review on the PR (using the github-pr-review reporter in reviewdog) for all linters together. RD automatically limits the number of line comments it posts with the review to 30 to avoid hitting githubs rate limit(see here ). It will add any over the limit to the summary comment for the review so no output is lost. If it is called once for each linter output that would generate a seperate "review" for each linter with the 30 comment limit per linter output, however the rate limit could still kick in if we are calling RD multiple times in quick sucession. This way we would have less control over whether it hit the rate limit or not. I think calling RD once for all the linters togehter is the best approach and this can easily be achieved by joinign together the RDJSONL output as the input to RD. I also think this will allow us to just let RD do it's thing with any of its reporters. |
b86e034
to
4b963cc
Compare
Have updated this to allow the reviewdog processor to be defined in the descriptor file for each linter. I'm not quite sure ive got the json schema stuff right but it seems to |
That is exactly what i was thinking :) |
6d46fde
to
936140e
Compare
@nvuillam 2 questions:
|
|
1d9e6fc
to
0846dd0
Compare
Awesome, thanks. I have added 2 more commits, one to install reviewdog and one to post to the PR. The later I ahve not been able to test completely as locally I am not working on a PR and in thsi PR (as identified above) it doesnt run with the latest changes in this PR so the descriptors dont have the config to make the the review dog per linter reporter run. |
0846dd0
to
b2852ec
Compare
Codecov Report
@@ Coverage Diff @@
## master #377 +/- ##
==========================================
+ Coverage 86.68% 87.54% +0.85%
==========================================
Files 123 125 +2
Lines 2915 3082 +167
==========================================
+ Hits 2527 2698 +171
+ Misses 388 384 -4
Continue to review full report at Codecov.
|
Can you add a test case using reviewdog ? This way you'll be able to see if it works from ci :) |
5a74495
to
8fedc6e
Compare
aa82bc7
to
04ce942
Compare
Great. That sounds like a good plan. I will work on that and some docs. I also think it would be sensible to have the reporter disabled by default (currently I have it enabled by default) so users have to explicitly enable it. Happy to defer to your opinion on that though. |
I don't know the details, I just read in reviewdog that it uses that internally, so maybe it would prevent you from describing the format, as it may already be done by an existing tool ^^
Agreed, Mega-Linter claims that there is no calls to external apps by default, let's respect that :)
|
Note: as you are declared as collaborator on the repo, you can create an branch named |
@ewencluley you should install https://www.npmjs.com/package/markdown-table-formatter :) (it is used in build.sh) |
you can also write |
Thanks for the pointers. I was trying to test out the alpha branch I created on this PR , but am unsure why it seems to be not getting the alpha version and instead getting v4 https://github.com/ewencluley/radiopi/pull/4/checks?check_run_id=2667467176 |
Ah, perfect. Next question- i need to add unidiff as a dependency. I've added it to
https://github.com/nvuillam/mega-linter/runs/2688240026?check_suite_focus=true |
Sorry, not |
@nvuillam I have just pushed to a new branch (alpha-reviewdog-reporter) and getting the same error
https://github.com/nvuillam/mega-linter/runs/2912917400?check_suite_focus=true I have unidiff in P.S. Apologies for the delays in getting this moving again, been on vacation for 3 weeks and just back. |
@ewencluley i'll try to checkout your branch :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz check comments :)
repository_owner, repository = config.get("GITHUB_REPOSITORY").split("/") | ||
|
||
process = subprocess.Popen( | ||
"reviewdog -f=rdjsonl -reporter=github-pr-review -filter-mode=nofilter", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the reporter have a default value that would be calculated according to ENV variables ? ( github, gitlab, azure ... )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gitlab: GITLAB_CI
Github action: GITHUB_ACTION
Azure: SYSTEM_TEAMFOUNDATIONCOLLECTIONURI
Travis CI: TRAVIS
Circle CI: CIRCLECI
(cf https://github.com/npm/ci-detect/blob/master/index.js )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would also be nice to be able to add more parameter to reviewdog, like we do for linters, using some var REVIEWDOG_EXTRA_ARGS
About https://github.com/nvuillam/mega-linter/runs/2912917400?check_suite_focus=true, Mega-Linter's own Mega-Linting during PR uses a merge between latest docker image and updated local code. So basically....
|
You also need to fix real MegaLinter errors Copy-Paste: Clone found (python):
- megalinter/tests/test_megalinter/reporters/ReviewDogLinterReporterTest.py [52:76 - 65:6] (13 lines, 89 tokens)
megalinter/tests/test_megalinter/reporters/ReviewDogLinterReporterTest.py [28:55 - 41:7] CSpell: Python: /tmp/lint/megalinter/reporters/ReviewdogLinterReporter.py:67:121: E501 line too long (126 > 120 characters)
/tmp/lint/megalinter/reporters/ReviewdogLinterReporter.py:75:17: F841 local variable 'file_nm' is assigned to but never used
/tmp/lint/megalinter/reporters/ReviewdogLinterReporter.py:161:27: E741 ambiguous variable name 'l'
/tmp/lint/megalinter/tests/test_megalinter/reporters/ReviewDogLinterReporterTest.py:44:121: E501 line too long (211 > 120 characters)
/tmp/lint/megalinter/tests/test_megalinter/reporters/ReviewDogLinterReporterTest.py:45:121: E501 line too long (211 > 120 characters)
/tmp/lint/megalinter/tests/test_megalinter/reporters/ReviewDogLinterReporterTest.py:79:121: E501 line too long (211 > 120 characters)
/tmp/lint/megalinter/tests/test_megalinter/reporters/ReviewDogLinterReporterTest.py:80:121: E501 line too long (211 > 120 characters)
/tmp/lint/megalinter/tests/test_megalinter/reporters/ReviewDogLinterReporterTest.py:109:1: W293 blank line contains whitespace
/tmp/lint/megalinter/tests/test_megalinter/reporters/ReviewDogLinterReporterTest.py:116:1: W293 blank line contains whitespace
/tmp/lint/megalinter/tests/test_megalinter/reporters/ReviewDogLinterReporterTest.py:130:121: E501 line too long (754 > 120 characters) |
@nvuillam - I've fixed the linting errors but the build on the |
Please can you try to increase timeout properties in CI job config ? |
Awesome, that seems to have worked. I am trying to test it out on this PR https://github.com/ewencluley/radiopi/actions/runs/1017820202 Having some trouble working out what the Have tried:
and
Can you advise @nvuillam? |
You need to be in alpha branch and use the alpha version built by deploy docker image - alpha job alpha must be the exact name ^^ |
Oh! Makes sense. Ok for me to push it to the alpha branch? |
alpha branch is yours :) |
Victory!!!! I have finally got it to post comments on a PR!! |
d140b4e
to
60f82cf
Compare
This reporter will convert linter output to a standardised format that can easily be read by reviewdog. I have decided to use the JSONL format over the JSON format as it will be simpler to join together mutltiple files before feeding into review dog. Install reviewdog To use with the reviewdog reporter we install reviewdog in the docker image. This intentionally pinned to a specific version to avoid issues if breaking changes occur in Reviewdog. Add overall reviewdog reporter This gathers results generated by the Reviewdog Linter Reporters and feeds those results into reviewdog. This will make reviewdog post comments to github as a PR review. Configure pylint for reviewdog reporter add unit tests for reviewdog reporter Reviewdog: Checkstyle config Dont run reviewdog reporter by default
60f82cf
to
80decf8
Compare
Codecov Report
@@ Coverage Diff @@
## master #377 +/- ##
==========================================
- Coverage 86.67% 84.92% -1.75%
==========================================
Files 130 132 +2
Lines 2986 3157 +171
==========================================
+ Hits 2588 2681 +93
- Misses 398 476 +78
Continue to review full report at Codecov.
|
This pull request has been automatically marked as stale because it has not had recent activity. If you think this pull request should stay open, please remove the |
This reporter will convert linter output to a standardised format that can
easily be read by reviewdog.
I have decided to use the JSONL format over the JSON format as it will be
simpler to join together mutltiple files before feeding into review dog.
Very much a WIP and would like feedback on whether this approach is sensible or not.
Currently I've done a converter for Flake8 and Black but would obviously need to do many more, though as I work on this some commonalities will emerge e.g. those linters that output unified diffs can likely share a converter.
TODO: