Skip to content

Commit 0d7d99b

Browse files
authored
fix(ci): repair crabbox hydrate replay (#85706)
1 parent 4ec8576 commit 0d7d99b

4 files changed

Lines changed: 258 additions & 3 deletions

File tree

‎.crabbox.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ capacity:
1818
- us-west-2
1919
actions:
2020
workflow: .github/workflows/crabbox-hydrate.yml
21+
# Default AWS hydration uses local Actions replay. Use
22+
# `crabbox actions hydrate --github-runner --job hydrate-github` when the
23+
# hydrate job needs GitHub secrets.
2124
job: hydrate
2225
ref: main
2326
runnerLabels:

‎.github/workflows/crabbox-hydrate.yml‎

Lines changed: 227 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,232 @@ env:
4141
jobs:
4242
hydrate:
4343
name: hydrate
44+
if: ${{ inputs.crabbox_job != 'hydrate-github' }}
45+
runs-on: [self-hosted, "${{ inputs.crabbox_runner_label }}"]
46+
timeout-minutes: 120
47+
steps:
48+
- uses: actions/checkout@v6
49+
with:
50+
ref: ${{ inputs.ref || github.ref }}
51+
52+
- name: Setup Node.js
53+
uses: actions/setup-node@v6
54+
with:
55+
node-version: "24"
56+
57+
- name: Setup pnpm and dependencies
58+
shell: bash
59+
env:
60+
CI: "true"
61+
run: |
62+
set -euo pipefail
63+
64+
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$RUNNER_TEMP/cache}"
65+
export COREPACK_HOME="${COREPACK_HOME:-$XDG_CACHE_HOME/corepack}"
66+
export PNPM_HOME="${PNPM_HOME:-$RUNNER_TEMP/pnpm-home}"
67+
mkdir -p "$XDG_CACHE_HOME" "$COREPACK_HOME" "$PNPM_HOME"
68+
export PATH="$PNPM_HOME:$PATH"
69+
{
70+
echo "XDG_CACHE_HOME=$XDG_CACHE_HOME"
71+
echo "COREPACK_HOME=$COREPACK_HOME"
72+
echo "PNPM_HOME=$PNPM_HOME"
73+
} >> "$GITHUB_ENV"
74+
75+
corepack enable
76+
node_bin="$(dirname "$(node -p 'process.execPath')")"
77+
echo "NODE_BIN=$node_bin" >> "$GITHUB_ENV"
78+
echo "$node_bin" >> "$GITHUB_PATH"
79+
export PATH="$node_bin:$PATH"
80+
81+
node -v
82+
npm -v
83+
pnpm -v
84+
85+
install_args=(
86+
install
87+
--prefer-offline
88+
--ignore-scripts=false
89+
--config.engine-strict=false
90+
--config.enable-pre-post-scripts=true
91+
--config.side-effects-cache=true
92+
--frozen-lockfile
93+
)
94+
append_pnpm_option_arg() {
95+
local env_name="$1"
96+
local option_name="$2"
97+
local value="${!env_name-}"
98+
if [ -n "$value" ]; then
99+
install_args+=("--${option_name}=${value}")
100+
fi
101+
}
102+
append_pnpm_option_arg PNPM_CONFIG_CHILD_CONCURRENCY child-concurrency
103+
append_pnpm_option_arg PNPM_CONFIG_MODULES_DIR modules-dir
104+
append_pnpm_option_arg PNPM_CONFIG_NETWORK_CONCURRENCY network-concurrency
105+
append_pnpm_option_arg PNPM_CONFIG_VIRTUAL_STORE_DIR virtual-store-dir
106+
if [ -n "${PNPM_CONFIG_MODULES_DIR:-}" ]; then
107+
mkdir -p "$PNPM_CONFIG_MODULES_DIR"
108+
ln -sfn . "$PNPM_CONFIG_MODULES_DIR/node_modules"
109+
fi
110+
pnpm "${install_args[@]}" || pnpm "${install_args[@]}"
111+
if [ -n "${PNPM_CONFIG_MODULES_DIR:-}" ]; then
112+
rm -rf node_modules
113+
ln -sfn "$PNPM_CONFIG_MODULES_DIR" node_modules
114+
ln -sfn . "$PNPM_CONFIG_MODULES_DIR/node_modules"
115+
fi
116+
117+
- name: Prepare Crabbox shell
118+
shell: bash
119+
run: |
120+
set -euo pipefail
121+
122+
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
123+
git fetch --no-tags --depth=50 origin "+refs/heads/main:refs/remotes/origin/main"
124+
fi
125+
126+
node_bin="$(dirname "$(node -p 'process.execPath')")"
127+
sudo ln -sf "$node_bin/node" /usr/local/bin/node
128+
sudo ln -sf "$node_bin/npm" /usr/local/bin/npm
129+
sudo ln -sf "$node_bin/npx" /usr/local/bin/npx
130+
sudo ln -sf "$node_bin/corepack" /usr/local/bin/corepack
131+
sudo tee /usr/local/bin/pnpm >/dev/null <<'PNPM'
132+
#!/usr/bin/env bash
133+
exec /usr/local/bin/corepack pnpm "$@"
134+
PNPM
135+
sudo chmod 0755 /usr/local/bin/pnpm
136+
137+
- name: Ensure Docker is running
138+
shell: bash
139+
run: |
140+
set -euo pipefail
141+
142+
if ! command -v docker >/dev/null 2>&1; then
143+
echo "docker not found; installing fallback engine"
144+
curl -fsSL https://get.docker.com | sudo sh
145+
fi
146+
147+
if command -v systemctl >/dev/null 2>&1; then
148+
sudo systemctl start docker || true
149+
elif command -v service >/dev/null 2>&1; then
150+
sudo service docker start || true
151+
fi
152+
153+
if [ -S /var/run/docker.sock ]; then
154+
sudo usermod -aG docker "$USER" || true
155+
# The runner process keeps its original groups; grant this
156+
# ephemeral runner session access without requiring a relogin.
157+
sudo chmod 666 /var/run/docker.sock
158+
fi
159+
160+
if ! docker buildx version >/dev/null 2>&1; then
161+
arch="$(uname -m)"
162+
case "$arch" in
163+
aarch64|arm64) buildx_arch=arm64 ;;
164+
x86_64|amd64) buildx_arch=amd64 ;;
165+
*) echo "unsupported buildx arch: $arch" >&2; exit 2 ;;
166+
esac
167+
buildx_version="${DOCKER_BUILDX_VERSION:-v0.15.1}"
168+
mkdir -p "$HOME/.docker/cli-plugins"
169+
curl -fsSL \
170+
"https://github.com/docker/buildx/releases/download/${buildx_version}/buildx-${buildx_version}.linux-${buildx_arch}" \
171+
-o "$HOME/.docker/cli-plugins/docker-buildx"
172+
chmod 0755 "$HOME/.docker/cli-plugins/docker-buildx"
173+
fi
174+
175+
docker version
176+
docker buildx version
177+
docker compose version || true
178+
179+
- name: Ensure SSH is available
180+
shell: bash
181+
run: |
182+
set -euo pipefail
183+
if command -v systemctl >/dev/null 2>&1; then
184+
sudo systemctl start ssh || sudo systemctl start sshd || true
185+
elif command -v service >/dev/null 2>&1; then
186+
sudo service ssh start || sudo service sshd start || true
187+
fi
188+
189+
- name: Hydrate provider env helper
190+
shell: bash
191+
run: bash scripts/ci-hydrate-testbox-env.sh
192+
193+
- name: Mark Crabbox ready
194+
shell: bash
195+
env:
196+
CRABBOX_ID: ${{ inputs.crabbox_id }}
197+
CRABBOX_JOB: ${{ inputs.crabbox_job }}
198+
run: |
199+
set -euo pipefail
200+
job="${CRABBOX_JOB}"
201+
if [ -z "$job" ]; then job=hydrate; fi
202+
case "$CRABBOX_ID" in
203+
''|*[!A-Za-z0-9._-]*)
204+
echo "Invalid crabbox_id" >&2
205+
exit 2
206+
;;
207+
esac
208+
mkdir -p "$HOME/.crabbox/actions"
209+
state="$HOME/.crabbox/actions/${CRABBOX_ID}.env"
210+
env_file="$HOME/.crabbox/actions/${CRABBOX_ID}.env.sh"
211+
services_file="$HOME/.crabbox/actions/${CRABBOX_ID}.services"
212+
write_export() {
213+
key="$1"
214+
value="${!key-}"
215+
if [ -n "$value" ]; then
216+
printf 'export %s=%q\n' "$key" "$value"
217+
fi
218+
}
219+
{
220+
for key in CI GITHUB_ACTIONS GITHUB_WORKSPACE GITHUB_REPOSITORY GITHUB_RUN_ID GITHUB_RUN_NUMBER GITHUB_RUN_ATTEMPT GITHUB_REF GITHUB_REF_NAME GITHUB_SHA GITHUB_EVENT_NAME GITHUB_ACTOR RUNNER_OS RUNNER_ARCH RUNNER_TEMP RUNNER_TOOL_CACHE XDG_CACHE_HOME COREPACK_HOME PNPM_HOME PNPM_CONFIG_CHILD_CONCURRENCY PNPM_CONFIG_MODULES_DIR PNPM_CONFIG_NETWORK_CONCURRENCY PNPM_CONFIG_STORE_DIR PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN PNPM_CONFIG_VIRTUAL_STORE_DIR; do
221+
write_export "$key"
222+
done
223+
} > "${env_file}.tmp"
224+
mv "${env_file}.tmp" "$env_file"
225+
{
226+
echo "# Docker containers visible from the hydrated runner"
227+
docker ps --format '{{.Names}}\t{{.Image}}\t{{.Ports}}' 2>/dev/null || true
228+
} > "${services_file}.tmp"
229+
mv "${services_file}.tmp" "$services_file"
230+
tmp="${state}.tmp"
231+
{
232+
echo "WORKSPACE=${GITHUB_WORKSPACE}"
233+
echo "RUN_ID=${GITHUB_RUN_ID}"
234+
echo "JOB=${job}"
235+
echo "ENV_FILE=${env_file}"
236+
echo "SERVICES_FILE=${services_file}"
237+
echo "READY_AT=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
238+
} > "$tmp"
239+
mv "$tmp" "$state"
240+
241+
- name: Keep Crabbox job alive
242+
shell: bash
243+
env:
244+
CRABBOX_ID: ${{ inputs.crabbox_id }}
245+
CRABBOX_KEEP_ALIVE_MINUTES: ${{ inputs.crabbox_keep_alive_minutes }}
246+
run: |
247+
set -euo pipefail
248+
case "$CRABBOX_ID" in
249+
''|*[!A-Za-z0-9._-]*)
250+
echo "Invalid crabbox_id" >&2
251+
exit 2
252+
;;
253+
esac
254+
minutes="${CRABBOX_KEEP_ALIVE_MINUTES}"
255+
case "$minutes" in
256+
''|*[!0-9]*) minutes=90 ;;
257+
esac
258+
stop="$HOME/.crabbox/actions/${CRABBOX_ID}.stop"
259+
deadline=$(( $(date +%s) + minutes * 60 ))
260+
while [ "$(date +%s)" -lt "$deadline" ]; do
261+
if [ -f "$stop" ]; then
262+
exit 0
263+
fi
264+
sleep 15
265+
done
266+
267+
hydrate-github:
268+
name: hydrate-github
269+
if: ${{ inputs.crabbox_job == 'hydrate-github' }}
44270
runs-on: [self-hosted, "${{ inputs.crabbox_runner_label }}"]
45271
timeout-minutes: 120
46272
steps:
@@ -161,7 +387,7 @@ jobs:
161387
run: |
162388
set -euo pipefail
163389
job="${CRABBOX_JOB}"
164-
if [ -z "$job" ]; then job=hydrate; fi
390+
if [ -z "$job" ]; then job=hydrate-github; fi
165391
case "$CRABBOX_ID" in
166392
''|*[!A-Za-z0-9._-]*)
167393
echo "Invalid crabbox_id" >&2

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Docs: https://docs.openclaw.ai
5959
- Providers/Anthropic: migrate 1M context handling to GA-capable Claude 4.x models by sizing eligible models at 1M without the retired `context-1m-2025-08-07` beta, ignoring that retired beta in older configs, and preserving OAuth-required Anthropic beta headers. (#45613) Thanks @haoyu-haoyu.
6060
- Twitch: keep stale message-handler cleanup callbacks from removing newer handler registrations for the same account, preserving inbound message delivery after reconnects. Fixes #83888. (#85425) Thanks @alkor2000.
6161
- Memory/LanceDB: expose public memory artifacts through the active memory provider bridge so memory-wiki imports durable memory files, daily notes, dream reports, and event logs without depending on memory-core internals. Fixes #83604. (#85060) Thanks @brokemac79.
62+
- Crabbox: keep AWS hydration compatible with local Actions replay by inlining the hydrate workflow's Node/pnpm setup instead of invoking repo-local composite actions.
6263
- Docker setup: stop printing the Gateway bearer token in setup logs and printed follow-up commands.
6364
- Agents: let embedded compaction fallback retries proceed when PI-compatible candidates do not need agent harness plugin preparation.
6465
- Agents/tools: honor configured custom provider API keys when deciding whether media, image-generation, video-generation, music-generation, and PDF tools are available. (#85570)

‎test/scripts/package-acceptance-workflow.test.ts‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const QA_LIVE_TRANSPORTS_WORKFLOW = ".github/workflows/qa-live-transports-convex
1515
const UPDATE_MIGRATION_WORKFLOW = ".github/workflows/update-migration.yml";
1616
const CI_CHECK_TESTBOX_WORKFLOW = ".github/workflows/ci-check-testbox.yml";
1717
const CRABBOX_HYDRATE_WORKFLOW = ".github/workflows/crabbox-hydrate.yml";
18+
const CRABBOX_CONFIG = ".crabbox.yaml";
1819
const SCHEDULED_LIVE_CHECKS_WORKFLOW = ".github/workflows/openclaw-scheduled-live-checks.yml";
1920
const CI_HYDRATE_LIVE_AUTH_SCRIPT = "scripts/ci-hydrate-live-auth.sh";
2021
const UPGRADE_SURVIVOR_RUN_SCRIPT = "scripts/e2e/lib/upgrade-survivor/run.sh";
@@ -105,6 +106,32 @@ describe("package acceptance workflow", () => {
105106
}
106107
});
107108

109+
it("keeps Crabbox hydration compatible with local Actions replay", () => {
110+
const crabboxConfig = parse(readFileSync(CRABBOX_CONFIG, "utf8")) as {
111+
actions?: { job?: string };
112+
};
113+
const workflow = readWorkflow(CRABBOX_HYDRATE_WORKFLOW);
114+
const hydrate = workflowJob(CRABBOX_HYDRATE_WORKFLOW, "hydrate");
115+
const hydrateGithub = workflowJob(CRABBOX_HYDRATE_WORKFLOW, "hydrate-github");
116+
117+
expect(crabboxConfig.actions?.job).toBe("hydrate");
118+
expect(hydrate.if).toBe("${{ inputs.crabbox_job != 'hydrate-github' }}");
119+
expect(workflowStep(hydrate, "Setup Node.js").uses).toBe("actions/setup-node@v6");
120+
expect(workflowStep(hydrate, "Setup Node.js").with?.["node-version"]).toBe("24");
121+
expect(workflowStep(hydrate, "Setup pnpm and dependencies").run).toContain("corepack enable");
122+
expect(workflowStep(hydrate, "Setup pnpm and dependencies").run).toContain("COREPACK_HOME");
123+
expect(workflowStep(hydrate, "Mark Crabbox ready").run).toContain("COREPACK_HOME");
124+
expect(workflowStep(hydrate, "Hydrate provider env helper").env).toBeUndefined();
125+
126+
expect(hydrateGithub.if).toBe("${{ inputs.crabbox_job == 'hydrate-github' }}");
127+
expect(workflowStep(hydrateGithub, "Setup Node environment").uses).toBe(
128+
"./.github/actions/setup-node-env",
129+
);
130+
expect(workflowStep(hydrateGithub, "Hydrate provider env helper").env?.FACTORY_API_KEY).toBe(
131+
"${{ secrets.FACTORY_API_KEY }}",
132+
);
133+
});
134+
108135
it("resolves candidate package sources before reusing Docker E2E lanes", () => {
109136
const workflow = readFileSync(PACKAGE_ACCEPTANCE_WORKFLOW, "utf8");
110137

@@ -639,7 +666,6 @@ describe("package artifact reuse", () => {
639666
const scheduledWorkflow = readFileSync(SCHEDULED_LIVE_CHECKS_WORKFLOW, "utf8");
640667
const packageAcceptanceWorkflow = readFileSync(PACKAGE_ACCEPTANCE_WORKFLOW, "utf8");
641668
const testboxWorkflow = readFileSync(CI_CHECK_TESTBOX_WORKFLOW, "utf8");
642-
const crabboxHydrateWorkflow = readFileSync(CRABBOX_HYDRATE_WORKFLOW, "utf8");
643669
const dockerPlanAction = readFileSync(DOCKER_E2E_PLAN_ACTION, "utf8");
644670
const hydrateScript = readFileSync(CI_HYDRATE_LIVE_AUTH_SCRIPT, "utf8");
645671

@@ -665,7 +691,6 @@ describe("package artifact reuse", () => {
665691
scheduledWorkflow,
666692
packageAcceptanceWorkflow,
667693
testboxWorkflow,
668-
crabboxHydrateWorkflow,
669694
]) {
670695
expect(workflow).toContain("FACTORY_API_KEY: ${{ secrets.FACTORY_API_KEY }}");
671696
}

0 commit comments

Comments
 (0)