|
1 | | -# Repository setup required :wave: |
2 | | - |
3 | | -Please visit the website URL :point_right: for this repository to complete the setup of this repository and configure access controls. |
| 1 | +# Merge Queue Demo |
| 2 | + |
| 3 | +This folder contains Proof of Concept files to demonstrate GitHub Merge Queues. |
| 4 | + |
| 5 | +## Files |
| 6 | + |
| 7 | +- `.github/workflows/merge-queue-demo.yaml`: A GitHub Actions workflow configured to run on `pull_request` and `merge_group` events. |
| 8 | +- `test.sh`: A script that simulates test execution with various modes (`pass`, `fail`, `flaky`, `sleep`). |
| 9 | +- `version.txt`: A simple text file used to demonstrate semantic conflicts. |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +1. **Setup**: |
| 14 | + - Ensure `test.sh` is executable (`chmod +x scripts/test.sh`). |
| 15 | + |
| 16 | +## Scenarios |
| 17 | + |
| 18 | +### 1. Happy Path |
| 19 | + |
| 20 | +- **Action**: Create a PR with no changes to the POC files (or trivial changes). |
| 21 | +- **Expectation**: All checks pass. Add to merge queue. It merges successfully. |
| 22 | + |
| 23 | +### 2. Simple Failure |
| 24 | + |
| 25 | +- **Action**: Modify `merge-queue-demo.yaml` in your PR to run `./scripts/test.sh fail`. |
| 26 | +- **Expectation**: The PR check fails immediately. You cannot add it to the merge queue. |
| 27 | + |
| 28 | +### 3. Merge Queue Exclusive Failure |
| 29 | + |
| 30 | +- **Action**: |
| 31 | + |
| 32 | + - Modify `merge-queue-demo.yaml` to make the `merge-queue-exclusive` job fail: |
| 33 | + |
| 34 | + ```yaml |
| 35 | + merge-queue-exclusive: |
| 36 | + if: github.event_name == 'merge_group' |
| 37 | + steps: |
| 38 | + - run: ./scripts/test.sh fail |
| 39 | + ``` |
| 40 | +
|
| 41 | +- **Expectation**: |
| 42 | + - PR checks pass (because this job is skipped on `pull_request`). |
| 43 | + - You add it to the merge queue. |
| 44 | + - The job runs in the queue and fails. |
| 45 | + - The PR is removed from the queue. |
| 46 | + |
| 47 | +### 4. Flaky Tests |
| 48 | + |
| 49 | +- **Action**: |
| 50 | + |
| 51 | + - Modify `merge-queue-demo.yaml` to use the `flaky` mode: |
| 52 | + |
| 53 | + ```yaml |
| 54 | + flaky-test: |
| 55 | + steps: |
| 56 | + - run: ./scripts/test.sh flaky |
| 57 | + ``` |
| 58 | + |
| 59 | +- **Expectation**: |
| 60 | + - The test will fail ~50% of the time. |
| 61 | + - Observe how the Merge Queue handles retries (if configured) or failures. |
| 62 | + |
| 63 | +### 5. Semantic Conflict (The "Diamond Dependency" / Logical Conflict) |
| 64 | + |
| 65 | +This scenario simulates two PRs that pass individually but fail when combined. |
| 66 | + |
| 67 | +- **Setup**: Ensure `scripts/test.sh` is in `main`. |
| 68 | +- **PR A**: |
| 69 | + - Update `scripts/test.sh` to **require** an argument. |
| 70 | + - Change line 4 to: `MODE="${1:?Usage: test.sh <mode>}"` |
| 71 | + - Update `merge-queue-demo.yaml` in PR A to pass an argument (e.g., `./scripts/test.sh pass`). |
| 72 | + - **Result**: PR A passes checks. |
| 73 | +- **PR B**: |
| 74 | + - Add a new step to `merge-queue-demo.yaml` that calls `./scripts/test.sh` **without** arguments. |
| 75 | + - **Result**: PR B passes checks (because in PR B's context, `test.sh` is still the old version that defaults to "pass"). |
| 76 | +- **Execution**: |
| 77 | + 1. Add PR A to the merge queue. |
| 78 | + 2. Add PR B to the merge queue immediately after. |
| 79 | + 3. PR A merges. |
| 80 | + 4. PR B runs in the queue _on top of_ PR A's changes. |
| 81 | + 5. PR B's new step calls `test.sh` (which is now the version from PR A). |
| 82 | + 6. `test.sh` fails because it requires an argument. |
| 83 | + 7. **Result**: PR B fails in the merge queue and is removed. |
| 84 | + |
| 85 | +### 6. Version Conflict |
| 86 | + |
| 87 | +- **PR A**: Change `scripts/version.txt` to `1.1.0`. |
| 88 | +- **PR B**: Change `scripts/version.txt` to `1.2.0`. |
| 89 | +- **Result**: If git cannot auto-resolve, this is a standard merge conflict. If they touch different lines (e.g., appending to a log), both might merge, but a test checking for specific content would fail in the queue. |
0 commit comments