Skip to content

Commit

Permalink
printer: dedup warnings
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Jun 25, 2024
1 parent c01e5d4 commit a306ee6
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 1 deletion.
61 changes: 61 additions & 0 deletions tests/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var bakeTests = []func(t *testing.T, sb integration.Sandbox){
testBakeUlimits,
testBakeMetadataProvenance,
testBakeMetadataWarnings,
testBakeMetadataWarningsDedup,
testBakeMultiExporters,
testBakeLoadPush,
}
Expand Down Expand Up @@ -778,6 +779,66 @@ target "default" {
require.Len(t, md.BuildWarnings, 3)
}

func testBakeMetadataWarningsDedup(t *testing.T, sb integration.Sandbox) {
dockerfile := []byte(`
frOM busybox as base
cOpy Dockerfile .
from scratch
COPy --from=base \
/Dockerfile \
/
`)
bakefile := []byte(`
group "default" {
targets = ["base", "def"]
}
target "base" {
target = "base"
}
target "def" {
}
`)
dir := tmpdir(
t,
fstest.CreateFile("docker-bake.hcl", bakefile, 0600),
fstest.CreateFile("Dockerfile", dockerfile, 0600),
)

dirDest := t.TempDir()

cmd := buildxCmd(
sb,
withDir(dir),
withArgs("bake", "--metadata-file", filepath.Join(dirDest, "md.json"), "--set", "*.output=type=cacheonly"),
withEnv("BUILDX_METADATA_WARNINGS=true"),
)
out, err := cmd.CombinedOutput()
require.NoError(t, err, string(out))

dt, err := os.ReadFile(filepath.Join(dirDest, "md.json"))
require.NoError(t, err)

type mdT struct {
BuildWarnings []client.VertexWarning `json:"buildx.build.warnings"`
Base struct {
BuildRef string `json:"buildx.build.ref"`
} `json:"base"`
Def struct {
BuildRef string `json:"buildx.build.ref"`
} `json:"def"`
}
var md mdT
err = json.Unmarshal(dt, &md)
require.NoError(t, err)

require.NotEmpty(t, md.Base.BuildRef)
require.NotEmpty(t, md.Def.BuildRef)
require.NotEmpty(t, md.BuildWarnings)

Check failure on line 836 in tests/bake.go

View workflow job for this annotation

GitHub Actions / test-integration (v0.12.5, remote, ./tests)

Failed: tests/TestIntegration/TestBakeMetadataWarningsDedup/worker=remote

=== RUN TestIntegration/TestBakeMetadataWarningsDedup/worker=remote === PAUSE TestIntegration/TestBakeMetadataWarningsDedup/worker=remote === CONT TestIntegration/TestBakeMetadataWarningsDedup/worker=remote bake.go:836: Error Trace: /src/tests/bake.go:836 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:95 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:212 Error: Should NOT be empty, but was [] Test: TestIntegration/TestBakeMetadataWarningsDedup/worker=remote sandbox.go:133: stdout: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config3127219151/buildkitd.toml --root /tmp/bktest_buildkitd590824101 --addr unix:///tmp/bktest_buildkitd590824101/buildkitd.sock --debug sandbox.go:133: stderr: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config3127219151/buildkitd.toml --root /tmp/bktest_buildkitd590824101 --addr unix:///tmp/bktest_buildkitd590824101/buildkitd.sock --debug sandbox.go:136: > StartCmd 2024-06-25 09:19:34.085130896 +0000 UTC m=+8.478209966 /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config3127219151/buildkitd.toml --root /tmp/bktest_buildkitd590824101 --addr unix:///tmp/bktest_buildkitd590824101/buildkitd.sock --debug sandbox.go:136: time="2024-06-25T09:19:34Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:136: time="2024-06-25T09:19:34Z" level=warning msg="using host network as the default" sandbox.go:136: time="2024-06-25T09:19:34Z" level=info msg="found worker \"zmu5hi6hnekn4db8z64w0iqhi\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:e8d0bf64bc3f org.mobyproject.buildkit.worker.network:host org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.sandbox:true org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/mips64le linux/mips64 linux/arm/v7 linux/arm/v6]" sandbox.go:136: time="2024-06-25T09:19:34Z" level=info msg="found 1 workers, default=\"zmu5hi6hnekn4db8z64w0iqhi\"" sandbox.go:136: time="2024-06-25T09:19:34Z" level=warning msg="currently, only the default worker can be used." sandbox.go:136: time="2024-06-25T09:19:34Z" level=info msg="running server on /tmp/bktest_buildkitd590824101/buildkitd.sock" sandbox.go:136: time="2024-06-25T09:19:34Z" level=debug msg="session started" spanID=329acaa03b654bb6 traceID=50cdb2de11ba91a6235d0fb098ea17fe sandbox.go:136: time="2024-06-25T09:19:34Z" level=debug msg="session finished: <nil>" spanID=329acaa03b654bb6 traceID=50cdb2de11ba91a6235d0fb098ea17fe sandbox.go:136: time="2024-06-25T09:19:34Z" level=debug msg="session started" spanID=2aabd215909eac8e traceID=50cdb2de11ba91a6235d0fb098ea17fe sandbox.go:136: time="2024-06-25T09:19:34Z" level=debug msg="new ref for local: o3jnda8tlx7p4rnpia0ahwlay" span="[internal] load build definition from Dockerfile" spanID=f02f55e08c0fbc64 traceID=50cdb2de11ba91a6235d0fb098ea17fe sandbox.go:136: time="2024-06-25T09:19:34Z" level=debug msg="diffcopy took: 2.823304ms" span="[internal] load build definition from Dockerfile" spanID=87f130bd429a74ad traceID=50cdb2de11ba91a6235d0fb098ea17fe sandbox.go:136: time="2024-06-25T09:19:34Z" level=debug msg="saved o3jnda8tlx7p4rnpia0ahwlay as dockerfile:dockerfile:" span="[internal] load build definition from Dockerfile" spanID=f02f55e08c0fbc64 traceID=50cdb2de11ba91a6235d0fb098ea17fe sandbox.go:136: time="2024-06-25T09:19:34Z" level=debug msg=resolv

Check failure on line 836 in tests/bake.go

View workflow job for this annotation

GitHub Actions / test-integration (v0.13.1, remote, ./tests)

Failed: tests/TestIntegration/TestBakeMetadataWarningsDedup/worker=remote

=== RUN TestIntegration/TestBakeMetadataWarningsDedup/worker=remote === PAUSE TestIntegration/TestBakeMetadataWarningsDedup/worker=remote === CONT TestIntegration/TestBakeMetadataWarningsDedup/worker=remote bake.go:836: Error Trace: /src/tests/bake.go:836 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:95 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:212 Error: Should NOT be empty, but was [] Test: TestIntegration/TestBakeMetadataWarningsDedup/worker=remote sandbox.go:133: stderr: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config3109495949/buildkitd.toml --root /tmp/bktest_buildkitd2414388258 --addr unix:///tmp/bktest_buildkitd2414388258/buildkitd.sock --debug sandbox.go:136: > StartCmd 2024-06-25 09:19:45.579065005 +0000 UTC m=+11.073288217 /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config3109495949/buildkitd.toml --root /tmp/bktest_buildkitd2414388258 --addr unix:///tmp/bktest_buildkitd2414388258/buildkitd.sock --debug sandbox.go:136: time="2024-06-25T09:19:45Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:136: time="2024-06-25T09:19:45Z" level=warning msg="using host network as the default" sandbox.go:136: time="2024-06-25T09:19:45Z" level=info msg="found worker \"0zt2vdgnik14c6rvlf0v7ovl8\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:abf425301b92 org.mobyproject.buildkit.worker.network:host org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.sandbox:true org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/mips64le linux/mips64 linux/arm/v7 linux/arm/v6]" sandbox.go:136: time="2024-06-25T09:19:45Z" level=info msg="found 1 workers, default=\"0zt2vdgnik14c6rvlf0v7ovl8\"" sandbox.go:136: time="2024-06-25T09:19:45Z" level=warning msg="currently, only the default worker can be used." sandbox.go:136: time="2024-06-25T09:19:45Z" level=info msg="running server on /tmp/bktest_buildkitd2414388258/buildkitd.sock" sandbox.go:136: time="2024-06-25T09:19:45Z" level=debug msg="session started" spanID=5f5511592af42104 traceID=e409a55513ffded09192ad61fe312244 sandbox.go:136: time="2024-06-25T09:19:45Z" level=debug msg="session finished: <nil>" spanID=5f5511592af42104 traceID=e409a55513ffded09192ad61fe312244 sandbox.go:136: time="2024-06-25T09:19:45Z" level=debug msg="session started" spanID=52f37ee98892a2b2 traceID=e409a55513ffded09192ad61fe312244 sandbox.go:136: time="2024-06-25T09:19:46Z" level=debug msg="new ref for local: lt0ld51zaif7iyj7py7plbhle" span="[internal] load build definition from Dockerfile" spanID=da585e3d18bfd073 traceID=e409a55513ffded09192ad61fe312244 sandbox.go:136: time="2024-06-25T09:19:46Z" level=debug msg="diffcopy took: 5.130079ms" span="[internal] load build definition from Dockerfile" spanID=9765913c44c1a7c7 traceID=e409a55513ffded09192ad61fe312244 sandbox.go:136: time="2024-06-25T09:19:46Z" level=debug msg="saved lt0ld51zaif7iyj7py7plbhle as dockerfile:dockerfile:" span="[internal] load build definition from Dockerfile" spanID=da585e3d18bfd073 traceID=e409a55513ffded09192ad61fe312244 sandbox.go:136: time="2024-06-25T09:19:46Z" level=debug msg="checked for cached auth handler namespace" cached=false key="docker.io/library/busybox::pull" name=docker.io/library/busybox scope=pull sandbox.go:136: time="2024-06-25T09:19:46Z" level=debug msg=resolving host="localhost:46611" sandbox.go:136: time="2024-06-25T09:19:46Z" level=debug msg="do request" host="localhost:46611" req

Check failure on line 836 in tests/bake.go

View workflow job for this annotation

GitHub Actions / test-integration (v0.12.5, remote, ./tests, experimental)

Failed: tests/TestIntegration/TestBakeMetadataWarningsDedup/worker=remote

=== RUN TestIntegration/TestBakeMetadataWarningsDedup/worker=remote === PAUSE TestIntegration/TestBakeMetadataWarningsDedup/worker=remote === CONT TestIntegration/TestBakeMetadataWarningsDedup/worker=remote bake.go:836: Error Trace: /src/tests/bake.go:836 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:95 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:212 Error: Should NOT be empty, but was [] Test: TestIntegration/TestBakeMetadataWarningsDedup/worker=remote sandbox.go:133: stderr: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1545211583/buildkitd.toml --root /tmp/bktest_buildkitd2451668565 --addr unix:///tmp/bktest_buildkitd2451668565/buildkitd.sock --debug sandbox.go:136: > StartCmd 2024-06-25 09:19:51.770040111 +0000 UTC m=+14.971546579 /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config1545211583/buildkitd.toml --root /tmp/bktest_buildkitd2451668565 --addr unix:///tmp/bktest_buildkitd2451668565/buildkitd.sock --debug sandbox.go:136: time="2024-06-25T09:19:51Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:136: time="2024-06-25T09:19:51Z" level=warning msg="using host network as the default" sandbox.go:136: time="2024-06-25T09:19:51Z" level=info msg="found worker \"keqysl2ftgswvib8zbdhi2z2i\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:831b63b85dfd org.mobyproject.buildkit.worker.network:host org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.sandbox:true org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/mips64le linux/mips64 linux/arm/v7 linux/arm/v6]" sandbox.go:136: time="2024-06-25T09:19:51Z" level=info msg="found 1 workers, default=\"keqysl2ftgswvib8zbdhi2z2i\"" sandbox.go:136: time="2024-06-25T09:19:51Z" level=warning msg="currently, only the default worker can be used." sandbox.go:136: time="2024-06-25T09:19:51Z" level=info msg="running server on /tmp/bktest_buildkitd2451668565/buildkitd.sock" sandbox.go:136: time="2024-06-25T09:19:52Z" level=debug msg="session started" spanID=dda6a0ce33b33eb5 traceID=9eb368f4e1da8e37f52694aa2c014180 sandbox.go:136: time="2024-06-25T09:19:52Z" level=debug msg="session finished: <nil>" spanID=dda6a0ce33b33eb5 traceID=9eb368f4e1da8e37f52694aa2c014180 sandbox.go:136: time="2024-06-25T09:19:52Z" level=debug msg="session started" spanID=1a793530600f2a0d traceID=9eb368f4e1da8e37f52694aa2c014180 sandbox.go:136: time="2024-06-25T09:19:52Z" level=debug msg="new ref for local: 32mlzcgqft21960y8i9ksixre" span="[internal] load build definition from Dockerfile" spanID=560fba374569a556 traceID=9eb368f4e1da8e37f52694aa2c014180 sandbox.go:136: time="2024-06-25T09:19:52Z" level=debug msg="diffcopy took: 4.023253ms" span="[internal] load build definition from Dockerfile" spanID=d59c8f104d56847c traceID=9eb368f4e1da8e37f52694aa2c014180 sandbox.go:136: time="2024-06-25T09:19:52Z" level=debug msg="saved 32mlzcgqft21960y8i9ksixre as dockerfile:dockerfile:" span="[internal] load build definition from Dockerfile" spanID=560fba374569a556 traceID=9eb368f4e1da8e37f52694aa2c014180 sandbox.go:136: time="2024-06-25T09:19:52Z" level=debug msg=resolving host="localhost:36927" spanID=17825e2094d6a62a traceID=9eb368f4e1da8e37f52694aa2c014180 sandbox.go:136: time="2024-06-25T09:19:52Z" level=debug msg="do request" host="localhost:36927" request.header.accept="application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, app

Check failure on line 836 in tests/bake.go

View workflow job for this annotation

GitHub Actions / test-integration (v0.13.1, remote, ./tests, experimental)

Failed: tests/TestIntegration/TestBakeMetadataWarningsDedup/worker=remote

=== RUN TestIntegration/TestBakeMetadataWarningsDedup/worker=remote === PAUSE TestIntegration/TestBakeMetadataWarningsDedup/worker=remote === CONT TestIntegration/TestBakeMetadataWarningsDedup/worker=remote bake.go:836: Error Trace: /src/tests/bake.go:836 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:95 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:212 Error: Should NOT be empty, but was [] Test: TestIntegration/TestBakeMetadataWarningsDedup/worker=remote sandbox.go:133: stdout: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config2684742493/buildkitd.toml --root /tmp/bktest_buildkitd3299214675 --addr unix:///tmp/bktest_buildkitd3299214675/buildkitd.sock --debug sandbox.go:133: stderr: /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config2684742493/buildkitd.toml --root /tmp/bktest_buildkitd3299214675 --addr unix:///tmp/bktest_buildkitd3299214675/buildkitd.sock --debug sandbox.go:136: > StartCmd 2024-06-25 09:19:48.650278753 +0000 UTC m=+7.114551955 /usr/bin/buildkitd --oci-worker=true --containerd-worker=false --oci-worker-gc=false --oci-worker-labels=org.mobyproject.buildkit.worker.sandbox=true --config=/tmp/bktest_config2684742493/buildkitd.toml --root /tmp/bktest_buildkitd3299214675 --addr unix:///tmp/bktest_buildkitd3299214675/buildkitd.sock --debug sandbox.go:136: time="2024-06-25T09:19:48Z" level=info msg="auto snapshotter: using overlayfs" sandbox.go:136: time="2024-06-25T09:19:48Z" level=warning msg="using host network as the default" sandbox.go:136: time="2024-06-25T09:19:48Z" level=info msg="found worker \"qjujqwdnbe1j1opi9wo3pdcjp\", labels=map[org.mobyproject.buildkit.worker.executor:oci org.mobyproject.buildkit.worker.hostname:466465f9989a org.mobyproject.buildkit.worker.network:host org.mobyproject.buildkit.worker.oci.process-mode:sandbox org.mobyproject.buildkit.worker.sandbox:true org.mobyproject.buildkit.worker.selinux.enabled:false org.mobyproject.buildkit.worker.snapshotter:overlayfs], platforms=[linux/amd64 linux/amd64/v2 linux/amd64/v3 linux/arm64 linux/riscv64 linux/ppc64le linux/s390x linux/386 linux/mips64le linux/mips64 linux/arm/v7 linux/arm/v6]" sandbox.go:136: time="2024-06-25T09:19:48Z" level=info msg="found 1 workers, default=\"qjujqwdnbe1j1opi9wo3pdcjp\"" sandbox.go:136: time="2024-06-25T09:19:48Z" level=warning msg="currently, only the default worker can be used." sandbox.go:136: time="2024-06-25T09:19:48Z" level=info msg="running server on /tmp/bktest_buildkitd3299214675/buildkitd.sock" sandbox.go:136: time="2024-06-25T09:19:49Z" level=debug msg="session started" spanID=7a1e2ffa67aabb50 traceID=3133382fc31b0f0f8d1b26afa3a0dbb3 sandbox.go:136: time="2024-06-25T09:19:49Z" level=debug msg="session finished: <nil>" spanID=7a1e2ffa67aabb50 traceID=3133382fc31b0f0f8d1b26afa3a0dbb3 sandbox.go:136: time="2024-06-25T09:19:49Z" level=debug msg="session started" spanID=2bbe0ce31dbb9770 traceID=3133382fc31b0f0f8d1b26afa3a0dbb3 sandbox.go:136: time="2024-06-25T09:19:49Z" level=debug msg="new ref for local: l2vn8dw63kz45nuhvxdliy15k" span="[internal] load build definition from Dockerfile" spanID=41bc0878df4a717a traceID=3133382fc31b0f0f8d1b26afa3a0dbb3 sandbox.go:136: time="2024-06-25T09:19:49Z" level=debug msg="diffcopy took: 3.450395ms" span="[internal] load build definition from Dockerfile" spanID=0c168362b0a36e10 traceID=3133382fc31b0f0f8d1b26afa3a0dbb3 sandbox.go:136: time="2024-06-25T09:19:49Z" level=debug msg="saved l2vn8dw63kz45nuhvxdliy15k as dockerfile:dockerfile:" span="[internal] load build definition from Dockerfile" spanID=41bc0878df4a717a traceID=3133382fc31b0f0f8d1b26afa3a0dbb3 sandbox.go:136: time="2024-06-25T09:19:49Z" level=debug msg

Check failure on line 836 in tests/bake.go

View workflow job for this annotation

GitHub Actions / test-integration (v0.13.1, docker-container, ./tests, experimental)

Failed: tests/TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container

=== RUN TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container === PAUSE TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container === CONT TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container bake.go:836: Error Trace: /src/tests/bake.go:836 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:95 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:212 Error: Should NOT be empty, but was [] Test: TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container --- FAIL: TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container (1.19s)

Check failure on line 836 in tests/bake.go

View workflow job for this annotation

GitHub Actions / test-integration (v0.12.5, docker-container, ./tests)

Failed: tests/TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container

=== RUN TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container === PAUSE TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container === CONT TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container bake.go:836: Error Trace: /src/tests/bake.go:836 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:95 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:212 Error: Should NOT be empty, but was [] Test: TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container --- FAIL: TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container (1.41s)

Check failure on line 836 in tests/bake.go

View workflow job for this annotation

GitHub Actions / test-integration (v0.13.1, docker-container, ./tests)

Failed: tests/TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container

=== RUN TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container === PAUSE TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container === CONT TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container bake.go:836: Error Trace: /src/tests/bake.go:836 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:95 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:212 Error: Should NOT be empty, but was [] Test: TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container --- FAIL: TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container (1.37s)

Check failure on line 836 in tests/bake.go

View workflow job for this annotation

GitHub Actions / test-integration (v0.12.5, docker-container, ./tests, experimental)

Failed: tests/TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container

=== RUN TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container === PAUSE TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container === CONT TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container bake.go:836: Error Trace: /src/tests/bake.go:836 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:95 /src/vendor/github.com/moby/buildkit/util/testutil/integration/run.go:212 Error: Should NOT be empty, but was [] Test: TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container --- FAIL: TestIntegration/TestBakeMetadataWarningsDedup/worker=docker-container (1.70s)

skipNoCompatBuildKit(t, sb, ">= 0.14.0-0", "lint")
require.Len(t, md.BuildWarnings, 3)
}

func testBakeMultiExporters(t *testing.T, sb integration.Sandbox) {
if !isDockerContainerWorker(sb) {
t.Skip("only testing with docker-container worker")
Expand Down
37 changes: 36 additions & 1 deletion util/progress/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package progress

import (
"context"
"crypto/sha256"
"encoding/hex"
"os"
"sync"

Expand Down Expand Up @@ -58,7 +60,7 @@ func (p *Printer) Write(s *client.SolveStatus) {
}

func (p *Printer) Warnings() []client.VertexWarning {
return p.warnings
return dedupWarnings(p.warnings)
}

func (p *Printer) ValidateLogSource(dgst digest.Digest, v interface{}) bool {
Expand Down Expand Up @@ -184,3 +186,36 @@ func WithOnClose(onclose func()) PrinterOpt {
opt.onclose = onclose
}
}

func dedupWarnings(inp []client.VertexWarning) []client.VertexWarning {
m := make(map[string]client.VertexWarning)
for _, w := range inp {
h := sha256.New()
h.Write(w.Short)
h.Write([]byte{0})
for _, d := range w.Detail {
h.Write(d)
h.Write([]byte{0})
}
h.Write([]byte(w.URL))
h.Write([]byte{0})
for _, r := range w.Range {
h.Write([]byte(r.String()))
h.Write([]byte{0})
}
if w.SourceInfo != nil {
h.Write([]byte(w.SourceInfo.Filename))
h.Write([]byte(w.SourceInfo.Data))
}
h.Write([]byte{0})
hkey := hex.EncodeToString(h.Sum(nil))
if _, ok := m[hkey]; !ok {
m[hkey] = w
}
}
res := make([]client.VertexWarning, 0, len(m))
for _, w := range m {
res = append(res, w)
}
return res
}

0 comments on commit a306ee6

Please sign in to comment.