mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:20:43 +00:00
ci: use packaged tarball for docker e2e
This commit is contained in:
63
scripts/lib/docker-e2e-package.sh
Normal file
63
scripts/lib/docker-e2e-package.sh
Normal 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")
|
||||
}
|
||||
Reference in New Issue
Block a user