diff --git a/pkg/compiler/compiler.go b/pkg/compiler/compiler.go index e95d438b..93082ab8 100644 --- a/pkg/compiler/compiler.go +++ b/pkg/compiler/compiler.go @@ -987,6 +987,14 @@ func (cs *LuetCompiler) compile(concurrency int, keepPermissions bool, generateA Assert: assertion, }) + if err := cs.resolveJoinImages(concurrency, keepPermissions, compileSpec); err != nil { + return nil, errors.Wrap(err, "while resolving join images") + } + + if err := cs.resolveMultiStageImages(concurrency, keepPermissions, compileSpec); err != nil { + return nil, errors.Wrap(err, "while resolving multi-stage images") + } + buildHash, err := packageHashTree.DependencyBuildImage(assertion.Package) if err != nil { return nil, errors.Wrap(err, "failed looking for dependency in hashtree") diff --git a/tests/fixtures/join_complex/c/c1/build.yaml b/tests/fixtures/join_complex/c/c1/build.yaml new file mode 100644 index 00000000..32bd4e99 --- /dev/null +++ b/tests/fixtures/join_complex/c/c1/build.yaml @@ -0,0 +1,7 @@ +join: + - name: "a" + category: "test" + version: ">=0" + - name: "b" + category: "test" + version: ">=0" diff --git a/tests/fixtures/join_complex/c/c1/definition.yaml b/tests/fixtures/join_complex/c/c1/definition.yaml new file mode 100644 index 00000000..7c0f2ed8 --- /dev/null +++ b/tests/fixtures/join_complex/c/c1/definition.yaml @@ -0,0 +1,3 @@ +category: "test" +name: "c" +version: "1.2" diff --git a/tests/fixtures/join_complex/c/f/build.yaml b/tests/fixtures/join_complex/c/f/build.yaml new file mode 100644 index 00000000..9c2b8473 --- /dev/null +++ b/tests/fixtures/join_complex/c/f/build.yaml @@ -0,0 +1,8 @@ +join: + - name: "a" + category: "test" + version: ">=0" + - name: "b" + category: "test" + version: ">=0" +unpack: true \ No newline at end of file diff --git a/tests/fixtures/join_complex/c/f/definition.yaml b/tests/fixtures/join_complex/c/f/definition.yaml new file mode 100644 index 00000000..03fba145 --- /dev/null +++ b/tests/fixtures/join_complex/c/f/definition.yaml @@ -0,0 +1,3 @@ +category: "test" +name: "f" +version: "1.2" diff --git a/tests/fixtures/join_complex/cat/a/a/build.yaml b/tests/fixtures/join_complex/cat/a/a/build.yaml new file mode 100644 index 00000000..266699b3 --- /dev/null +++ b/tests/fixtures/join_complex/cat/a/a/build.yaml @@ -0,0 +1,2 @@ +image: "alpine" +unpack: true \ No newline at end of file diff --git a/tests/fixtures/join_complex/cat/a/a/definition.yaml b/tests/fixtures/join_complex/cat/a/a/definition.yaml new file mode 100644 index 00000000..006dd943 --- /dev/null +++ b/tests/fixtures/join_complex/cat/a/a/definition.yaml @@ -0,0 +1,3 @@ +category: "test" +name: "a" +version: "1.2" diff --git a/tests/fixtures/join_complex/cat/b-1.1/build.yaml b/tests/fixtures/join_complex/cat/b-1.1/build.yaml new file mode 100644 index 00000000..62d26ddc --- /dev/null +++ b/tests/fixtures/join_complex/cat/b-1.1/build.yaml @@ -0,0 +1,13 @@ +requires: +- category: "test" + name: "a" + version: ">=0" + +prelude: + - echo foo > /test + - echo bar > /test2 +steps: + - echo artifact5 > /newc + - echo artifact6 > /newnewc + - chmod +x generate.sh + - ./generate.sh diff --git a/tests/fixtures/join_complex/cat/b-1.1/definition.yaml b/tests/fixtures/join_complex/cat/b-1.1/definition.yaml new file mode 100644 index 00000000..e695c6c9 --- /dev/null +++ b/tests/fixtures/join_complex/cat/b-1.1/definition.yaml @@ -0,0 +1,3 @@ +category: "test" +name: "b" +version: "1.1" diff --git a/tests/fixtures/join_complex/cat/b-1.1/generate.sh b/tests/fixtures/join_complex/cat/b-1.1/generate.sh new file mode 100644 index 00000000..3b2dc1b2 --- /dev/null +++ b/tests/fixtures/join_complex/cat/b-1.1/generate.sh @@ -0,0 +1 @@ +echo generated > /sonewc diff --git a/tests/fixtures/join_complex/x/build.yaml b/tests/fixtures/join_complex/x/build.yaml new file mode 100644 index 00000000..5c32411e --- /dev/null +++ b/tests/fixtures/join_complex/x/build.yaml @@ -0,0 +1,10 @@ +join: +- category: "test" + name: "f" + version: ">=0" +# this is actually a virtual, no files shipped in c +- category: "test" + name: "c" + version: ">=0" +steps: +- mv /newnewc /x \ No newline at end of file diff --git a/tests/fixtures/join_complex/x/definition.yaml b/tests/fixtures/join_complex/x/definition.yaml new file mode 100644 index 00000000..8950a1c0 --- /dev/null +++ b/tests/fixtures/join_complex/x/definition.yaml @@ -0,0 +1,3 @@ +name: "x" +category: "test" +version: "0.1" \ No newline at end of file diff --git a/tests/fixtures/join_complex/z/build.yaml b/tests/fixtures/join_complex/z/build.yaml new file mode 100644 index 00000000..263a0da6 --- /dev/null +++ b/tests/fixtures/join_complex/z/build.yaml @@ -0,0 +1,6 @@ +requires: +- category: "test" + name: "c" + version: ">=0" +steps: +- mv /newnewc /z \ No newline at end of file diff --git a/tests/fixtures/join_complex/z/definition.yaml b/tests/fixtures/join_complex/z/definition.yaml new file mode 100644 index 00000000..387e0b51 --- /dev/null +++ b/tests/fixtures/join_complex/z/definition.yaml @@ -0,0 +1,3 @@ +name: "z" +category: "test" +version: "0.1" \ No newline at end of file diff --git a/tests/integration/31_join_complex.sh b/tests/integration/31_join_complex.sh new file mode 100755 index 00000000..a629ecf8 --- /dev/null +++ b/tests/integration/31_join_complex.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +export LUET_NOLOCK=true + +oneTimeSetUp() { + export tmpdir="$(mktemp -d)" + docker images --filter='reference=luet/cache' --format='{{.Repository}}:{{.Tag}}' | xargs -r docker rmi +} + +oneTimeTearDown() { + rm -rf "$tmpdir" + docker images --filter='reference=luet/cache' --format='{{.Repository}}:{{.Tag}}' | xargs -r docker rmi +} + +testBuild() { + [ "$LUET_BACKEND" == "img" ] && startSkipping + mkdir $tmpdir/testbuild + luet build --tree "$ROOT_DIR/tests/fixtures/join_complex" \ + --destination $tmpdir/testbuild --concurrency 1 \ + --compression gzip \ + test/z test/x + buildst=$? + assertEquals 'builds successfully' "$buildst" "0" + assertTrue 'create package z' "[ -e '$tmpdir/testbuild/z-test-0.1.package.tar.gz' ]" + assertTrue 'create package z' "[ -e '$tmpdir/testbuild/x-test-0.1.package.tar.gz' ]" + + mkdir $tmpdir/extract + tar -xvf $tmpdir/testbuild/x-test-0.1.package.tar.gz -C $tmpdir/extract + tar -xvf $tmpdir/testbuild/z-test-0.1.package.tar.gz -C $tmpdir/extract + assertTrue 'create result from a package that requires a join' "[ -e '$tmpdir/extract/z' ]" + assertTrue 'create result from join of a join' "[ -e '$tmpdir/extract/x' ]" +} + + +# Load shUnit2. +. "$ROOT_DIR/tests/integration/shunit2"/shunit2 +