Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduced include to filter files considered by watch #12584

Merged
merged 2 commits into from
Mar 3, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
e2e test for watch.include
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Mar 3, 2025
commit 7bd320f8c7b76576e4d2ca25a2c5fca05d240203
12 changes: 12 additions & 0 deletions pkg/e2e/fixtures/watch/include.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
a:
build:
dockerfile_inline: |
FROM nginx
RUN mkdir /data/
develop:
watch:
- path: .
include: A.*
target: /data/
action: sync
37 changes: 37 additions & 0 deletions pkg/e2e/watch_test.go
Original file line number Diff line number Diff line change
@@ -368,3 +368,40 @@ func TestWatchMultiServices(t *testing.T) {

c.RunDockerComposeCmdNoCheck(t, "-p", projectName, "kill", "-s", "9")
}

func TestWatchIncludes(t *testing.T) {
c := NewCLI(t)
const projectName = "test_watch_includes"

defer c.cleanupWithDown(t, projectName)

tmpdir := t.TempDir()
composeFilePath := filepath.Join(tmpdir, "compose.yaml")
CopyFile(t, filepath.Join("fixtures", "watch", "include.yaml"), composeFilePath)

cmd := c.NewDockerComposeCmd(t, "-p", projectName, "-f", composeFilePath, "up", "--watch")
buffer := bytes.NewBuffer(nil)
cmd.Stdout = buffer
watch := icmd.StartCmd(cmd)

poll.WaitOn(t, func(l poll.LogT) poll.Result {
if strings.Contains(watch.Stdout(), "Attaching to ") {
return poll.Success()
}
return poll.Continue("%v", watch.Stdout())
})

require.NoError(t, os.WriteFile(filepath.Join(tmpdir, "B.test"), []byte("test"), 0o600))
require.NoError(t, os.WriteFile(filepath.Join(tmpdir, "A.test"), []byte("test"), 0o600))

poll.WaitOn(t, func(l poll.LogT) poll.Result {
cat := c.RunDockerComposeCmdNoCheck(t, "-p", projectName, "exec", "a", "ls", "/data/")
if strings.Contains(cat.Stdout(), "A.test") {
assert.Check(t, !strings.Contains(cat.Stdout(), "B.test"))
return poll.Success()
}
return poll.Continue("%v", cat.Combined())
})

c.RunDockerComposeCmdNoCheck(t, "-p", projectName, "kill", "-s", "9")
}
Loading
Oops, something went wrong.