Skip to content

build/ci: update golangci-linter with --new-from-rev #32262

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 0

# Cache build tools to avoid downloading them each time
- uses: actions/cache@v4
Expand All @@ -28,6 +29,12 @@ jobs:
go-version: 1.24
cache: false

- name: Fetch base branch
run: |
if [ ! -z "$GITHUB_BASE_REF" ]; then
git fetch origin $GITHUB_BASE_REF:refs/remotes/origin/$GITHUB_BASE_REF
fi

- name: Run linters
run: |
go run build/ci.go lint
Expand Down Expand Up @@ -56,3 +63,4 @@ jobs:

- name: Run tests
run: go test ./...

10 changes: 9 additions & 1 deletion build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,14 @@ func doLint(cmdline []string) {
}

linter := downloadLinter(*cachedir)
lflags := []string{"run", "--config", ".golangci.yml"}
baseRef := "master"
if ref := os.Getenv("GITHUB_BASE_REF"); ref != "" {
baseRef = ref
}

lflags := []string{"run", "--config", ".golangci.yml",
fmt.Sprintf("--new-from-rev=origin/%s", baseRef),
}
build.MustRunCommandWithOutput(linter, append(lflags, packages...)...)
fmt.Println("You have achieved perfection.")
}
Expand Down Expand Up @@ -1172,3 +1179,4 @@ func doSanityCheck() {
csdb := download.MustLoadChecksums("build/checksums.txt")
csdb.DownloadAndVerifyAll()
}

Loading