update golangci lint using GIT_BRANCH_REF

This commit is contained in:
Muzry 2025-07-23 09:51:11 +00:00
parent 56a2e89767
commit 8b5a222efd
2 changed files with 17 additions and 1 deletions

View file

@ -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
@ -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
@ -56,3 +63,4 @@ jobs:
- name: Run tests
run: go test ./...

View file

@ -433,7 +433,14 @@ func doLint(cmdline []string) {
}
linter := downloadLinter(*cachedir)
lflags := []string{"run", "--config", ".golangci.yml", "--new-from-rev=origin/master"}
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.")
}
@ -1172,3 +1179,4 @@ func doSanityCheck() {
csdb := download.MustLoadChecksums("build/checksums.txt")
csdb.DownloadAndVerifyAll()
}