Skip to content

Commit

Permalink
Update the go code for detecting if run in CI
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandros Sapranidis <alexandros@elastic.co>
  • Loading branch information
alexsapran committed Oct 3, 2024
1 parent ed730a4 commit 98bfbfd
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions dev-tools/mage/gotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,13 @@ type TestBinaryArgs struct {
}

func makeGoTestArgs(name string) GoTestArgs {
fileName := ""
_, isCI := os.LookupEnv("CI")
if isCI {
fileName := fmt.Sprintf("build/TEST-go-%s", strings.Replace(strings.ToLower(name), " ", "_", -1))
if ci, ok := os.LookupEnv("CI"); ok && ci == "true" {
buildkiteJobId := os.Getenv("BUILDKITE_JOB_ID")
fileName = fmt.Sprintf("build/TEST-go-%s-%s",
strings.Replace(strings.ToLower(name), " ", "_", -1),
buildkiteJobId,
)
} else {
fileName = fmt.Sprintf("build/TEST-go-%s", strings.Replace(strings.ToLower(name), " ", "_", -1))
}
params := GoTestArgs{
LogName: name,
Expand All @@ -73,20 +70,18 @@ func makeGoTestArgs(name string) GoTestArgs {
}

func makeGoTestArgsForModule(name, module string) GoTestArgs {
fileName := ""
_, isCI := os.LookupEnv("CI")
if isCI {
fileName := fmt.Sprintf("build/TEST-go-%s-%s",
strings.Replace(strings.ToLower(name), " ", "_", -1),
strings.Replace(strings.ToLower(module), " ", "_", -1),
)
if ci, ok := os.LookupEnv("CI"); ok && ci == "true" {
buildkiteJobId := os.Getenv("BUILDKITE_JOB_ID")
fileName = fmt.Sprintf("build/TEST-go-%s-%s-%s",
strings.Replace(strings.ToLower(name), " ", "_", -1),
strings.Replace(strings.ToLower(module), " ", "_", -1),
buildkiteJobId,
)
} else {
fileName = fmt.Sprintf("build/TEST-go-%s-%s", strings.Replace(strings.ToLower(name), " ", "_", -1),
strings.Replace(strings.ToLower(module), " ", "_", -1))
}

params := GoTestArgs{
LogName: fmt.Sprintf("%s-%s", name, module),
Race: RaceDetector,
Expand Down

0 comments on commit 98bfbfd

Please sign in to comment.