Skip to content

Commit f5dc2c7

Browse files
committed
fix(e2e): retry opencode auth bootstrap
1 parent 3c50976 commit f5dc2c7

2 files changed

Lines changed: 35 additions & 5 deletions

File tree

packages/app/tests/docker-git/controller-resource-limits.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,21 @@ describe("API Dockerfile controller tooling install", () => {
121121
}))
122122
})
123123

124+
describe("OpenCode E2E auth bootstrap", () => {
125+
it.effect("retries controller auth commands before the clone scenario", () =>
126+
Effect.gen(function*(_) {
127+
const contents = yield* _(readComposeFile("scripts/e2e/opencode-autoconnect.sh"))
128+
expect(contents).toContain("auth_attempts=3")
129+
expect(contents).toContain(": > \"$AUTH_LOG\"")
130+
expect(contents).toContain("if (")
131+
expect(contents).toContain("dg_run_docker_git \"$REPO_ROOT\" auth codex import")
132+
expect(contents).toContain("dg_run_docker_git \"$REPO_ROOT\" auth codex status")
133+
expect(contents).toContain(") >>\"$AUTH_LOG\" 2>&1")
134+
expect(contents).toContain("auth bootstrap attempt $auth_attempt/$auth_attempts failed")
135+
expect(contents).toContain("docker-git auth bootstrap failed after $auth_attempts attempts")
136+
}))
137+
})
138+
124139
describe("controller resource limit resolution", () => {
125140
it.effect("resolves CPU and RAM defaults to 90% of host resources", () =>
126141
Effect.sync(() => {

scripts/e2e/opencode-autoconnect.sh

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,26 @@ OPENCODE_AUTO_CONNECT=1
124124
EOF_ENV
125125

126126
AUTH_LOG="$ROOT/codex-auth.log"
127-
(
128-
cd "$REPO_ROOT"
129-
dg_run_docker_git "$REPO_ROOT" auth codex import --codex-auth "$ROOT/.orch/auth/codex"
130-
dg_run_docker_git "$REPO_ROOT" auth codex status --codex-auth "$ROOT/.orch/auth/codex"
131-
) >"$AUTH_LOG" 2>&1
127+
auth_attempts=3
128+
auth_attempt=1
129+
auth_exit=0
130+
: > "$AUTH_LOG"
131+
while [[ "$auth_attempt" -le "$auth_attempts" ]]; do
132+
if (
133+
cd "$REPO_ROOT"
134+
dg_run_docker_git "$REPO_ROOT" auth codex import --codex-auth "$ROOT/.orch/auth/codex"
135+
dg_run_docker_git "$REPO_ROOT" auth codex status --codex-auth "$ROOT/.orch/auth/codex"
136+
) >>"$AUTH_LOG" 2>&1; then
137+
auth_exit=0
138+
break
139+
else
140+
auth_exit=$?
141+
fi
142+
echo "e2e/opencode-autoconnect: auth bootstrap attempt $auth_attempt/$auth_attempts failed (exit: $auth_exit); retrying..." >&2
143+
auth_attempt="$((auth_attempt + 1))"
144+
sleep 2
145+
done
146+
[[ "$auth_exit" -eq 0 ]] || fail "docker-git auth bootstrap failed after $auth_attempts attempts (last exit: $auth_exit)"
132147

133148
auth_confirmation_count="$(grep -Fc -- "Codex auth imported into controller state (account: ci@example.com)." "$AUTH_LOG" || true)"
134149
[[ "$auth_confirmation_count" -ge 2 ]] \

0 commit comments

Comments
 (0)