update action to dagger 0.2

- Remove AGE key setup
- Update README to use `dagger do`
- Update tests to dagger 0.2

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2022-03-09 12:07:13 -08:00
parent 64f8bd95de
commit 24d6bfd692
96 changed files with 15028 additions and 70 deletions

View file

@ -0,0 +1,59 @@
// Helpers to run bash commands in containers
package bash
import (
"dagger.io/dagger"
"universe.dagger.io/docker"
)
// Run a bash script in a Docker container
// Since this is a thin wrapper over docker.#Run, we embed it.
// Whether to embed or wrap is a case-by-case decision, like in Go.
#Run: {
// The script to execute
script: {
// A directory containing one or more bash scripts
directory: dagger.#FS
// Name of the file to execute
filename: string
_directory: directory
_filename: filename
} | {
// Script contents
contents: string
_filename: "run.sh"
_write: dagger.#WriteFile & {
input: dagger.#Scratch
path: _filename
"contents": contents
}
_directory: _write.output
}
// Arguments to the script
args: [...string]
// Where in the container to mount the scripts directory
_mountpoint: "/bash/scripts"
docker.#Run & {
command: {
name: "bash"
"args": ["\(_mountpoint)/\(script._filename)"] + args
// FIXME: make default flags overrideable
flags: {
"--norc": true
"-e": true
"-o": "pipefail"
}
}
mounts: "Bash scripts": {
contents: script._directory
dest: _mountpoint
}
}
}

View file

@ -0,0 +1,3 @@
#!/bin/sh
echo Hello, world > /out.txt

View file

@ -0,0 +1,10 @@
setup() {
load '../../bats_helpers'
common_setup
}
@test "bash" {
dagger up
}

View file

@ -0,0 +1,49 @@
package bash
import (
"dagger.io/dagger"
"universe.dagger.io/docker"
"universe.dagger.io/bash"
)
dagger.#Plan & {
actions: tests: {
_pull: docker.#Pull & {
source: "index.docker.io/debian"
}
_image: _pull.output
// Run a script from source directory + filename
runFile: {
dir: _load.output
_load: dagger.#Source & {
path: "./data"
include: ["*.sh"]
}
run: bash.#Run & {
input: _image
export: files: "/out.txt": _
script: {
directory: dir
filename: "hello.sh"
}
}
output: run.export.files."/out.txt" & "Hello, world\n"
}
// Run a script from string
runString: {
run: bash.#Run & {
input: _image
export: files: "/output.txt": _
script: contents: "echo 'Hello, inlined world!' > /output.txt"
}
output: run.export.files."/output.txt" & "Hello, inlined world!\n"
}
}
}