-
Notifications
You must be signed in to change notification settings - Fork 22.5k
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
Feature: provide automated PR reviews for linting related changes #28240
Conversation
Preview URLs (comment last updated: 2023-09-29 18:29:46) |
We'll need a token with Pull request write permissions. Getting following error:
For demo output see OnkarRuikar#15 |
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.
One nit :)
Co-authored-by: A1lo <[email protected]>
Hi @OnkarRuikar, should we make the "add lint reviews to PRs" workflow failed when there does have some formats need to be done (maybe we should rename this workflow). Just as what I said in another PR, this could help the maintainer to check if it's ready to merge PRs (if the contributer just mark the suggestions as resolved, the maintainer may not realize that the PR is not ready to be merged yet. |
Good point! Now the job fails when there are any suggestions by the linters or raised issues. |
We are not able to make it work for the PRs submitted from forks of guest users. The initial PR showed those review comments because the PR author has direct push permissions to the repo so their GITHUB_TOKEN in the workflow runs got write permissions. But PRs from guest users are not getting the write permissions. We've tried to use a repo wide secret personal access token with PR write permissions but it is not visible in PRs from fork. |
Hi @OnkarRuikar, is it possible that we could run the reviewdog in another workflow which could be triggered by "Add lint reviews to PRs" workflow. So we could use mdn-bot token (or other token which has write permission, maybe in this way, the GITHUB_TOKEN does have write permission) to report suggestions (This should keep the repository secure). But the reviewdog seems to only works with pull request event. So I just check how the reviewdog collects enough info before submitting suggestions. The entry should be here. And all the information seems to be provided by the event file, and it's location is provided by So, I'm wondering is it possible that we could upload the event file and git diff content, and in another PR, we just download those files, and set up the |
I just setup the /cc @LeoMcA I'm not sure if it's secure enough for us, do you have any thought? |
Hi @OnkarRuikar, one more question, I'm not really familiar with markdown-lint and front-matter-lint, do I just need to redirect stderr to a log file? or we need to combine stdout with stderr, and then redirect to a log file? |
Chatted with Onkar on Slack about this, but documenting here for everyone to see: I think I believe we'll be alright here if we:
|
I'll try this approach in a new draft PR. This one has a lot of commits and history accrued. |
--- | ||
|
||
{{GamesSidebar}} | ||
|
||
Gaming is one of the most popular computer activities. New technologies are constantly arriving to make it possible to develop better and more powerful games that can be run in any standards-compliant web browser. | ||
|
||
## Develop web games | ||
```css | ||
body { background-color: aqua; } |
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.
[mdn-linter] reported by reviewdog 🐶
body { background-color: aqua; } | |
body { | |
background-color: aqua; | |
} |
* item 1 | ||
+ item 2 |
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.
[mdn-linter] reported by reviewdog 🐶
* item 1 | |
+ item 2 | |
- item 1 | |
- item 2 | |
We've also included a reference section so you can easily find information about all the most common APIs used in game development. | ||
|
||
> **Note:** Creating games on the web draws on a number of core web technologies such as HTML, CSS, and JavaScript. The [Learning Area](/en-US/docs/Learn) is a good place to go to get started with the basics. | ||
|
||
## Port native games to the Web | ||
## Port native games to the Web |
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.
[mdn-linter] reported by reviewdog 🐶
## Port native games to the Web | |
## Port native games to the Web |
} | ||
``` | ||
|
||
# Develop web games |
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.
[markdownlint] reported by reviewdog 🐶
MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: # Develop web games]
Looks like a duplicate of #28363 |
Purpose of this PR is to provide an alternative approach. This PR involves all the linters/formatters (markdown, prettier, front-matter) for automated review using reviewdog.
Summary
Current Prettier implementation in our CI is being annoying because the formatter tells contributors that there is something wrong with their changes without telling what is it and how to fix it. This is forcing contributors to fix those issues using command line tools or online Prettier playground.
Using reviewdog it is possible to instead suggest those changes as review comments on PRs. With this contributors will simply have to accept these changes and commit them in a batch.
While we are at it we can involve markdownlint and front-matter linters too, i.e we can suggest solutions to markdown and front-matter related issues as well.
Implementation
reviewdog uses two inputs to provide review comments:
a)
git diff
generated after running the linters with--fix
or--write
optionsb) logs generated by the linters along with error message matching pattern
The implementation performs following steps to provide the review comments:
git diff
to suggest changes done by the linters usingreviewdog -f=diff
command. Basically we are suggesting the same changes done by the linters.Note: The diff is collected after running all the linters because we always run Prettier the last in order to avoid clashes with markdownlint. Also providing reviews for each linter separately will confuse the contributors. The combined linting is being presented as "mdn-linter".
reviewdog -efm
command.