Merge pull request #1613 from shykes/yarn-image

yarn: enable image customization
This commit is contained in:
Solomon Hykes 2022-02-13 13:20:57 -08:00 committed by GitHub
commit eee71d0382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import (
"dagger.io/dagger" "dagger.io/dagger"
"dagger.io/dagger/engine" "dagger.io/dagger/engine"
"universe.dagger.io/docker"
"universe.dagger.io/yarn" "universe.dagger.io/yarn"
) )
@ -15,10 +16,15 @@ dagger.#Plan & {
actions: tests: { actions: tests: {
// Configuration for all tests
common: {
data: inputs.directories.testdata.contents
}
// Run yarn.#Build // Run yarn.#Build
simple: { simple: {
build: yarn.#Build & { build: yarn.#Build & {
source: inputs.directories.testdata.contents source: common.data
} }
verify: #AssertFile & { verify: #AssertFile & {
@ -32,7 +38,7 @@ dagger.#Plan & {
customName: { customName: {
build: yarn.#Build & { build: yarn.#Build & {
name: "My Build" name: "My Build"
source: inputs.directories.testdata.contents source: common.data
} }
verify: #AssertFile & { verify: #AssertFile & {
input: build.output input: build.output
@ -40,6 +46,30 @@ dagger.#Plan & {
contents: "output\n" 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
}
}
} }
} }

View File

@ -9,6 +9,7 @@ import (
"universe.dagger.io/alpine" "universe.dagger.io/alpine"
"universe.dagger.io/bash" "universe.dagger.io/bash"
"universe.dagger.io/docker"
) )
// Build a Yarn package // Build a Yarn package
@ -59,7 +60,7 @@ import (
// Run yarn in a docker container // Run yarn in a docker container
container: bash.#Run & { container: bash.#Run & {
input: _buildImage.output input: *_buildImage.output | docker.#Image
// FIXME: move shell script to its own file // FIXME: move shell script to its own file
script: contents: #""" script: contents: #"""