diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 13f97898bbc..28ea996efff 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -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 ./... + diff --git a/build/ci.go b/build/ci.go index 5126793c3d6..7395088648a 100644 --- a/build/ci.go +++ b/build/ci.go @@ -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.") } @@ -1172,3 +1179,4 @@ func doSanityCheck() { csdb := download.MustLoadChecksums("build/checksums.txt") csdb.DownloadAndVerifyAll() } +