ci: use packaged tarball for docker e2e

This commit is contained in:
Peter Steinberger
2026-04-26 23:10:23 +01:00
parent 1b1eea238c
commit d108110a89
32 changed files with 432 additions and 202 deletions

View File

@@ -1,10 +1,15 @@
#!/usr/bin/env bash
#
# Shared Docker E2E image resolver/builder.
# Suite-specific scripts call this to resolve overrides, reuse pulled images, or
# build the runner/functional images with the prepared OpenClaw package tarball.
DOCKER_E2E_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="${ROOT_DIR:-$(cd "$DOCKER_E2E_LIB_DIR/../.." && pwd)}"
source "$DOCKER_E2E_LIB_DIR/docker-e2e-logs.sh"
source "$DOCKER_E2E_LIB_DIR/docker-build.sh"
source "$DOCKER_E2E_LIB_DIR/docker-e2e-package.sh"
docker_e2e_resolve_image() {
local default_image="$1"
@@ -34,6 +39,11 @@ docker_e2e_build_or_reuse() {
local context="${4:-$ROOT_DIR}"
local target="${5:-}"
local skip_build="${6:-0}"
if [ -z "$target" ] && [ "$dockerfile" = "$ROOT_DIR/scripts/e2e/Dockerfile" ]; then
# The generic E2E image defaults to the package-installed app image; tests
# that need a clean install runner pass target=bare explicitly.
target="functional"
fi
if [ "${OPENCLAW_SKIP_DOCKER_BUILD:-0}" = "1" ] || [ "$skip_build" = "1" ]; then
echo "Reusing Docker image: $image_name"
@@ -53,6 +63,15 @@ docker_e2e_build_or_reuse() {
if [ -n "$target" ]; then
build_args+=(--target "$target")
fi
if [ "$target" = "functional" ]; then
local package_tgz
local package_context
package_tgz="$(docker_e2e_prepare_package_tgz "$label")"
package_context="$(docker_e2e_prepare_package_context "$package_tgz")"
# The Dockerfile never sees repo sources as app input; functional installs
# exactly this tarball through a named BuildKit context.
build_args+=(--build-context "openclaw_package=$package_context")
fi
build_args+=(-t "$image_name" -f "$dockerfile" "$context")
docker_build_run "$label-build" "${build_args[@]}"
}

View File

@@ -0,0 +1,63 @@
#!/usr/bin/env bash
#
# Shared package helpers for Docker E2E scripts.
# Builds or resolves one OpenClaw npm tarball and exposes mount/build-context
# helpers so Docker lanes test the package artifact instead of repo sources.
DOCKER_E2E_PACKAGE_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="${ROOT_DIR:-$(cd "$DOCKER_E2E_PACKAGE_LIB_DIR/../.." && pwd)}"
if ! declare -F run_logged >/dev/null 2>&1; then
source "$DOCKER_E2E_PACKAGE_LIB_DIR/docker-e2e-logs.sh"
fi
docker_e2e_abs_path() {
local file="$1"
(cd "$(dirname "$file")" && printf '%s/%s\n' "$(pwd)" "$(basename "$file")")
}
docker_e2e_prepare_package_tgz() {
local label="$1"
local package_tgz="${2:-${OPENCLAW_CURRENT_PACKAGE_TGZ:-}}"
if [ -n "$package_tgz" ]; then
if [ ! -f "$package_tgz" ]; then
echo "OpenClaw package tarball does not exist: $package_tgz" >&2
return 1
fi
docker_e2e_abs_path "$package_tgz"
return 0
fi
echo "Building OpenClaw package artifacts..."
run_logged "$label-host-build" pnpm build
echo "Writing package inventory and packing OpenClaw once..."
run_logged "$label-inventory" node --import tsx --input-type=module -e 'const { writePackageDistInventory } = await import("./src/infra/package-dist-inventory.ts"); await writePackageDistInventory(process.cwd());'
local pack_dir
pack_dir="$(mktemp -d "${TMPDIR:-/tmp}/openclaw-docker-e2e-pack.XXXXXX")"
run_logged "$label-pack" npm pack --ignore-scripts --pack-destination "$pack_dir"
package_tgz="$(find "$pack_dir" -maxdepth 1 -name 'openclaw-*.tgz' -print -quit)"
if [ -z "$package_tgz" ]; then
echo "missing packed OpenClaw tarball" >&2
return 1
fi
docker_e2e_abs_path "$package_tgz"
}
docker_e2e_prepare_package_context() {
local package_tgz="$1"
local context_dir
context_dir="$(mktemp -d "${TMPDIR:-/tmp}/openclaw-docker-e2e-package-context.XXXXXX")"
# BuildKit named contexts must be directories, so expose the tarball as a
# stable filename inside a tiny temporary context.
cp "$package_tgz" "$context_dir/openclaw-current.tgz"
printf '%s\n' "$context_dir"
}
docker_e2e_package_mount_args() {
local package_tgz="$1"
local target="${2:-/tmp/openclaw-current.tgz}"
DOCKER_E2E_PACKAGE_ARGS=(-v "$package_tgz:$target:ro" -e "OPENCLAW_CURRENT_PACKAGE_TGZ=$target")
}