From 919245ac07466e375b8d99475e86fb1c1b4348e6 Mon Sep 17 00:00:00 2001 From: dann frazier Date: Tue, 24 Feb 2026 17:21:43 -0700 Subject: [PATCH] feat(lint): add rule to check for sccache/enable users This pipeline is intended for local devel use only. Using it in elastic will, at best, slow things down by caching things unnecessarily. There may be other side-effects as well - let's just block them. Signed-off-by: dann frazier --- pkg/lint/rules.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/pkg/lint/rules.go b/pkg/lint/rules.go index dcdbcd996..eef5cf0b5 100644 --- a/pkg/lint/rules.go +++ b/pkg/lint/rules.go @@ -76,6 +76,7 @@ var ( ) const gitCheckout = "git-checkout" +const sccacheEnable = "sccache/enable" // AllRules is a list of all available rules to evaluate. var AllRules = func(l *Linter) Rules { //nolint:gocyclo @@ -527,6 +528,17 @@ var AllRules = func(l *Linter) Rules { //nolint:gocyclo return nil }, }, + { + Name: "sccache-enabled", + Description: "sccache/enable is for local devel-use only", + Severity: SeverityError, + LintFunc: func(c config.Configuration) error { + if anyPipelineUses(c, sccacheEnable) { + return fmt.Errorf("scacche/enable pipeline exists") + } + return nil + }, + }, { Name: "valid-update-schedule", Description: "update schedule config should contain a valid period", @@ -630,6 +642,37 @@ func pickPipelinesUsing(uses string, pipelines []config.Pipeline) []*config.Pipe return retval } +func anyPipelineUses(c config.Configuration, uses string) bool { + for index := range len(c.Pipeline) { + if c.Pipeline[index].Uses == uses { + return true + } + } + if c.Test != nil { + for index := range len(c.Test.Pipeline) { + if c.Test.Pipeline[index].Uses == uses { + return true + } + } + } + for spindex := range c.Subpackages { + sp := c.Subpackages[spindex] + for index := range len(sp.Pipeline) { + if sp.Pipeline[index].Uses == uses { + return true + } + } + if sp.Test != nil { + for index := range len(sp.Test.Pipeline) { + if sp.Test.Pipeline[index].Uses == uses { + return true + } + } + } + } + return false +} + func containsKey(parentNode *yaml.Node, key string) error { it := yit.FromNode(parentNode). ValuesForMap(yit.WithValue(key), yit.All)