From 9b0b0910ba5aa991d4d35797d2b6c20db0f08770 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Sun, 20 Sep 2026 17:34:46 +0800 Subject: [PATCH] ci(lint): filter new issues from git instead of the PR patch API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `only-new-issues: true` makes golangci-lint-action ask the GitHub API for the pull request patch, and that endpoint refuses any diff over 20000 lines: failed to fetch pull request patch: RequestError [HttpError]: Sorry, the diff exceeded the maximum number of lines (20000): {"resource":"PullRequest","field":"diff","code":"too_large"} The action does not fail on that error — it falls back to linting everything. With the backlog this repository carries (5672 findings at the time of writing) the job then reports hundreds of issues in files the pull request never touched, capped at 50 per linter, and cannot pass no matter how clean the change is. Tencent/WeKnora#3470 hit this at 28050 diff lines. golangci-lint computes the same filter itself with --new-from-merge-base, which reads git rather than the API and has no size limit. `fetch-depth: 0` on the checkout is what makes the base commit available, and the changes job above already relies on it, so nothing else needs to move. Verified against that pull request's branch: full run reports 5672 issues, `--new-from-merge-base=` reports 0, both from the repository root and from the cli module directory. --- .github/workflows/go-lint.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/go-lint.yml b/.github/workflows/go-lint.yml index 401a7fbb..af10de96 100644 --- a/.github/workflows/go-lint.yml +++ b/.github/workflows/go-lint.yml @@ -1,10 +1,18 @@ name: Go Lint # The repository carries a large backlog of pre-existing golangci-lint findings, -# so pull requests are only judged on the code they introduce (`only-new-issues`). -# That filter needs a pull request diff, which is why this workflow has no other -# trigger; the companion go-lint-cache.yml keeps the caches this job restores -# from warm on main. +# so pull requests are only judged on the code they introduce. The filter needs +# a pull request diff, which is why this workflow has no other trigger; the +# companion go-lint-cache.yml keeps the caches this job restores from warm on +# main. +# +# The filter is golangci-lint's own `--new-from-merge-base` rather than the +# action's `only-new-issues`, because that option asks the GitHub API for the +# pull request patch and the API refuses any diff over 20000 lines +# ("code": "too_large"). On a large pull request the action silently falls back +# to linting everything, which reports the entire backlog and can never pass. +# Computing the merge base from git has no size limit, and `fetch-depth: 0` +# below is what makes the base commit available to do it. on: pull_request: @@ -101,4 +109,7 @@ jobs: with: version: ${{ env.GOLANGCI_LINT_VERSION }} working-directory: ${{ matrix.module }} - only-new-issues: true + # Deliberately off: see the note at the top of this file. The same + # filtering is done below, from git. + only-new-issues: false + args: --new-from-merge-base=${{ github.event.pull_request.base.sha }}