Skip to content

Commit ffdca8e

Browse files
committed
test(e2e): verify local packed docker-git CLI via pnpm
1 parent af5b7c5 commit ffdca8e

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed

.github/workflows/check.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ jobs:
8585
- name: Lint Effect-TS (lib)
8686
run: pnpm --filter ./packages/lib lint:effect
8787

88+
e2e-local-package:
89+
name: E2E (Local package CLI)
90+
runs-on: ubuntu-latest
91+
timeout-minutes: 15
92+
steps:
93+
- uses: actions/checkout@v6
94+
- name: Install dependencies
95+
uses: ./.github/actions/setup
96+
- name: Pack and run local package via pnpm
97+
run: bash scripts/e2e/local-package-cli.sh
98+
8899
e2e-opencode:
89100
name: E2E (OpenCode)
90101
runs-on: ubuntu-latest

scripts/e2e/local-package-cli.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
RUN_ID="$(date +%s)-$RANDOM"
5+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
7+
ROOT_BASE="${DOCKER_GIT_E2E_ROOT_BASE:-/tmp/docker-git-e2e-root}"
8+
mkdir -p "$ROOT_BASE"
9+
ROOT="$(mktemp -d "$ROOT_BASE/local-package-cli.XXXXXX")"
10+
KEEP="${KEEP:-0}"
11+
12+
PACK_LOG="$ROOT/npm-pack.log"
13+
HELP_LOG="$ROOT/docker-git-help.log"
14+
PACKED_TARBALL=""
15+
16+
fail() {
17+
echo "e2e/local-package-cli: $*" >&2
18+
exit 1
19+
}
20+
21+
on_error() {
22+
local line="$1"
23+
echo "e2e/local-package-cli: failed at line $line" >&2
24+
if [[ -f "$PACK_LOG" ]]; then
25+
echo "--- npm pack log ---" >&2
26+
cat "$PACK_LOG" >&2 || true
27+
fi
28+
if [[ -f "$HELP_LOG" ]]; then
29+
echo "--- docker-git --help log ---" >&2
30+
cat "$HELP_LOG" >&2 || true
31+
fi
32+
}
33+
34+
cleanup() {
35+
if [[ "$KEEP" == "1" ]]; then
36+
echo "e2e/local-package-cli: KEEP=1 set; preserving temp dir: $ROOT" >&2
37+
return
38+
fi
39+
if [[ -n "$PACKED_TARBALL" ]] && [[ -f "$PACKED_TARBALL" ]]; then
40+
rm -f "$PACKED_TARBALL" >/dev/null 2>&1 || true
41+
fi
42+
rm -rf "$ROOT" >/dev/null 2>&1 || true
43+
}
44+
45+
trap 'on_error $LINENO' ERR
46+
trap cleanup EXIT
47+
48+
cd "$REPO_ROOT/packages/app"
49+
npm pack --silent >"$PACK_LOG"
50+
tarball_name="$(tail -n 1 "$PACK_LOG" | tr -d '\r')"
51+
[[ -n "$tarball_name" ]] || fail "npm pack did not return tarball name"
52+
53+
PACKED_TARBALL="$REPO_ROOT/packages/app/$tarball_name"
54+
[[ -f "$PACKED_TARBALL" ]] || fail "packed tarball not found: $PACKED_TARBALL"
55+
56+
dep_keys="$(tar -xOf "$PACKED_TARBALL" package/package.json | node -e 'let s="";process.stdin.on("data",(c)=>{s+=c});process.stdin.on("end",()=>{const pkg=JSON.parse(s);const deps=Object.keys(pkg.dependencies ?? {});if (deps.includes("@effect-template/lib")) {console.error("@effect-template/lib must not be a runtime dependency in packed package");process.exit(1)}process.stdout.write(deps.join(","));});')"
57+
[[ "$dep_keys" == *"effect"* ]] || fail "packed dependency set looks invalid: $dep_keys"
58+
59+
mkdir -p "$ROOT/project"
60+
cd "$ROOT/project"
61+
npm init -y >/dev/null
62+
pnpm add "$PACKED_TARBALL" --silent --lockfile=false
63+
pnpm docker-git --help >"$HELP_LOG" 2>&1
64+
65+
grep -Fq -- "docker-git clone <url> [options]" "$HELP_LOG" \
66+
|| fail "expected docker-git help output from local packed package"
67+
68+
echo "e2e/local-package-cli: local tarball install + pnpm docker-git --help OK" >&2

scripts/e2e/run-all.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
55

66
cases=("$@")
77
if [[ "${#cases[@]}" -eq 0 ]]; then
8-
cases=("clone-cache" "login-context" "opencode-autoconnect")
8+
cases=("local-package-cli" "clone-cache" "login-context" "opencode-autoconnect")
99
fi
1010

1111
for case_name in "${cases[@]}"; do
@@ -20,4 +20,3 @@ for case_name in "${cases[@]}"; do
2020
done
2121

2222
echo "e2e/run-all: all cases OK" >&2
23-

0 commit comments

Comments
 (0)