diff --git a/Taskfile.yml b/Taskfile.yml index 683f04e16..71c61689f 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -453,9 +453,9 @@ tasks: cmds: - go build -ldflags "-X github.com/samcharles93/archie-core/internal/app/archied.gatewayVersion={{.GATEWAY_VERSION}} -X github.com/samcharles93/archie-core/internal/app/archied.runtimeVersion={{.RUNTIME_VERSION}} -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o {{.BIN_DIR}}/archied ./cmd/archied - go build -ldflags "-X github.com/samcharles93/archie-core/internal/app/archied.gatewayVersion={{.GATEWAY_VERSION}} -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o {{.BIN_DIR}}/archie-gateway ./cmd/archie-gateway - - go build -o {{.BIN_DIR}}/archie-state-store ./cmd/archie-state-store - - go build -o {{.BIN_DIR}}/archie-ui ./cmd/archie-ui - - go build -o {{.BIN_DIR}}/archie-messaging ./cmd/archie-messaging + - go build -ldflags "-X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o {{.BIN_DIR}}/archie-state-store ./cmd/archie-state-store + - go build -ldflags "-X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o {{.BIN_DIR}}/archie-ui ./cmd/archie-ui + - go build -ldflags "-X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o {{.BIN_DIR}}/archie-messaging ./cmd/archie-messaging - go build -ldflags "-X github.com/samcharles93/archie-core/internal/app/agentworker.version={{.RUNTIME_VERSION}} -X github.com/samcharles93/archie-core/internal/installtype.buildType=binary" -o {{.BIN_DIR}}/archie-agent ./cmd/archie-agent test: diff --git a/deployment_contract_test.go b/deployment_contract_test.go index e628923d8..50f1334e7 100644 --- a/deployment_contract_test.go +++ b/deployment_contract_test.go @@ -141,6 +141,37 @@ func TestBuildTaskSourcesTrackEmbeddedAssets(t *testing.T) { } } +func TestBuildTaskStampsInstallTypeOnEveryCommand(t *testing.T) { + taskfile := readDeploymentFile(t, "Taskfile.yml") + start := strings.Index(taskfile, "\n build:\n") + end := strings.Index(taskfile, "\n test:\n") + if start < 0 || end < start { + t.Fatal("Taskfile has no bounded build task") + } + build := taskfile[start:end] + cmdsAt := strings.Index(build, "\n cmds:\n") + if cmdsAt < 0 { + t.Fatal("build task has no cmds block") + } + cmds := build[cmdsAt:] + + buildLine := regexp.MustCompile(`^ - go build .*\./cmd/([a-z0-9-]+)`) + found := 0 + for line := range strings.SplitSeq(cmds, "\n") { + m := buildLine.FindStringSubmatch(line) + if m == nil { + continue + } + found++ + if !strings.Contains(line, "internal/installtype.buildType=") { + t.Errorf("build task does not stamp installtype.buildType on %s: %s", m[1], strings.TrimSpace(line)) + } + } + if found == 0 { + t.Fatal("build task has no go build commands under ./cmd/: this guard would assert nothing") + } +} + func TestFormattersExcludeInterpretedSecretEngines(t *testing.T) { config := readDeploymentFile(t, ".golangci.yml") if !strings.Contains(config, `^examples/secret-engines/(age|sops|vault)\.go$`) {