Skip to content

Commit ec7d2df

Browse files
Copilotnhorton
andauthored
Add explicit branch targeting to merge_group triggers (#52)
* Initial plan * Fix merge queue CI by adding passing jobs for each event type Co-authored-by: nhorton <204146+nhorton@users.noreply.github.com> * Add branch specification to merge_group triggers and workflow_dispatch support Co-authored-by: nhorton <204146+nhorton@users.noreply.github.com> * Update workflow README to document branch targeting and workflow_dispatch Co-authored-by: nhorton <204146+nhorton@users.noreply.github.com> * Add branch specification to pull_request_target trigger in cla.yml Co-authored-by: nhorton <204146+nhorton@users.noreply.github.com> * Add explicit permissions to workflows for security Co-authored-by: nhorton <204146+nhorton@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: nhorton <204146+nhorton@users.noreply.github.com> Co-authored-by: Noah Horton <noah@unsupervised.com>
1 parent ededf2c commit ec7d2df

4 files changed

Lines changed: 78 additions & 25 deletions

File tree

.github/workflows/README.md

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,47 @@ This directory contains CI/CD workflows for the DeepWork project. We use GitHub'
1313

1414
## Merge Queue Strategy
1515

16+
All workflows explicitly target the `main` branch for both `pull_request` and `merge_group` triggers to ensure proper execution in the merge queue.
17+
1618
We use a skip pattern so the same required checks pass in both PR and merge queue contexts:
1719

18-
| Workflow | On PRs | In Merge Queue |
19-
|----------|--------|----------------|
20-
| **Validate** | Runs | Runs |
21-
| **Integration Tests** | Skipped (passes) | Runs |
22-
| **E2E Tests** | Skipped (passes) | Runs |
23-
| **CLA Check** | Runs | Skipped (passes) |
20+
| Workflow | On PRs | In Merge Queue | Manual Trigger |
21+
|----------|--------|----------------|----------------|
22+
| **Validate** | Runs | Runs | Runs |
23+
| **Integration Tests** | Skipped (passes) | Runs | Runs |
24+
| **E2E Tests** | Skipped (passes) | Runs | Runs |
25+
| **CLA Check** | Runs | Skipped (passes) | Skipped (passes) |
2426

2527
### How It Works
2628

29+
All workflows specify explicit branch targeting:
30+
31+
```yaml
32+
on:
33+
pull_request:
34+
branches: [main]
35+
merge_group:
36+
branches: [main]
37+
workflow_dispatch: # Enables manual triggering for testing
38+
```
39+
2740
Jobs/steps use `if: github.event_name == 'merge_group'` conditions to control execution:
2841

2942
```yaml
30-
# Job that only runs in merge queue (skipped on PRs)
43+
# Job that only runs in merge queue and manual dispatch (skipped on PRs)
3144
jobs:
3245
expensive-tests:
3346
if: github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch'
3447
...
3548
36-
# Step that skips in merge queue (runs on PRs only)
37-
steps:
38-
- name: CLA Check
39-
if: github.event_name != 'merge_group'
49+
# Job that skips in merge queue and manual dispatch (runs on PRs only)
50+
jobs:
51+
cla-check:
52+
if: github.event_name != 'merge_group' && github.event_name != 'workflow_dispatch'
4053
...
4154
```
4255

43-
When a job/step is skipped due to an `if` condition, GitHub treats it as a successful check. This allows:
56+
When a job is skipped due to an `if` condition, GitHub treats it as a successful check. This allows:
4457

4558
- **Fast PR feedback**: Only lint + unit tests run on every push
4659
- **Thorough merge validation**: Expensive integration/e2e tests run in merge queue before merging
@@ -50,31 +63,38 @@ When a job/step is skipped due to an `if` condition, GitHub treats it as a succe
5063

5164
In GitHub branch protection rules, require these checks:
5265
- `Validate / tests`
53-
- `Claude Code Integration Test / validate-generation`
54-
- `Claude Code Integration Test / claude-code-e2e`
55-
- `CLA Assistant / cla-check`
66+
- `Claude Code Integration Test / pr-check` (for PRs)
67+
- `Claude Code Integration Test / validate-generation` (for merge queue)
68+
- `Claude Code Integration Test / claude-code-e2e` (for merge queue)
69+
- `CLA Assistant / merge-queue-pass` (for merge queue)
70+
- `CLA Assistant / cla-check` (for PRs)
5671

5772
All checks will pass in both PR and merge queue contexts (either by running or by being skipped).
5873

74+
**Note**: The explicit branch targeting in `merge_group` triggers is critical for workflows to run properly in the merge queue. Without this, GitHub may not trigger the workflows and they will remain in "expected" state.
75+
5976
## Workflow Details
6077

6178
### validate.yml
62-
- **Triggers**: `pull_request`, `merge_group`
79+
- **Triggers**: `pull_request` (main), `merge_group` (main), `workflow_dispatch`
6380
- **Jobs**: `tests` - runs ruff format/lint checks and pytest unit tests
64-
- Runs on every PR and in merge queue
81+
- Runs on every PR, in merge queue, and can be manually triggered
6582

6683
### claude-code-test.yml
67-
- **Triggers**: `pull_request`, `merge_group`, `workflow_dispatch`
84+
- **Triggers**: `pull_request` (main), `merge_group` (main), `workflow_dispatch`
6885
- **Jobs**:
86+
- `pr-check`: Runs on PRs only, always passes (lightweight check)
6987
- `validate-generation`: Tests command generation from fixtures (no API key needed)
7088
- `claude-code-e2e`: Full end-to-end test with Claude Code CLI (requires `ANTHROPIC_API_KEY`)
71-
- Both jobs skip on PRs, run in merge queue and manual dispatch
89+
- `validate-generation` and `claude-code-e2e` skip on PRs, run in merge queue and manual dispatch
7290

7391
### cla.yml
74-
- **Triggers**: `pull_request_target`, `issue_comment`, `merge_group`
75-
- **Jobs**: `cla-check` - verifies contributors have signed the CLA
76-
- Runs on PRs, skips in merge queue (CLA already verified)
92+
- **Triggers**: `pull_request_target`, `issue_comment`, `merge_group` (main), `workflow_dispatch`
93+
- **Jobs**:
94+
- `merge-queue-pass`: Runs on merge queue and manual dispatch, always passes
95+
- `cla-check`: Verifies contributors have signed the CLA
96+
- `cla-check` runs on PRs, skips in merge queue and manual dispatch (CLA already verified)
7797

7898
### release.yml
79-
- **Triggers**: Tags matching `v*`
99+
- **Triggers**: `release` (published)
80100
- **Jobs**: Builds and publishes to PyPI

.github/workflows/cla.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ on:
55
types: [created]
66
pull_request_target:
77
types: [opened, synchronize]
8+
branches: [main]
89
# Run in merge queue but skip the step (shows as passing check)
910
merge_group:
11+
branches: [main]
12+
workflow_dispatch:
1013

1114
# Explicitly set permissions for the workflow
1215
permissions:
@@ -16,11 +19,20 @@ permissions:
1619
statuses: write
1720

1821
jobs:
22+
# Job for merge queue - always passes since CLA is checked at PR time
23+
merge-queue-pass:
24+
runs-on: ubuntu-latest
25+
if: github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch'
26+
steps:
27+
- name: CLA already verified at PR time
28+
run: echo "CLA check is performed on PRs, not in merge queue. Passing."
29+
1930
cla-check:
2031
runs-on: ubuntu-latest
32+
if: github.event_name != 'merge_group' && github.event_name != 'workflow_dispatch'
2133
steps:
2234
- name: "CLA Assistant"
23-
if: github.event_name != 'merge_group' && ((github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target')
35+
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
2436
uses: contributor-assistant/github-action@v2.6.1
2537
env:
2638
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/claude-code-test.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,31 @@ on:
1111
type: boolean
1212
# Run on all PRs (shows as check, but steps skip unless in merge queue)
1313
pull_request:
14+
branches: [main]
1415
# Run in the merge queue to validate before merging
1516
merge_group:
17+
branches: [main]
1618

1719
# Ensure only one instance runs at a time per PR/branch
1820
concurrency:
1921
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
2022
cancel-in-progress: true
2123

24+
# Minimal permissions for this workflow
25+
permissions:
26+
contents: read
27+
2228
jobs:
29+
# Job for PRs - always passes, actual validation happens in merge queue
30+
pr-check:
31+
runs-on: ubuntu-latest
32+
if: github.event_name == 'pull_request'
33+
steps:
34+
- name: PR Check
35+
run: echo "Claude Code integration tests will run in the merge queue"
36+
2337
# Job 1: Validate command generation from fixtures (no API key needed)
24-
# Runs on merge_group and workflow_dispatch, skipped on PRs (shows as passing check)
38+
# Runs on merge_group and workflow_dispatch only
2539
validate-generation:
2640
runs-on: ubuntu-latest
2741
if: github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch'

.github/workflows/validate.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ name: Validate
22

33
on:
44
pull_request:
5+
branches: [main]
56
merge_group:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
# Minimal permissions for this workflow
11+
permissions:
12+
contents: read
613

714
jobs:
815
tests:

0 commit comments

Comments
 (0)