From 1951e7d336df23fcdef2718fb108f50f08b77f3c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Apr 2026 01:38:00 +0000 Subject: [PATCH 1/2] Add copilot-fix-lint job to auto-fix lint errors on PRs Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/8ec606c9-d765-438a-9810-012c2033d057 Co-authored-by: xiaoyu-work <85524621+xiaoyu-work@users.noreply.github.com> --- .github/workflows/lint.yml | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b51caacca..1936f9fca 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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: + pull-requests: write + steps: + - name: Request Copilot to fix lint errors + uses: actions/github-script@v7 + with: + script: | + const prNumber = context.payload.pull_request.number; + const marker = ''; + + // 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, + }); + + if (comments.some(c => c.body?.includes(marker))) { + core.info('Copilot lint fix already requested; skipping.'); + return; + } + + const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; + + const body = [ + marker, + '@copilot The lint check failed for this PR. Please fix all the lint errors and push the fixes to this branch.', + '', + `Failed workflow run: ${runUrl}`, + '', + 'To reproduce and fix:', + '1. Run `lintrunner --all-files` to see all lint errors', + '2. Run `lintrunner --all-files -a` to auto-fix formatting issues', + '3. Manually fix any remaining lint errors that cannot be auto-fixed', + '4. Commit and push the fixes', + ].join('\n'); + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + body: body, + }); + + core.info(`Requested Copilot to fix lint errors on PR #${prNumber}`); From a3f7de86f42ae47a974aaf6c273dad42ebec29f6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 10 Apr 2026 03:43:15 +0000 Subject: [PATCH 2/2] Address Copilot review comments on copilot-fix-lint job Agent-Logs-Url: https://github.com/microsoft/Olive/sessions/950d51d5-2dc1-4df4-a471-7577bbadea9a Co-authored-by: xiaoyu-work <85524621+xiaoyu-work@users.noreply.github.com> --- .github/workflows/lint.yml | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1936f9fca..dd5f7788f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -80,14 +80,18 @@ jobs: 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) + # Only run when lint-python-format fails on pull requests from the same repo (not forks) if: >- - failure() + always() + && needs.lint-python-format.result == 'failure' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository runs-on: ubuntu-latest + concurrency: + group: copilot-fix-lint-pr-${{ github.event.pull_request.number }} + cancel-in-progress: true permissions: - pull-requests: write + issues: write steps: - name: Request Copilot to fix lint errors uses: actions/github-script@v7 @@ -96,13 +100,16 @@ jobs: const prNumber = context.payload.pull_request.number; const marker = ''; - // 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, + }, + ); if (comments.some(c => c.body?.includes(marker))) { core.info('Copilot lint fix already requested; skipping.');