From 889a4da9ae4ee75deadae71529a9fef3daeb8cc4 Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Mon, 16 Dec 2024 16:45:11 +1100 Subject: [PATCH] ci: skip redpanda console (#3776) Co-authored-by: github-actions[bot] --- .../xyz/block/ftl/java/test/subscriber/Subscriber.java | 2 -- internal/container/container.go | 10 ++++++++-- internal/dev/db.go | 4 ++-- internal/dev/docker-compose.redpanda.yml | 2 ++ internal/dev/grafana.go | 4 +++- internal/dev/redpanda.go | 10 +++++++++- internal/dev/registry.go | 4 +++- 7 files changed, 27 insertions(+), 9 deletions(-) diff --git a/backend/runner/pubsub/testdata/java/subscriber/src/main/java/xyz/block/ftl/java/test/subscriber/Subscriber.java b/backend/runner/pubsub/testdata/java/subscriber/src/main/java/xyz/block/ftl/java/test/subscriber/Subscriber.java index 2148cb3609..ca74499b64 100644 --- a/backend/runner/pubsub/testdata/java/subscriber/src/main/java/xyz/block/ftl/java/test/subscriber/Subscriber.java +++ b/backend/runner/pubsub/testdata/java/subscriber/src/main/java/xyz/block/ftl/java/test/subscriber/Subscriber.java @@ -1,7 +1,5 @@ package xyz.block.ftl.java.test.subscriber; -import java.util.concurrent.atomic.AtomicInteger; - import ftl.publisher.PubSubEvent; import ftl.publisher.TestTopicTopic; import ftl.publisher.Topic2Topic; diff --git a/internal/container/container.go b/internal/container/container.go index e58535c859..b9e6b2e6c0 100644 --- a/internal/container/container.go +++ b/internal/container/container.go @@ -353,7 +353,7 @@ func PollContainerHealth(ctx context.Context, containerName string, timeout time // // Make sure you obtain the compose yaml from a string literal or an embedded file, rather than // reading from disk. The project file will not be included in the release build. -func ComposeUp(ctx context.Context, name, composeYAML string, envars ...string) error { +func ComposeUp(ctx context.Context, name, composeYAML string, profile optional.Option[string], envars ...string) error { logger := log.FromContext(ctx).Scope(name) ctx = log.ContextWithLogger(ctx, logger) @@ -378,7 +378,13 @@ func ComposeUp(ctx context.Context, name, composeYAML string, envars ...string) envars = append(envars, "COMPOSE_IGNORE_ORPHANS=True") - cmd := exec.CommandWithEnv(ctx, log.Debug, ".", envars, "docker", "compose", "-f", "-", "-p", "ftl", "up", "-d", "--wait") + args := []string{"compose"} + if profile, ok := profile.Get(); ok { + args = append(args, "--profile", profile) + } + args = append(args, "-f", "-", "-p", "ftl", "up", "-d", "--wait") + + cmd := exec.CommandWithEnv(ctx, log.Debug, ".", envars, "docker", args...) cmd.Stdin = bytes.NewReader([]byte(composeYAML)) if err := cmd.RunStderrError(ctx); err != nil { return fmt.Errorf("failed to run docker compose up: %w", err) diff --git a/internal/dev/db.go b/internal/dev/db.go index 3679dde157..01520dc43e 100644 --- a/internal/dev/db.go +++ b/internal/dev/db.go @@ -103,7 +103,7 @@ func SetupPostgres(ctx context.Context, image optional.Option[string], port int, if imaneName, ok := image.Get(); ok { envars = append(envars, "FTL_DATABASE_IMAGE="+imaneName) } - err := container.ComposeUp(ctx, "postgres", postgresDockerCompose, envars...) + err := container.ComposeUp(ctx, "postgres", postgresDockerCompose, optional.None[string](), envars...) if err != nil { return fmt.Errorf("could not start postgres: %w", err) } @@ -120,7 +120,7 @@ func SetupMySQL(ctx context.Context, port int) (string, error) { if port != 0 { envars = append(envars, "MYSQL_PORT="+strconv.Itoa(port)) } - err := container.ComposeUp(ctx, "mysql", mysqlDockerCompose, envars...) + err := container.ComposeUp(ctx, "mysql", mysqlDockerCompose, optional.None[string](), envars...) if err != nil { return "", fmt.Errorf("could not start mysql: %w", err) } diff --git a/internal/dev/docker-compose.redpanda.yml b/internal/dev/docker-compose.redpanda.yml index 0a2c3a648b..8178d4fdca 100644 --- a/internal/dev/docker-compose.redpanda.yml +++ b/internal/dev/docker-compose.redpanda.yml @@ -67,3 +67,5 @@ services: - 18083:8080 depends_on: - redpanda + profiles: + - console diff --git a/internal/dev/grafana.go b/internal/dev/grafana.go index ac3809b1ce..2d51c05a05 100644 --- a/internal/dev/grafana.go +++ b/internal/dev/grafana.go @@ -5,6 +5,8 @@ import ( _ "embed" "fmt" + "github.com/alecthomas/types/optional" + "github.com/block/ftl/internal/container" ) @@ -12,7 +14,7 @@ import ( var grafanaDockerCompose string func SetupGrafana(ctx context.Context, image string) error { - err := container.ComposeUp(ctx, "grafana", grafanaDockerCompose) + err := container.ComposeUp(ctx, "grafana", grafanaDockerCompose, optional.None[string]()) if err != nil { return fmt.Errorf("could not start grafana: %w", err) } diff --git a/internal/dev/redpanda.go b/internal/dev/redpanda.go index 5b6c9c9e04..93a2c07343 100644 --- a/internal/dev/redpanda.go +++ b/internal/dev/redpanda.go @@ -4,6 +4,9 @@ import ( "context" _ "embed" "fmt" + "os" + + "github.com/alecthomas/types/optional" "github.com/block/ftl/internal/container" ) @@ -12,7 +15,12 @@ import ( var redpandaDockerCompose string func SetUpRedPanda(ctx context.Context) error { - err := container.ComposeUp(ctx, "redpanda", redpandaDockerCompose) + var profile optional.Option[string] + if _, ci := os.LookupEnv("CI"); !ci { + // include console except in CI + profile = optional.Some[string]("console") + } + err := container.ComposeUp(ctx, "redpanda", redpandaDockerCompose, profile) if err != nil { return fmt.Errorf("could not start redpanda: %w", err) } diff --git a/internal/dev/registry.go b/internal/dev/registry.go index 3775c51c13..87c47ce1b6 100644 --- a/internal/dev/registry.go +++ b/internal/dev/registry.go @@ -8,6 +8,8 @@ import ( "strconv" "time" + "github.com/alecthomas/types/optional" + "github.com/block/ftl/internal/container" ) @@ -15,7 +17,7 @@ import ( var registryDockerCompose string func SetupRegistry(ctx context.Context, image string, port int) error { - err := container.ComposeUp(ctx, "registry", registryDockerCompose, + err := container.ComposeUp(ctx, "registry", registryDockerCompose, optional.None[string](), "FTL_REGISTRY_IMAGE="+image, "FTL_REGISTRY_PORT="+strconv.Itoa(port)) if err != nil {