Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions examples/gastown/gastown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,24 @@ func TestRefineryFormulaRespectsExistingPRMetadata(t *testing.T) {
)
}

func TestRefineryFormulaEnablesAutoMergeAfterPRValidation(t *testing.T) {
dir := exampleDir()
path := filepath.Join(dir, "packs", "gastown", "formulas", "mol-refinery-patrol.toml")
data, err := os.ReadFile(path)
if err != nil {
t.Fatalf("reading refinery formula: %v", err)
}
body := string(data)
if !strings.Contains(body, `gh pr merge "$PR_REF" --auto`) {
t.Errorf("refinery formula missing auto-merge enablement after PR validation")
}
assertContainsInOrder(t, body,
`PR_HEAD_REPO=$(printf '%s\n' "$PR_INFO" | jq -r '.headRepositoryOwner.login + "/" + .headRepository.name')`,
`gh pr merge "$PR_REF" --auto`,
`gc bd close $WORK --reason "Pull request ready: $PR_URL"`,
)
}

func TestWorktreeSetupKeepsIgnoresLocal(t *testing.T) {
tmp := t.TempDir()
repo := filepath.Join(tmp, "repo")
Expand Down
15 changes: 13 additions & 2 deletions examples/gastown/packs/gastown/formulas/mol-refinery-patrol.toml
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,18 @@ fi
```
If this command fails or prints empty output: STOP. Debug and retry. Do NOT continue.

**4. Record PR metadata and close the work bead:**
**4. Enable auto-merge on the pull request:**
```bash
gh pr merge "$PR_REF" --auto -m 2>&1 || true
```
Idempotent — `--auto` returns 'already queued' or 'already enabled' on repeat
calls. If the PR is currently mergeable (all required checks passed), it is
added directly to the GitHub merge queue; otherwise auto-merge is enabled and
the PR enters the queue when checks pass. This is best-effort — a transient
failure here does not block the bead handoff. The intent is that no campaign
PR sits CI-green-but-unqueued waiting for a human to push the merge button.

**5. Record PR metadata and close the work bead:**
```bash
gc bd update $WORK \
--set-metadata merge_result=pull_request \
Expand All @@ -525,7 +536,7 @@ gc bd update $WORK \
gc bd close $WORK --reason "Pull request ready: $PR_URL"
```

**5. Cleanup:**
**6. Cleanup:**
```bash
git checkout "$TARGET"
git branch -d temp
Expand Down
Loading