diff --git a/internal/buildengine/discover_test.go b/internal/buildengine/discover_test.go index 1c096c42c8..8199bfdcff 100644 --- a/internal/buildengine/discover_test.go +++ b/internal/buildengine/discover_test.go @@ -21,11 +21,16 @@ func TestDiscoverModules(t *testing.T) { Language: "go", Realm: "home", Module: "alpha", - Deploy: []string{"main", "launch"}, + Deploy: []string{"launch", "main"}, DeployDir: ".ftl", Schema: "schema.pb", Errors: "errors.pb", - Watch: []string{"**/*.go", "go.mod", "go.sum", "../../../../go-runtime/ftl/**/*.go"}, + Watch: []string{ + "**/*.go", + "../../../../go-runtime/ftl/**/*.go", + "go.mod", + "go.sum", + }, }, }, { @@ -34,11 +39,17 @@ func TestDiscoverModules(t *testing.T) { Language: "go", Realm: "home", Module: "another", - Deploy: []string{"main", "launch"}, + Deploy: []string{"launch", "main"}, DeployDir: ".ftl", Schema: "schema.pb", Errors: "errors.pb", - Watch: []string{"**/*.go", "go.mod", "go.sum", "../../../../go-runtime/ftl/**/*.go", "../../../../go-runtime/schema/testdata/**/*.go"}, + Watch: []string{ + "**/*.go", + "../../../../go-runtime/ftl/**/*.go", + "../../../../go-runtime/schema/testdata/**/*.go", + "go.mod", + "go.sum", + }, }, }, { @@ -47,7 +58,7 @@ func TestDiscoverModules(t *testing.T) { Language: "go", Realm: "home", Module: "depcycle1", - Deploy: []string{"main", "launch"}, + Deploy: []string{"launch", "main"}, DeployDir: ".ftl", Schema: "schema.pb", Errors: "errors.pb", @@ -60,7 +71,7 @@ func TestDiscoverModules(t *testing.T) { Language: "go", Realm: "home", Module: "depcycle2", - Deploy: []string{"main", "launch"}, + Deploy: []string{"launch", "main"}, DeployDir: ".ftl", Schema: "schema.pb", Errors: "errors.pb", @@ -75,8 +86,8 @@ func TestDiscoverModules(t *testing.T) { Module: "echo", Build: "mvn -B package", Deploy: []string{ - "quarkus-app", "launch", + "quarkus-app", }, DeployDir: "target", GeneratedSchemaDir: "src/main/ftl-module-schema", @@ -100,8 +111,8 @@ func TestDiscoverModules(t *testing.T) { Module: "external", Build: "", Deploy: []string{ - "main", "launch", + "main", }, DeployDir: ".ftl", Schema: "schema.pb", @@ -121,8 +132,8 @@ func TestDiscoverModules(t *testing.T) { Module: "externalkotlin", Build: "mvn -B package", Deploy: []string{ - "quarkus-app", "launch", + "quarkus-app", }, DeployDir: "target", GeneratedSchemaDir: "src/main/ftl-module-schema", @@ -144,7 +155,7 @@ func TestDiscoverModules(t *testing.T) { Language: "go", Realm: "home", Module: "integer", - Deploy: []string{"main", "launch"}, + Deploy: []string{"launch", "main"}, DeployDir: ".ftl", Schema: "schema.pb", Errors: "errors.pb", @@ -157,11 +168,17 @@ func TestDiscoverModules(t *testing.T) { Language: "go", Realm: "home", Module: "other", - Deploy: []string{"main", "launch"}, + Deploy: []string{"launch", "main"}, DeployDir: ".ftl", Schema: "schema.pb", Errors: "errors.pb", - Watch: []string{"**/*.go", "go.mod", "go.sum", "../../../../go-runtime/ftl/**/*.go", "../../../../go-runtime/schema/testdata/**/*.go"}, + Watch: []string{ + "**/*.go", + "../../../../go-runtime/ftl/**/*.go", + "../../../../go-runtime/schema/testdata/**/*.go", + "go.mod", + "go.sum", + }, }, }, } diff --git a/internal/moduleconfig/moduleconfig.go b/internal/moduleconfig/moduleconfig.go index 35a40f4e0a..430b313d87 100644 --- a/internal/moduleconfig/moduleconfig.go +++ b/internal/moduleconfig/moduleconfig.go @@ -209,7 +209,8 @@ func setConfigDefaults(moduleDir string, config *ModuleConfig) error { return fmt.Errorf("deploy %s files must be relative to the module directory %s", deploy, moduleDir) } } - + config.Deploy = slices.Sort(config.Deploy) + config.Watch = slices.Sort(config.Watch) return nil } diff --git a/internal/slices/slices.go b/internal/slices/slices.go index 4c7b99ef7d..f25acc5a26 100644 --- a/internal/slices/slices.go +++ b/internal/slices/slices.go @@ -70,7 +70,7 @@ func AppendOrReplace[T any](slice []T, value T, fn func(T) bool) []T { func Sort[T cmp.Ordered](slice []T) []T { out := make([]T, len(slice)) copy(out, slice) - sort.Slice(out, func(i, j int) bool { + sort.SliceStable(out, func(i, j int) bool { return out[i] < out[j] }) return out