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

Set image create #441

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"] : []
Expand Down
5 changes: 5 additions & 0 deletions frontend/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"time"

"github.com/Azure/dalec"
"github.com/containerd/platforms"
Expand Down Expand Up @@ -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 {
Expand Down
16 changes: 14 additions & 2 deletions test/azlinux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path/filepath"
"strings"
"testing"
"time"

"github.com/Azure/dalec"
"github.com/Azure/dalec/frontend/azlinux"
Expand All @@ -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"
)

Expand Down Expand Up @@ -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.
Expand All @@ -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")
}
})
Expand Down