ci: cache golangci-lint cache across builds (#46043)

This commit is contained in:
Jean-Hadrien Chabran 2023-01-06 14:31:15 +01:00 committed by GitHub
parent 373b795ee2
commit 6ee33f77f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

3
.gitignore vendored
View File

@ -171,6 +171,9 @@ annotations/
# Buildkite analytics files
test-reports/
# CI linter cache (used only in CI)
.golangci-lint-cache
# go workspace files shouldn't be committed
go.work
go.work.sum

View File

@ -14,6 +14,7 @@ import (
"github.com/sourcegraph/sourcegraph/dev/ci/runtype"
"github.com/sourcegraph/sourcegraph/enterprise/dev/ci/images"
"github.com/sourcegraph/sourcegraph/enterprise/dev/ci/internal/buildkite"
bk "github.com/sourcegraph/sourcegraph/enterprise/dev/ci/internal/buildkite"
"github.com/sourcegraph/sourcegraph/enterprise/dev/ci/internal/ci/changed"
"github.com/sourcegraph/sourcegraph/enterprise/dev/ci/internal/ci/operations"
@ -128,8 +129,17 @@ func addSgLints(targets []string) func(pipeline *bk.Pipeline) {
cmd = cmd + "lint -annotations -fail-fast=false " + formatCheck + strings.Join(targets, " ")
return func(pipeline *bk.Pipeline) {
lintCachePath := "/root/buildkite/build/sourcegraph/.golangci-lint-cache"
pipeline.AddStep(":pineapple::lint-roller: Run sg lint",
withYarnCache(),
bk.Env("GOLANGCI_LINT_CACHE", lintCachePath),
buildkite.Cache(&bk.CacheOptions{
ID: "golangci-lint",
Key: "golangci-lint-{{ git.branch }}",
RestoreKeys: []string{"golangci-lint-{{ git.branch }}", "golangci-lint-main"},
Paths: []string{".golangci-lint-cache"},
Compress: true,
}),
bk.AnnotatedCmd(cmd, bk.AnnotatedCmdOpts{
Annotations: &bk.AnnotationOpts{
IncludeNames: true,