Skip to content

Commit c6f92d5

Browse files
jyaunchesclaude
andcommitted
feat(ci): add keep_alive option to preserve Brev instance for debugging
Default to keep_alive=true so the instance stays up after tests. PR comment includes SSH instructions and instance name when alive. Vitest afterAll skips deletion when KEEP_ALIVE=true. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 62205c5 commit c6f92d5

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

.github/workflows/e2e-brev.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ on:
2323
- full
2424
- credential-sanitization
2525
- all
26+
keep_alive:
27+
description: "Keep Brev instance alive after tests (for SSH debugging)"
28+
required: false
29+
type: boolean
30+
default: true
2631
workflow_call:
2732
inputs:
2833
branch:
@@ -36,6 +41,10 @@ on:
3641
required: false
3742
type: string
3843
default: "full"
44+
keep_alive:
45+
required: false
46+
type: boolean
47+
default: true
3948
secrets:
4049
BREV_API_TOKEN:
4150
required: true
@@ -101,6 +110,7 @@ jobs:
101110
GITHUB_TOKEN: ${{ github.token }}
102111
INSTANCE_NAME: e2e-pr-${{ inputs.pr_number || github.run_id }}
103112
TEST_SUITE: ${{ inputs.test_suite }}
113+
KEEP_ALIVE: ${{ inputs.keep_alive }}
104114
run: npx vitest run --project e2e-brev --reporter=verbose
105115

106116
- name: Update check run (completed)
@@ -128,7 +138,17 @@ jobs:
128138
EMOJI="❌"
129139
STATUS="FAILED"
130140
fi
141+
INSTANCE="e2e-pr-${{ inputs.pr_number || github.run_id }}"
131142
BODY="${EMOJI} **Brev E2E** (${{ inputs.test_suite }}): **${STATUS}** on branch \`${{ inputs.branch }}\` — [See logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
143+
if [ "${{ inputs.keep_alive }}" = "true" ]; then
144+
BODY="${BODY}
145+
146+
> **Instance \`${INSTANCE}\` is still running.** To SSH in:
147+
> \`\`\`
148+
> brev refresh && ssh ${INSTANCE}
149+
> \`\`\`
150+
> When done, delete it: \`brev delete ${INSTANCE}\`"
151+
fi
132152
gh pr comment ${{ inputs.pr_number }} --repo ${{ github.repository }} --body "$BODY"
133153
134154
- name: Upload test logs

test/e2e/brev-e2e.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ describe("Brev E2E", () => {
144144

145145
afterAll(() => {
146146
if (!instanceCreated) return;
147+
if (process.env.KEEP_ALIVE === "true") {
148+
console.log(`\n Instance "${INSTANCE_NAME}" kept alive for debugging.`);
149+
console.log(` To connect: brev refresh && ssh ${INSTANCE_NAME}`);
150+
console.log(` To delete: brev delete ${INSTANCE_NAME}\n`);
151+
return;
152+
}
147153
try {
148154
brev("delete", INSTANCE_NAME);
149155
} catch {

0 commit comments

Comments
 (0)