diff --git a/enterprise/dev/ci/ci/helpers.go b/enterprise/dev/ci/ci/helpers.go index 4deb9e14e8b6..29aed3a44127 100644 --- a/enterprise/dev/ci/ci/helpers.go +++ b/enterprise/dev/ci/ci/helpers.go @@ -24,6 +24,10 @@ type Config struct { // in the branch. If empty, then no check is enforced. mustIncludeCommit []string + // changedFiles is the list of files that have changed since the + // merge-base with origin/master. + changedFiles []string + taggedRelease bool releaseBranch bool isBextReleaseBranch bool @@ -78,12 +82,21 @@ func ComputeConfig() Config { mustIncludeCommits[i] = strings.TrimSpace(mustIncludeCommits[i]) } } + + var changedFiles []string + if output, err := exec.Command("git", "diff", "--name-only", "origin/master...").Output(); err != nil { + panic(err) + } else { + changedFiles = strings.Split(strings.TrimSpace(string(output)), "\n") + } + return Config{ now: now, branch: branch, version: version, commit: commit, mustIncludeCommit: mustIncludeCommits, + changedFiles: changedFiles, taggedRelease: taggedRelease, releaseBranch: lazyregexp.New(`^[0-9]+\.[0-9]+$`).MatchString(branch), @@ -131,13 +144,18 @@ func (c Config) isPR() bool { !strings.HasPrefix(c.branch, "docker-images-patch/") } -func isDocsOnly() bool { - output, err := exec.Command("git", "diff", "--name-only", "origin/master...").Output() - if err != nil { - panic(err) +func (c Config) isDocsOnly() bool { + for _, p := range c.changedFiles { + if !strings.HasPrefix(p, "doc/") && p != "CHANGELOG.md" { + return false + } } - for _, line := range strings.Split(strings.TrimSpace(string(output)), "\n") { - if !strings.HasPrefix(line, "doc/") && line != "CHANGELOG.md" { + return true +} + +func (c Config) isGoOnly() bool { + for _, p := range c.changedFiles { + if !strings.HasSuffix(p, ".go") { return false } } diff --git a/enterprise/dev/ci/ci/pipeline.go b/enterprise/dev/ci/ci/pipeline.go index c5e1516c27dc..edd0eff86115 100644 --- a/enterprise/dev/ci/ci/pipeline.go +++ b/enterprise/dev/ci/ci/pipeline.go @@ -62,11 +62,21 @@ func GeneratePipeline(c Config) (*bk.Pipeline, error) { // Generate pipeline steps. This statement outlines the pipeline steps for each CI case. var pipelineOperations []func(*bk.Pipeline) switch { - case c.isPR() && isDocsOnly(): + case c.isPR() && c.isDocsOnly(): // If this is a docs-only PR, run only the steps necessary to verify the docs. pipelineOperations = []func(*bk.Pipeline){ addDocs, } + + case c.isPR() && c.isGoOnly(): + // If this is a go-only PR, run only the steps necessary to verify the go code. + pipelineOperations = []func(*bk.Pipeline){ + addGoTests, // ~1.5m + addCheck, // ~1m + addGoBuild, // ~0.5m + addPostgresBackcompat, // ~0.25m + } + case c.patchNoTest: // If this is a no-test branch, then run only the Docker build. No tests are run. app := c.branch[27:]