tests: Basic test infrastructure for Europa Universe
- Each package can include its own bats file (e.g. `universe.dagger.io/yarn/test/yarn.bats`) - universe.dagger.io includes a common bash helper file - bats is installed/launched through yarn with minimal setup - shellcheck is done across the entire repo - Integrated into our CI Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
2
pkg/universe.dagger.io/.gitignore
vendored
Normal file
2
pkg/universe.dagger.io/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
report.xml
|
25
pkg/universe.dagger.io/bats_helpers.bash
Normal file
25
pkg/universe.dagger.io/bats_helpers.bash
Normal file
@@ -0,0 +1,25 @@
|
||||
common_setup() {
|
||||
load "$(dirname "${BASH_SOURCE[0]}")/node_modules/bats-support/load.bash"
|
||||
load "$(dirname "${BASH_SOURCE[0]}")/node_modules/bats-assert/load.bash"
|
||||
|
||||
# Dagger Binary
|
||||
# FIXME: `command -v` must be wrapped in a sub-bash,
|
||||
# otherwise infinite recursion when DAGGER_BINARY is not set.
|
||||
export DAGGER="${DAGGER_BINARY:-$(bash -c 'command -v dagger')}"
|
||||
|
||||
# Force Europa mode
|
||||
DAGGER_EUROPA="1"
|
||||
export DAGGER_EUROPA
|
||||
|
||||
# Force plain printing for error reporting
|
||||
DAGGER_LOG_FORMAT="plain"
|
||||
export DAGGER_LOG_FORMAT
|
||||
|
||||
# cd into the directory containing the bats file
|
||||
cd "$BATS_TEST_DIRNAME" || exit 1
|
||||
}
|
||||
|
||||
# dagger helper to execute the right binary
|
||||
dagger() {
|
||||
"${DAGGER}" "$@"
|
||||
}
|
@@ -1 +0,0 @@
|
||||
../../../dagger.io
|
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
find . -name '*.cue' -exec cue fmt -s {} \;
|
11
pkg/universe.dagger.io/package.json
Normal file
11
pkg/universe.dagger.io/package.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"license": "Apache-2.0",
|
||||
"scripts": {
|
||||
"test": "bats --report-formatter junit --jobs 4 $(find . -type f -name '*.bats' -not -path '*/node_modules/*')"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bats": "^1.5.0",
|
||||
"bats-assert": "^2.0.0",
|
||||
"bats-support": "^0.3.0"
|
||||
}
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
find . -name '*.cue' -exec grep -H "$1" {} \;
|
@@ -1,33 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
targets=(
|
||||
dagger.io/dagger
|
||||
dagger.io/dagger/engine
|
||||
|
||||
./docker
|
||||
./docker/test/build
|
||||
|
||||
./alpine
|
||||
./alpine/tests/simple
|
||||
|
||||
./yarn
|
||||
./yarn/tests/simple
|
||||
|
||||
./bash
|
||||
./python
|
||||
./git
|
||||
./nginx
|
||||
./netlify
|
||||
./netlify/test/simple
|
||||
|
||||
./examples/todoapp
|
||||
./examples/todoapp/dev
|
||||
./examples/todoapp/staging
|
||||
)
|
||||
|
||||
for t in "${targets[@]}"; do
|
||||
echo "-- $t"
|
||||
cue eval "$t" >/dev/null
|
||||
done
|
18
pkg/universe.dagger.io/yarn.lock
Normal file
18
pkg/universe.dagger.io/yarn.lock
Normal file
@@ -0,0 +1,18 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
bats-assert@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/bats-assert/-/bats-assert-2.0.0.tgz#ba1b4eeee2c7848f1a25948b623790dd41a2b94b"
|
||||
integrity sha512-qO3kNilWxW8iCONu9NDUfvsCiC6JzL6DPOc/DGq9z3bZ9/A7wURJ+FnFMxGbofOmWbCoy7pVhofn0o47A95qkQ==
|
||||
|
||||
bats-support@^0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/bats-support/-/bats-support-0.3.0.tgz#a1f6b8878d2a51837911fdffa0750036f60701ef"
|
||||
integrity sha512-z+2WzXbI4OZgLnynydqH8GpI3+DcOtepO66PlK47SfEzTkiuV9hxn9eIQX+uLVFbt2Oqoc7Ky3TJ/N83lqD+cg==
|
||||
|
||||
bats@^1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/bats/-/bats-1.5.0.tgz#683f522e89df7d8fc99bf3631d35501f35445166"
|
||||
integrity sha512-83YgQw24Yi2c1ctB0Vd7WCsACUMSWuEtOboxQZyFQYfiv9hDMW7nk7bdloqGLg3vK5pOODCBGBQjhvRmHKsJuA==
|
9
pkg/universe.dagger.io/yarn/test/yarn.bats
Normal file
9
pkg/universe.dagger.io/yarn/test/yarn.bats
Normal file
@@ -0,0 +1,9 @@
|
||||
setup() {
|
||||
load '../../bats_helpers'
|
||||
|
||||
common_setup
|
||||
}
|
||||
|
||||
@test "yarn.#Build" {
|
||||
dagger up ./yarn-test.cue
|
||||
}
|
Reference in New Issue
Block a user