Skip to content

Commit 8b5a222

Browse files
committed
update golangci lint using GIT_BRANCH_REF
1 parent 56a2e89 commit 8b5a222

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

.github/workflows/go.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
- uses: actions/checkout@v4
1616
with:
1717
submodules: false
18+
fetch-depth: 0
1819

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

32+
- name: Fetch base branch
33+
run: |
34+
if [ ! -z "$GITHUB_BASE_REF" ]; then
35+
git fetch origin $GITHUB_BASE_REF:refs/remotes/origin/$GITHUB_BASE_REF
36+
fi
37+
3138
- name: Run linters
3239
run: |
3340
go run build/ci.go lint
@@ -56,3 +63,4 @@ jobs:
5663

5764
- name: Run tests
5865
run: go test ./...
66+

build/ci.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,14 @@ func doLint(cmdline []string) {
433433
}
434434

435435
linter := downloadLinter(*cachedir)
436-
lflags := []string{"run", "--config", ".golangci.yml", "--new-from-rev=origin/master"}
436+
baseRef := "master"
437+
if ref := os.Getenv("GITHUB_BASE_REF"); ref != "" {
438+
baseRef = ref
439+
}
440+
441+
lflags := []string{"run", "--config", ".golangci.yml",
442+
fmt.Sprintf("--new-from-rev=origin/%s", baseRef),
443+
}
437444
build.MustRunCommandWithOutput(linter, append(lflags, packages...)...)
438445
fmt.Println("You have achieved perfection.")
439446
}
@@ -1172,3 +1179,4 @@ func doSanityCheck() {
11721179
csdb := download.MustLoadChecksums("build/checksums.txt")
11731180
csdb.DownloadAndVerifyAll()
11741181
}
1182+

0 commit comments

Comments
 (0)