-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Makes sure distros are tested with go modules. Also fixes the Windows implementation. Signed-off-by: Brian Goff <[email protected]>
- Loading branch information
Showing
5 changed files
with
178 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,20 +157,36 @@ index 0000000..5260cb1 | |
|
||
Dependencies: &dalec.PackageDependencies{ | ||
Runtime: map[string][]string{ | ||
"bash": {}, | ||
"bash": {}, | ||
"coreutils": {}, | ||
}, | ||
}, | ||
|
||
Build: dalec.ArtifactBuild{ | ||
Steps: []dalec.BuildStep{ | ||
// These are "build" steps where we aren't really building things just verifying | ||
// that sources are in the right place and have the right permissions and content | ||
{ | ||
// file added by patch | ||
Command: "test -f ./src1", | ||
}, | ||
{ | ||
Command: "test -x ./src1", | ||
}, | ||
{ | ||
Command: "test ! -d ./src1", | ||
}, | ||
{ | ||
Command: "./src1 | grep 'hello world'", | ||
}, | ||
{ | ||
// file added by patch | ||
Command: "ls -lh ./src2/file2", | ||
}, | ||
{ | ||
// file added by patch | ||
Command: "test -f ./src2/file2", | ||
}, | ||
{ | ||
// file added by patch | ||
Command: "test -x ./src2/file2", | ||
|
@@ -316,4 +332,60 @@ echo "$BAR" > bar.txt | |
|
||
runTest(t, distroSigningTest(t, &spec, signTarget)) | ||
}) | ||
|
||
t.Run("go module", func(t *testing.T) { | ||
t.Parallel() | ||
ctx := startTestSpan(baseCtx, t) | ||
|
||
spec := &dalec.Spec{ | ||
Name: "test-build-with-gomod", | ||
Version: "0.0.1", | ||
Revision: "1", | ||
License: "MIT", | ||
Website: "https://github.com/azure/dalec", | ||
Vendor: "Dalec", | ||
Packager: "Dalec", | ||
Description: "Testing container target", | ||
Sources: map[string]dalec.Source{ | ||
"src": { | ||
Generate: []*dalec.SourceGenerator{ | ||
{ | ||
Gomod: &dalec.GeneratorGomod{}, | ||
}, | ||
}, | ||
Inline: &dalec.SourceInline{ | ||
Dir: &dalec.SourceInlineDir{ | ||
Files: map[string]*dalec.SourceInlineFile{ | ||
"main.go": {Contents: gomodFixtureMain}, | ||
"go.mod": {Contents: gomodFixtureMod}, | ||
"go.sum": {Contents: gomodFixtureSum}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
Dependencies: &dalec.PackageDependencies{ | ||
Build: map[string][]string{ | ||
// TODO: This works at least for now, but is distro specific and | ||
// could break on new distros (though that is still unlikely). | ||
"golang": {}, | ||
}, | ||
}, | ||
Build: dalec.ArtifactBuild{ | ||
Steps: []dalec.BuildStep{ | ||
{Command: "[ -d \"${GOMODCACHE}/github.com/cpuguy83/[email protected]\" ]"}, | ||
{Command: "[ -d ./src ]"}, | ||
{Command: "[ -f ./src/main.go ]"}, | ||
{Command: "[ -f ./src/go.mod ]"}, | ||
{Command: "[ -f ./src/go.sum ]"}, | ||
{Command: "cd ./src && go build"}, | ||
}, | ||
}, | ||
} | ||
|
||
testEnv.RunTest(ctx, t, func(ctx context.Context, client gwclient.Client) (*gwclient.Result, error) { | ||
req := newSolveRequest(withBuildTarget(buildTarget), withSpec(ctx, t, spec)) | ||
return client.Solve(ctx, req) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -336,6 +336,62 @@ echo "$BAR" > bar.txt | |
return gwclient.NewResult(), nil | ||
}) | ||
}) | ||
|
||
t.Run("go module", func(t *testing.T) { | ||
t.Parallel() | ||
ctx := startTestSpan(baseCtx, t) | ||
|
||
spec := &dalec.Spec{ | ||
Name: "test-build-with-gomod", | ||
Version: "0.0.1", | ||
Revision: "1", | ||
License: "MIT", | ||
Website: "https://github.com/azure/dalec", | ||
Vendor: "Dalec", | ||
Packager: "Dalec", | ||
Description: "Testing container target", | ||
Sources: map[string]dalec.Source{ | ||
"src": { | ||
Generate: []*dalec.SourceGenerator{ | ||
{ | ||
Gomod: &dalec.GeneratorGomod{}, | ||
}, | ||
}, | ||
Inline: &dalec.SourceInline{ | ||
Dir: &dalec.SourceInlineDir{ | ||
Files: map[string]*dalec.SourceInlineFile{ | ||
"main.go": {Contents: gomodFixtureMain}, | ||
"go.mod": {Contents: gomodFixtureMod}, | ||
"go.sum": {Contents: gomodFixtureSum}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
Dependencies: &dalec.PackageDependencies{ | ||
Build: map[string][]string{ | ||
// TODO: This works at least for now, but is distro specific and | ||
// could break on new distros (though that is still unlikely). | ||
"golang": {}, | ||
}, | ||
}, | ||
Build: dalec.ArtifactBuild{ | ||
Steps: []dalec.BuildStep{ | ||
{Command: "[ -d \"${GOMODCACHE}/github.com/cpuguy83/[email protected]\" ]"}, | ||
{Command: "[ -d ./src ]"}, | ||
{Command: "[ -f ./src/main.go ]"}, | ||
{Command: "[ -f ./src/go.mod ]"}, | ||
{Command: "[ -f ./src/go.sum ]"}, | ||
{Command: "cd ./src && go build"}, | ||
}, | ||
}, | ||
} | ||
|
||
testEnv.RunTest(ctx, t, func(ctx context.Context, client gwclient.Client) (*gwclient.Result, error) { | ||
req := newSolveRequest(withBuildTarget(buildTarget), withSpec(ctx, t, spec)) | ||
return client.Solve(ctx, req) | ||
}) | ||
}) | ||
} | ||
|
||
func reqToState(ctx context.Context, gwc gwclient.Client, sr gwclient.SolveRequest, t *testing.T) llb.State { | ||
|