26d24e6ac0
The goal is to preserve the container.input interface so that custom images can be specified, as per yarn/test/test.cue while keeping the initial fix for https://github.com/dagger/dagger/issues/1670 Signed-off-by: Gerhard Lazu <gerhard@lazu.co.uk>
91 lines
1.4 KiB
CUE
91 lines
1.4 KiB
CUE
package yarn
|
|
|
|
import (
|
|
"dagger.io/dagger"
|
|
|
|
"universe.dagger.io/docker"
|
|
"universe.dagger.io/yarn"
|
|
)
|
|
|
|
dagger.#Plan & {
|
|
inputs: directories: {
|
|
testdata: path: "./data/foo"
|
|
testdata2: path: "./data/bar"
|
|
}
|
|
|
|
actions: tests: {
|
|
|
|
// Configuration for all tests
|
|
common: {
|
|
data: inputs.directories.testdata.contents
|
|
}
|
|
|
|
// Run yarn.#Build
|
|
simple: {
|
|
build: yarn.#Build & {
|
|
source: common.data
|
|
}
|
|
|
|
verify: #AssertFile & {
|
|
input: build.output
|
|
path: "test"
|
|
contents: "output\n"
|
|
}
|
|
}
|
|
|
|
// Run yarn.#Build with a custom name
|
|
customName: {
|
|
build: yarn.#Build & {
|
|
name: "My Build"
|
|
source: common.data
|
|
}
|
|
verify: #AssertFile & {
|
|
input: build.output
|
|
path: "test"
|
|
contents: "output\n"
|
|
}
|
|
}
|
|
|
|
// Run yarn.#Build with a custom docker image
|
|
customImage: {
|
|
buildImage: docker.#Build & {
|
|
steps: [
|
|
docker.#Pull & {
|
|
source: "alpine"
|
|
},
|
|
docker.#Run & {
|
|
command: {
|
|
name: "apk"
|
|
args: ["add", "yarn", "bash"]
|
|
}
|
|
},
|
|
]
|
|
}
|
|
|
|
image: build.output
|
|
|
|
build: yarn.#Build & {
|
|
source: common.data
|
|
container: #input: buildImage.output
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Make an assertion on the contents of a file
|
|
#AssertFile: {
|
|
input: dagger.#FS
|
|
path: string
|
|
contents: string
|
|
|
|
_read: dagger.#ReadFile & {
|
|
"input": input
|
|
"path": path
|
|
}
|
|
|
|
actual: _read.contents
|
|
|
|
// Assertion
|
|
contents: actual
|
|
}
|