From 55b330c8ec6f68c8e913179e43aac7878a237273 Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Mon, 16 Dec 2024 16:05:12 +1100 Subject: [PATCH 1/2] ci: skip redpanda console --- .../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 | 3 ++- internal/dev/redpanda.go | 9 ++++++++- internal/dev/registry.go | 3 ++- 7 files changed, 24 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..7c98f73d2f 100644 --- a/internal/dev/grafana.go +++ b/internal/dev/grafana.go @@ -5,6 +5,7 @@ import ( _ "embed" "fmt" + "github.com/alecthomas/types/optional" "github.com/block/ftl/internal/container" ) @@ -12,7 +13,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..165454c935 100644 --- a/internal/dev/redpanda.go +++ b/internal/dev/redpanda.go @@ -4,7 +4,9 @@ import ( "context" _ "embed" "fmt" + "os" + "github.com/alecthomas/types/optional" "github.com/block/ftl/internal/container" ) @@ -12,7 +14,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..b7aa3e1874 100644 --- a/internal/dev/registry.go +++ b/internal/dev/registry.go @@ -8,6 +8,7 @@ import ( "strconv" "time" + "github.com/alecthomas/types/optional" "github.com/block/ftl/internal/container" ) @@ -15,7 +16,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 { From 60d445edf0f733c27a99b5b162a2cef0ad47700c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 16 Dec 2024 05:11:33 +0000 Subject: [PATCH 2/2] chore(autofmt): Automated formatting --- internal/dev/grafana.go | 1 + internal/dev/redpanda.go | 1 + internal/dev/registry.go | 1 + 3 files changed, 3 insertions(+) diff --git a/internal/dev/grafana.go b/internal/dev/grafana.go index 7c98f73d2f..2d51c05a05 100644 --- a/internal/dev/grafana.go +++ b/internal/dev/grafana.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/alecthomas/types/optional" + "github.com/block/ftl/internal/container" ) diff --git a/internal/dev/redpanda.go b/internal/dev/redpanda.go index 165454c935..93a2c07343 100644 --- a/internal/dev/redpanda.go +++ b/internal/dev/redpanda.go @@ -7,6 +7,7 @@ import ( "os" "github.com/alecthomas/types/optional" + "github.com/block/ftl/internal/container" ) diff --git a/internal/dev/registry.go b/internal/dev/registry.go index b7aa3e1874..87c47ce1b6 100644 --- a/internal/dev/registry.go +++ b/internal/dev/registry.go @@ -9,6 +9,7 @@ import ( "time" "github.com/alecthomas/types/optional" + "github.com/block/ftl/internal/container" )