Skip to content

Commit a6b7e7b

Browse files
feat(project): init
Signed-off-by: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com>
1 parent b14d5a7 commit a6b7e7b

File tree

5 files changed

+190
-4
lines changed

5 files changed

+190
-4
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
name: Merge Queue Demo
3+
4+
on:
5+
pull_request:
6+
branches: [main]
7+
merge_group:
8+
types: [checks_requested]
9+
10+
jobs:
11+
unit-test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
15+
- name: Run Unit Test
16+
run: ./scripts/test.sh
17+
18+
# Scenario: Job that only runs in the Merge Queue (e.g., expensive integration tests)
19+
merge-queue-exclusive:
20+
if: github.event_name == 'merge_group'
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
24+
- name: Run Expensive Test
25+
run: ./scripts/test.sh sleep 10
26+
27+
# Scenario: Job that only runs on PRs (e.g., quick linting, or checks not needed for merge)
28+
pr-exclusive:
29+
if: github.event_name == 'pull_request'
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
33+
- name: Run Quick Check
34+
run: ./scripts/test.sh
35+
36+
integration-test:
37+
runs-on: ubuntu-latest
38+
needs: unit-test
39+
steps:
40+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
41+
- name: Run Integration Test
42+
run: ./scripts/test.sh
43+
44+
flaky-test:
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
48+
- name: Run Flaky Test
49+
# Change 'pass' to 'flaky' to simulate flakiness
50+
run: ./scripts/test.sh pass
51+
52+
# Scenario: Semantic Conflict Simulation
53+
# This job checks a version file. If two PRs change it incompatibly, this fails.
54+
semantic-conflict-check:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
58+
- name: Check Version Compatibility
59+
run: |
60+
if [ -f scripts/version.txt ]; then
61+
cat scripts/version.txt
62+
else
63+
echo "No version file found."
64+
fi

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2025 CSE Labs
3+
Copyright (c) 2025 Microsoft
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,89 @@
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.

scripts/test.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
MODE="${1:-pass}"
6+
7+
echo "Running POC Test in mode: $MODE"
8+
9+
case $MODE in
10+
fail)
11+
echo "Simulating failure..."
12+
exit 1
13+
;;
14+
flaky)
15+
# Simple 50/50 chance
16+
if ((RANDOM % 2)); then
17+
echo "Simulating flaky failure..."
18+
exit 1
19+
else
20+
echo "Simulating flaky success..."
21+
exit 0
22+
fi
23+
;;
24+
sleep)
25+
DURATION="${2:-30}"
26+
echo "Sleeping for $DURATION seconds..."
27+
sleep "$DURATION"
28+
echo "Woke up!"
29+
exit 0
30+
;;
31+
*)
32+
echo "Test passed!"
33+
exit 0
34+
;;
35+
esac

version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

0 commit comments

Comments
 (0)