Merge pull request #1479 from aluzzardi/yarn-test-cleanup

test: clean up yarn test
This commit is contained in:
Andrea Luzzardi 2022-01-21 16:52:44 -08:00 committed by GitHub
commit a6330f8167
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 29 deletions

View File

@ -8,6 +8,12 @@ import (
// This may safely be called from any package // This may safely be called from any package
#Source: engine.#Source #Source: engine.#Source
// A (best effort) persistent cache dir
#CacheDir: engine.#CacheDir
// A temporary directory for command execution
#TempDir: engine.#TempDir
// Select a subdirectory from a filesystem tree // Select a subdirectory from a filesystem tree
#Subdir: { #Subdir: {
// Input tree // Input tree

View File

@ -2,11 +2,9 @@ package yarn
import ( import (
"dagger.io/dagger" "dagger.io/dagger"
"dagger.io/dagger/engine"
"universe.dagger.io/yarn" "universe.dagger.io/yarn"
// "universe.dagger.io/alpine" "universe.dagger.io/alpine"
// "universe.dagger.io/bash" "universe.dagger.io/bash"
) )
dagger.#Plan & { dagger.#Plan & {
@ -16,34 +14,28 @@ dagger.#Plan & {
} }
actions: { actions: {
TestReact: { cache: dagger.#CacheDir & {
cache: engine.#CacheDir & { id: "yarn cache"
id: "yarn cache" }
}
pkg: yarn.#Build & { pkg: yarn.#Build & {
source: inputs.directories.testdata.contents source: inputs.directories.testdata.contents
"cache": cache "cache": cache
} }
_image: engine.#Pull & { _image: alpine.#Build & {
source: "alpine:3.15.0@sha256:e7d88de73db3d3fd9b2d63aa7f447a10fd0220b7cbf39803c803f2af9ba256b3" packages: bash: {}
} }
// FIXME: use bash.#Script test: bash.#Run & {
test: engine.#Exec & { image: _image.output
input: _image.output mounts: build: {
mounts: build: { dest: "/build"
dest: "/build" contents: pkg.output
contents: pkg.output
}
args: [
"sh", "-c",
#"""
test "$(cat /build/test)" = "output"
"""#,
]
} }
script: #"""
test "$(cat /build/test)" = "output"
"""#
} }
// FIXME: re-enable? // FIXME: re-enable?

View File

@ -190,7 +190,12 @@ func (t *execTask) mountTmp(_ *plancontext.Context, dest string, _ *compiler.Val
func (t *execTask) mountCache(_ *plancontext.Context, dest string, mnt *compiler.Value) (llb.RunOption, error) { func (t *execTask) mountCache(_ *plancontext.Context, dest string, mnt *compiler.Value) (llb.RunOption, error) {
contents := mnt.Lookup("contents") contents := mnt.Lookup("contents")
id, err := contents.Lookup("id").String()
idValue := contents.Lookup("id")
if !idValue.IsConcrete() {
return nil, fmt.Errorf("cache %q is not set", mnt.Path().String())
}
id, err := idValue.String()
if err != nil { if err != nil {
return nil, err return nil, err
} }