Skip to content

Commit

Permalink
fix: add warning if build or deploy command finds no modules (#4239)
Browse files Browse the repository at this point in the history
fixes #4214
  • Loading branch information
matt2e authored Jan 30, 2025
1 parent e47ff38 commit b865882
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cmd/ftl/cmd_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/block/ftl/backend/protos/xyz/block/ftl/v1/ftlv1connect"
"github.com/block/ftl/internal/buildengine"
"github.com/block/ftl/internal/log"
"github.com/block/ftl/internal/projectconfig"
"github.com/block/ftl/internal/schema/schemaeventsource"
)
Expand All @@ -25,6 +26,7 @@ func (b *buildCmd) Run(
schemaSourceFactory func() schemaeventsource.EventSource,
projConfig projectconfig.Config,
) error {
logger := log.FromContext(ctx)
if len(b.Dirs) == 0 {
b.Dirs = projConfig.AbsModuleDirs()
}
Expand All @@ -48,6 +50,10 @@ func (b *buildCmd) Run(
if err != nil {
return err
}
if len(engine.Modules()) == 0 {
logger.Warnf("No modules were found to build")
return nil
}
if err := engine.Build(ctx); err != nil {
return fmt.Errorf("build failed: %w", err)
}
Expand Down
7 changes: 6 additions & 1 deletion cmd/ftl/cmd_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

provisionerconnect "github.com/block/ftl/backend/protos/xyz/block/ftl/provisioner/v1beta1/provisionerpbconnect"
"github.com/block/ftl/internal/buildengine"
"github.com/block/ftl/internal/log"
"github.com/block/ftl/internal/projectconfig"
"github.com/block/ftl/internal/schema/schemaeventsource"
)
Expand All @@ -24,6 +25,7 @@ func (d *deployCmd) Run(
provisionerClient provisionerconnect.ProvisionerServiceClient,
schemaSourceFactory func() schemaeventsource.EventSource,
) error {
logger := log.FromContext(ctx)
// Cancel build engine context to ensure all language plugins are killed.
if d.Timeout > 0 {
var cancel context.CancelFunc //nolint: forbidigo
Expand All @@ -42,7 +44,10 @@ func (d *deployCmd) Run(
if err != nil {
return err
}

if len(engine.Modules()) == 0 {
logger.Warnf("No modules were found to deploy")
return nil
}
err = engine.BuildAndDeploy(ctx, d.Replicas, !d.NoWait)
if err != nil {
return fmt.Errorf("failed to deploy: %w", err)
Expand Down

0 comments on commit b865882

Please sign in to comment.