Skip to content

Commit

Permalink
ci: skip redpanda console (#3776)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
matt2e and github-actions[bot] authored Dec 16, 2024
1 parent 84d6877 commit 889a4da
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
10 changes: 8 additions & 2 deletions internal/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions internal/dev/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down
2 changes: 2 additions & 0 deletions internal/dev/docker-compose.redpanda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ services:
- 18083:8080
depends_on:
- redpanda
profiles:
- console
4 changes: 3 additions & 1 deletion internal/dev/grafana.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import (
_ "embed"
"fmt"

"github.com/alecthomas/types/optional"

"github.com/block/ftl/internal/container"
)

//go:embed docker-compose.grafana.yml
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)
}
Expand Down
10 changes: 9 additions & 1 deletion internal/dev/redpanda.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"context"
_ "embed"
"fmt"
"os"

"github.com/alecthomas/types/optional"

"github.com/block/ftl/internal/container"
)
Expand All @@ -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)
}
Expand Down
4 changes: 3 additions & 1 deletion internal/dev/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import (
"strconv"
"time"

"github.com/alecthomas/types/optional"

"github.com/block/ftl/internal/container"
)

//go:embed docker-compose.registry.yml
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 {
Expand Down

0 comments on commit 889a4da

Please sign in to comment.