diff --git a/examples/dagger-dev/main.cue b/examples/dagger-dev/main.cue new file mode 100644 index 00000000..0c3239d7 --- /dev/null +++ b/examples/dagger-dev/main.cue @@ -0,0 +1,46 @@ +package main + +// A dagger configuration to build and test the dagger source code. +// This configuration can easily be adapted to build and test any go project. +// +// +// Example: +// dagger compute ./examples/dagger-dev --input-dir repository=/path/to/go/project + +import ( + "dagger.io/dagger" + "dagger.io/go" + "dagger.io/docker" +) + +repository: dagger.#Dir + +// Build `dagger` using Go +build: go.#Build & { + source: repository + packages: "./cmd/dagger" + output: "/usr/local/bin/dagger" +} + +// Run go tests +test: go.#Test & { + source: repository + packages: "./..." +} + +// Run a command with the binary we just built +help: docker.#Run & { + image: build + args: ["dagger", "-h"] +} + +// Build dagger using the (included) Dockerfile +buildWithDocker: docker.#Build & { + source: repository +} + +// Run a command in the docker image we just built +helpFromDocker: docker.#Run & { + image: buildWithDocker.image + args: ["dagger", "-h"] +} diff --git a/examples/dogfood/main.cue b/examples/dogfood/main.cue deleted file mode 100644 index e87ee4ee..00000000 --- a/examples/dogfood/main.cue +++ /dev/null @@ -1,39 +0,0 @@ -package main - -import ( - "dagger.io/dagger" - "dagger.io/go" -) - -repository: dagger.#Dir // Use `--input-dir repository=.` from the root directory of the project - -// Build `dagger` using Go -build: go.#Build & { - source: repository - packages: "./cmd/dagger" - output: "/usr/local/bin/dagger" -} - -test: go.#Test & { - source: repository - packages: "./..." -} - -// Run a command with the binary we just built -help: #compute: [ - dagger.#Load & {from: build}, - dagger.#Exec & {args: ["dagger", "-h"]}, -] - -// Build dagger using the (included) Dockerfile -buildWithDocker: #compute: [ - dagger.#DockerBuild & { - context: repository - }, -] - -// Run a command in the docker image we just built -helpFromDocker: #compute: [ - dagger.#Load & {from: buildWithDocker}, - dagger.#Exec & {args: ["dagger", "-h"]}, -] diff --git a/examples/react-netlify/main.cue b/examples/react-netlify/main.cue index 0fb2c3ae..c48ced57 100644 --- a/examples/react-netlify/main.cue +++ b/examples/react-netlify/main.cue @@ -1,17 +1,15 @@ package main import ( - "dagger.io/dagger" "dagger.io/netlify" "dagger.io/yarn" + "dagger.io/git" ) -repository: #compute: [ - dagger.#FetchGit & { - remote: "https://github.com/kabirbaidhya/react-todo-app.git" - ref: "624041b17bd62292143f99bce474a0e3c2d2dd61" - }, -] +repository: git.#Repository & { + remote: "https://github.com/kabirbaidhya/react-todo-app.git" + ref: "624041b17bd62292143f99bce474a0e3c2d2dd61" +} todoApp: netlify.#Site & { account: { diff --git a/examples/simple/simple.cue b/examples/simple/simple.cue deleted file mode 100644 index 735ddefd..00000000 --- a/examples/simple/simple.cue +++ /dev/null @@ -1,68 +0,0 @@ -package simple - -import ( - "dagger.io/dagger" -) - -let alpine = { - digest: "sha256:3c7497bf0c7af93428242d6176e8f7905f2201d8fc5861f45be7a346b5f23436" - package: [string]: true | false | string - #compute: [ - { - do: "fetch-container" - ref: "index.docker.io/alpine@\(digest)" - }, - for pkg, info in package { - if (info & true) != _|_ { - do: "exec" - args: ["apk", "add", "-U", "--no-cache", pkg] - } - if (info & string) != _|_ { - do: "exec" - args: ["apk", "add", "-U", "--no-cache", "\(pkg)\(info)"] - } - }, - ] -} - -www: { - - source: dagger.#Dir - - // List the contents of the source directory - listing: { - string - - #compute: [ - dagger.#Load & { - from: alpine - }, - dagger.#Exec & { - args: ["sh", "-c", "ls /src > /tmp/out"] - mount: "/src": from: source - }, - dagger.#Export & { - source: "/tmp/out" - }, - ] - } - - host: string - - url: { - string - - #compute: [ - { - do: "load" - from: alpine - }, - dagger.#Exec & { - args: ["sh", "-c", "echo -n 'https://\(host)/foo' > /tmp/out"] - }, - dagger.#Export & { - source: "/tmp/out" - }, - ] - } -} diff --git a/tests/test.sh b/tests/test.sh index f9843843..1b15ae76 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -13,13 +13,6 @@ DAGGER_BINARY_ARGS="${DAGGER_BINARY_ARGS:---log-format json}" read -ra DAGGER_BINARY_ARGS <<< "${DAGGER_BINARY_ARGS:-}" readonly DAGGER_BINARY_ARGS -test::examples() { - local dagger="$1" - - test::one "Examples: simple" --stdout='{"www":{"listing":"simple.cue\n","source":{}}}' \ - "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-dir www.source="$d"/../examples/simple "$d"/../examples/simple -} - test::stdlib() { local dagger="$1" @@ -259,7 +252,6 @@ test::all(){ test::dockerbuild "$dagger" test::stdlib "$dagger" - test::examples "$dagger" } case "${1:-all}" in