|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | |
3 | | -parallels_package_current_build_commit() { |
4 | | - node scripts/e2e/lib/parallels-package/build-info-commit.mjs |
5 | | -} |
6 | | - |
7 | 3 | parallels_package_acquire_build_lock() { |
8 | 4 | local lock_dir="$1" |
9 | 5 | local owner_pid="" |
@@ -27,142 +23,3 @@ parallels_package_release_build_lock() {
|
27 | 23 | rm -rf "$lock_dir" |
28 | 24 | fi |
29 | 25 | } |
30 | | - |
31 | | -parallels_package_run_with_build_lock() { |
32 | | -local lock_dir="$1" |
33 | | -local rc |
34 | | -shift |
35 | | - parallels_package_acquire_build_lock "$lock_dir" |
36 | | -set +e |
37 | | -"$@" |
38 | | - rc=$? |
39 | | -set -e |
40 | | - parallels_package_release_build_lock "$lock_dir" |
41 | | -return "$rc" |
42 | | -} |
43 | | - |
44 | | -parallels_package_write_dist_inventory() { |
45 | | - node --import tsx --input-type=module --eval \ |
46 | | -'import { writePackageDistInventory } from "./src/infra/package-dist-inventory.ts"; await writePackageDistInventory(process.cwd());' |
47 | | -} |
48 | | - |
49 | | -parallels_package_assert_no_generated_drift() { |
50 | | -local drift |
51 | | - drift="$(git status --porcelain -- ':(glob)extensions/*/src/host/**/.bundle.hash' 2>/dev/null || true)" |
52 | | -if [[ -z "$drift" ]]; then |
53 | | -return 0 |
54 | | -fi |
55 | | -printf 'error: generated file drift after build; commit or revert before Parallels packaging:\n%s\n' "$drift" >&2 |
56 | | -return 1 |
57 | | -} |
58 | | - |
59 | | -parallels_log_progress_extract() { |
60 | | -local _python_bin="$1" |
61 | | -local log_path="$2" |
62 | | - node scripts/e2e/lib/parallels-package/log-progress-extract.mjs "$log_path" |
63 | | -} |
64 | | - |
65 | | -parallels_bash_seed_workspace_snippet() { |
66 | | -local purpose="$1" |
67 | | - cat <<EOF |
68 | | -workspace="\${OPENCLAW_WORKSPACE_DIR:-\$HOME/.openclaw/workspace}" |
69 | | -mkdir -p "\$workspace/.openclaw" |
70 | | -cat > "\$workspace/IDENTITY.md" <<'IDENTITY_EOF' |
71 | | -# Identity |
72 | | - |
73 | | -- Name: OpenClaw |
74 | | -- Purpose: $purpose |
75 | | -IDENTITY_EOF |
76 | | -cat > "\$workspace/.openclaw/workspace-state.json" <<'STATE_EOF' |
77 | | -{ |
78 | | - "version": 1, |
79 | | - "setupCompletedAt": "2026-01-01T00:00:00.000Z" |
80 | | -} |
81 | | -STATE_EOF |
82 | | -rm -f "\$workspace/BOOTSTRAP.md" |
83 | | -EOF |
84 | | -} |
85 | | - |
86 | | -parallels_powershell_seed_workspace_snippet() { |
87 | | -local purpose="$1" |
88 | | - cat <<EOF |
89 | | -\$workspace = \$env:OPENCLAW_WORKSPACE_DIR |
90 | | -if (-not \$workspace) { |
91 | | - \$workspace = Join-Path \$env:USERPROFILE '.openclaw\\workspace' |
92 | | -} |
93 | | -\$stateDir = Join-Path \$workspace '.openclaw' |
94 | | -New-Item -ItemType Directory -Path \$stateDir -Force | Out-Null |
95 | | -@' |
96 | | -# Identity |
97 | | - |
98 | | -- Name: OpenClaw |
99 | | -- Purpose: $purpose |
100 | | -'@ | Set-Content -Path (Join-Path \$workspace 'IDENTITY.md') -Encoding UTF8 |
101 | | -@' |
102 | | -{ |
103 | | - "version": 1, |
104 | | - "setupCompletedAt": "2026-01-01T00:00:00.000Z" |
105 | | -} |
106 | | -'@ | Set-Content -Path (Join-Path \$stateDir 'workspace-state.json') -Encoding UTF8 |
107 | | -Remove-Item (Join-Path \$workspace 'BOOTSTRAP.md') -Force -ErrorAction SilentlyContinue |
108 | | -EOF |
109 | | -} |
110 | | - |
111 | | -parallels_child_job_running() { |
112 | | -local target="$1" |
113 | | -local owner="${2:-}" |
114 | | -local ppid |
115 | | -kill -0 "$target" >/dev/null 2>&1 || return 1 |
116 | | -if [[ -z "$owner" ]]; then |
117 | | -return 0 |
118 | | -fi |
119 | | - ppid="$(ps -o ppid= -p "$target" 2>/dev/null | tr -d '[:space:]')" |
120 | | - [[ "$ppid" == "$owner" ]] |
121 | | -} |
122 | | - |
123 | | -parallels_monitor_jobs_progress() { |
124 | | -local group="$1" |
125 | | -local interval_s="$2" |
126 | | -local stale_s="$3" |
127 | | -local python_bin="$4" |
128 | | -local owner_pid="$5" |
129 | | -shift 5 |
130 | | - |
131 | | -local labels=() |
132 | | -local pids=() |
133 | | -local logs=() |
134 | | -local last_progress=() |
135 | | -local last_print=() |
136 | | -local i summary now running |
137 | | - |
138 | | -while [[ $# -gt 0 ]]; do |
139 | | - labels+=("$1") |
140 | | - pids+=("$2") |
141 | | - logs+=("$3") |
142 | | - last_progress+=("") |
143 | | - last_print+=(0) |
144 | | -shift 3 |
145 | | -done |
146 | | - |
147 | | -printf '==> %s progress; run dir: %s\n' "$group" "${RUN_DIR:-unknown}" |
148 | | - |
149 | | -while :; do |
150 | | - running=0 |
151 | | - now=$SECONDS |
152 | | -for ((i = 0; i < ${#pids[@]}; i++)); do |
153 | | -if ! parallels_child_job_running "${pids[$i]}" "$owner_pid"; then |
154 | | -continue |
155 | | -fi |
156 | | - running=1 |
157 | | - summary="$(parallels_log_progress_extract "$python_bin" "${logs[$i]}")" |
158 | | - [[ -n "$summary" ]] || summary="waiting for first log line" |
159 | | -if [[ "${last_progress[i]}" != "$summary" ]] || (( now - last_print[i] >= stale_s )); then |
160 | | -printf '==> %s %s: %s\n' "$group" "${labels[$i]}" "$summary" |
161 | | - last_progress[i]="$summary" |
162 | | - last_print[i]=$now |
163 | | -fi |
164 | | -done |
165 | | -(( running )) || break |
166 | | - sleep "$interval_s" |
167 | | -done |
168 | | -} |