Skip to content

Commit

Permalink
tiltfile: make docker compose dependency order deterministic (#6335)
Browse files Browse the repository at this point in the history
i don't think this affects anything in practice!
But it mostly helps ensure tests are deterministic.

Signed-off-by: Nick Santos <nick.santos@docker.com>
  • Loading branch information
nicks authored Mar 13, 2024
1 parent 71299e1 commit 3b4ddc2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 2 additions & 3 deletions internal/tiltfile/docker_compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,8 @@ func dockerComposeConfigToService(dcrs *dcResourceSet, projectName string, svcCo
dcrs.resOptions[svcConfig.Name] = options
}

for _, dep := range svcConfig.GetDependencies() {
options.resourceDeps = sliceutils.AppendWithoutDupes(options.resourceDeps, dep)
}
options.resourceDeps = sliceutils.DedupedAndSorted(
append(options.resourceDeps, svcConfig.GetDependencies()...))

svc := dcService{
Name: svcConfig.Name,
Expand Down
14 changes: 13 additions & 1 deletion internal/tiltfile/docker_compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,21 @@ services:

services := f.parse(output)
if assert.Len(t, services, 6) {
for i, name := range []string{"f", "e", "d", "c", "b", "a"} {
serviceOrder := []string{"f", "e", "d", "c", "b", "a"}
for i, name := range serviceOrder {
assert.Equal(t, name, services[i].Name)
}
depOrder := [][]string{
[]string{},
[]string{"f"},
[]string{"e", "f"},
[]string{"d", "e", "f"},
[]string{"c"},
[]string{"b"},
}
for i, deps := range depOrder {
assert.Equal(t, deps, services[i].Options.resourceDeps)
}
}
}

Expand Down

0 comments on commit 3b4ddc2

Please sign in to comment.