Files
self f7e147b8be
CI / Test (push) Failing after 24s
feat: gate Kobold datasets with access policies
Make Kobold require Trust, declare editable dataset/feature permissions, and enforce generic access rules for remote dataset reads and writes.\n\nUpdate the Docker e2e harness to include Trust and verify handshake-backed public access plus explicit private read/write grants.
2026-05-28 21:30:24 +02:00

112 lines
3.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
HOST_ROOT="${TRIBES_HOST_ROOT:-$ROOT_DIR/../tribes}"
HOST_ROOT="$(cd "$HOST_ROOT" && pwd -P)"
TRUST_ROOT="${TRIBES_TRUST_ROOT:-$ROOT_DIR/../tribes-plugin-trust}"
TRUST_ROOT="$(cd "$TRUST_ROOT" && pwd -P)"
COMPOSE_FILE="$ROOT_DIR/test/e2e/compose.kobold.yaml"
PROJECT="kobold-e2e-$(date +%s)"
IMAGE_LINK="$ROOT_DIR/.kobold-e2e-image"
HOST_SOURCE_TMP=""
TRUST_SOURCE_TMP=""
export COMPOSE_PROJECT_NAME="$PROJECT"
export E2E_COMPOSE_FILE="$COMPOSE_FILE"
export KOBOLD_PLUGIN_ROOT="$ROOT_DIR"
export TRIBES_HOST_ROOT="$HOST_ROOT"
export TRIBES_TRUST_ROOT="$TRUST_ROOT"
export TRIBES_KOBOLD_IMAGE="${TRIBES_KOBOLD_IMAGE:-tribes-kobold-e2e:latest}"
cleanup() {
if [[ "${TRIBES_E2E_KEEP_RUNNING:-0}" == "1" ]]; then
echo "==> keeping kobold e2e compose stack running"
else
docker compose -f "$COMPOSE_FILE" down -v || true
fi
if [[ -n "$HOST_SOURCE_TMP" ]]; then
rm -rf "$HOST_SOURCE_TMP"
fi
if [[ -n "$TRUST_SOURCE_TMP" ]]; then
rm -rf "$TRUST_SOURCE_TMP"
fi
}
trap cleanup EXIT
command -v docker >/dev/null 2>&1 || {
echo "docker is required for kobold e2e" >&2
exit 1
}
copy_filtered_source() {
local from="$1"
local to="$2"
tar -C "$from" \
--exclude=.git \
--exclude=.devenv \
--exclude=.direnv \
--exclude=_build \
--exclude=deps \
--exclude=node_modules \
--exclude=result \
--exclude='result-*' \
-cf - . | tar -C "$to" -xf -
}
if [[ "${SKIP_BUILD:-0}" != "1" ]]; then
echo "==> preparing filtered Tribes host source"
HOST_SOURCE_TMP="$(mktemp -d -t kobold-tribes-host.XXXXXX)"
copy_filtered_source "$HOST_ROOT" "$HOST_SOURCE_TMP"
echo "==> preparing filtered Trust plugin source"
TRUST_SOURCE_TMP="$(mktemp -d -t kobold-trust-plugin.XXXXXX)"
copy_filtered_source "$TRUST_ROOT" "$TRUST_SOURCE_TMP"
echo "==> building kobold e2e image"
image_path="$(
nix build --impure "$ROOT_DIR#koboldDockerE2E" \
--override-input tribes "path:$HOST_SOURCE_TMP" \
--override-input trust "path:$TRUST_SOURCE_TMP" \
--no-write-lock-file \
--out-link "$IMAGE_LINK" \
--print-out-paths \
--no-link
)"
echo "==> loading image tarball: $image_path"
docker image rm "$TRIBES_KOBOLD_IMAGE" >/dev/null 2>&1 || true
docker load < "$image_path"
else
echo "==> skipping image build (SKIP_BUILD=1)"
fi
echo "==> starting kobold e2e databases"
docker compose -f "$COMPOSE_FILE" up -d db-origin db-edge
echo "==> migrating kobold e2e databases"
docker compose -f "$COMPOSE_FILE" run --rm migrate-origin
docker compose -f "$COMPOSE_FILE" run --rm migrate-edge
echo "==> starting kobold e2e nodes"
docker compose -f "$COMPOSE_FILE" up -d kobold-origin kobold-edge
echo "==> running kobold e2e assertions"
set +e
mix run --no-start "$ROOT_DIR/scripts/kobold_e2e_runner.exs"
E2E_STATUS=$?
set -e
if [[ "$E2E_STATUS" -ne 0 ]]; then
echo "kobold docker e2e failed (exit $E2E_STATUS)"
docker compose -f "$COMPOSE_FILE" ps -a || true
docker compose -f "$COMPOSE_FILE" logs kobold-origin kobold-edge --tail=300 || true
exit "$E2E_STATUS"
fi
echo "kobold docker e2e passed"