diff --git a/docker-bake.hcl b/docker-bake.hcl index 857e0855d..2a658f275 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -100,9 +100,9 @@ target "runc-jammy" { } target = tgt == "container" ? "jammy/testing/${tgt}" : "jammy/${tgt}" // only tag the container target - tags = tgt == "testing/container" ? ["runc:jammy"] : [] + tags = tgt == "container" ? ["runc:jammy"] : [] // only output non-container targets to the fs - output = tgt != "testing/container" ? ["_output"] : [] + output = tgt != "container" ? ["_output"] : [] cache-from = ["type=gha,scope=dalec/runc/jammy/${tgt}"] cache-to = DALEC_NO_CACHE_EXPORT != "1" ? ["type=gha,scope=dalec/runc/jammy/${tgt},mode=max"] : [] diff --git a/frontend/build.go b/frontend/build.go index 8482b3a56..146133b83 100644 --- a/frontend/build.go +++ b/frontend/build.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "fmt" + "time" "github.com/Azure/dalec" "github.com/containerd/platforms" @@ -88,6 +89,10 @@ func BuildWithPlatform(ctx context.Context, client gwclient.Client, f PlatformBu targetKey := GetTargetKey(dc) ref, cfg, err := f(ctx, client, platform, spec, targetKey) + if cfg != nil { + now := time.Now() + cfg.Created = &now + } return ref, cfg, nil, err }) if err != nil { diff --git a/test/azlinux_test.go b/test/azlinux_test.go index 9c0019e4c..eacd2c821 100644 --- a/test/azlinux_test.go +++ b/test/azlinux_test.go @@ -8,6 +8,7 @@ import ( "path/filepath" "strings" "testing" + "time" "github.com/Azure/dalec" "github.com/Azure/dalec/frontend/azlinux" @@ -17,6 +18,7 @@ import ( gwclient "github.com/moby/buildkit/frontend/gateway/client" moby_buildkit_v1_frontend "github.com/moby/buildkit/frontend/gateway/pb" ocispecs "github.com/opencontainers/image-spec/specs-go/v1" + "golang.org/x/exp/maps" "gotest.tools/v3/assert" ) @@ -528,7 +530,16 @@ echo "$BAR" > bar.txt ) sr.Evaluate = true - solveT(ctx, t, gwc, sr) + beforeBuild := time.Now() + res := solveT(ctx, t, gwc, sr) + + dt, ok := res.Metadata[exptypes.ExporterImageConfigKey] + assert.Assert(t, ok, "result metadata should contain an image config: available metadata: %s", strings.Join(maps.Keys(res.Metadata), ", ")) + + var cfg dalec.DockerImageSpec + assert.Assert(t, json.Unmarshal(dt, &cfg)) + assert.Check(t, cfg.Created.After(beforeBuild)) + assert.Check(t, cfg.Created.Before(time.Now())) // Make sure the test framework was actually executed by the build target. // This appends a test case so that is expected to fail and as such cause the build to fail. @@ -542,7 +553,8 @@ echo "$BAR" > bar.txt // update the spec in the solve request withSpec(ctx, t, &spec)(&newSolveRequestConfig{req: &sr}) - if _, err := gwc.Solve(ctx, sr); err == nil { + _, err := gwc.Solve(ctx, sr) + if err == nil { t.Fatal("expected test spec to run with error but got none") } })