-
Notifications
You must be signed in to change notification settings - Fork 293
Add Copilot agent to lint CI for automatic lint fix on PRs #2407
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -76,3 +76,59 @@ jobs: | |||||||||||||||||||||||||||||||||||
| sarif_file: lintrunner.sarif | ||||||||||||||||||||||||||||||||||||
| category: lintrunner | ||||||||||||||||||||||||||||||||||||
| checkout_path: ${{ github.workspace }} | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| copilot-fix-lint: | ||||||||||||||||||||||||||||||||||||
| name: Copilot Fix Lint Errors | ||||||||||||||||||||||||||||||||||||
| needs: lint-python-format | ||||||||||||||||||||||||||||||||||||
| # Only run when lint fails on pull requests from the same repo (not forks) | ||||||||||||||||||||||||||||||||||||
| if: >- | ||||||||||||||||||||||||||||||||||||
| failure() | ||||||||||||||||||||||||||||||||||||
| && github.event_name == 'pull_request' | ||||||||||||||||||||||||||||||||||||
| && github.event.pull_request.head.repo.full_name == github.repository | ||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| permissions: | |
| permissions: | |
| issues: write |
Copilot
AI
Apr 10, 2026
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.
Deduplication can miss prior markers because only the first 100 comments are fetched. If a PR has more than 100 comments, the marker could be on a later page and this job would post a duplicate request. Consider paginating through comments (or searching most-recent pages first), or updating an existing comment instead of creating a new one.
| // Avoid duplicate comments on workflow re-runs | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| per_page: 100, | |
| }); | |
| // Avoid duplicate comments on workflow re-runs by checking all comment pages | |
| const comments = await github.paginate( | |
| github.rest.issues.listComments, | |
| { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| per_page: 100, | |
| }, | |
| ); |
Copilot
AI
Apr 10, 2026
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.
There is a race window where two workflow runs (for example a re-run started before the prior run posts the comment) can both pass the "no marker" check and create duplicate comments. If duplicates are a concern, consider adding a workflow concurrency group for this job/workflow or switching to an idempotent update strategy (for example editing an existing marker comment).
Copilot
AI
Apr 22, 2026
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.
The instructions in the PR comment recommend running full lintrunner --all-files locally, but this repo’s developer guidance recommends lintrunner --all-files -a --skip PYLINT for faster iteration and running PYLINT only when changes are PR-ready (see AGENTS.md). Consider updating steps 1–2 in the generated comment to reflect that convention so developers are not encouraged to run the slowest option by default.
| '1. Run `lintrunner --all-files` to see all lint errors', | |
| '2. Run `lintrunner --all-files -a` to auto-fix formatting issues', | |
| '1. Run `lintrunner --all-files -a --skip PYLINT` to auto-fix issues and check the faster local lint path', | |
| '2. When the changes are PR-ready, run `lintrunner --all-files` to include PYLINT and any remaining checks', |
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.
The job-level condition is broader than the PR description and may not run when intended.
failure()can become true due to failures in other jobs (for exampleoptional-lint), and dependent jobs are often skipped whenneedsfails unless you includealways(). Prefer gating explicitly on the dependency result, for example checkingneeds.lint-python-format.result == 'failure'and combining withalways()plus the pull_request and non-fork checks.