|
1 | | -name: "🚀 Auto-merge Development → Main" |
| 1 | +name: Auto-merge Development to Main |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | workflow_run: |
5 | 5 | workflows: |
6 | 6 | - "Cross-Platform Sanity Check" |
7 | | - - "🔍 Package Discovery Demo - Omnipkg Intelligence" |
8 | | - - "🌌 LIVE - Quantum Python Auto-Switch Test" |
9 | | - - "🧪 Flask Port Finder & Auto-Healing Test" |
10 | | - - "🔥 Live NumPy/SciPy Hot-Swapping" |
11 | | - - "🔥 LIVE - Python Library Hot-Swap" |
12 | | - - "💥 Nuclear Test: TensorFlow Dependency Hot-Swap" |
13 | | - - "⬆️ LIVE - Package Upgrade Test" |
14 | | - - "🔄 LIVE - Omnipkg Self-Upgrade Test" |
15 | | - - "🌍 Omnipkg Multi-Language Intelligence Demo" |
16 | | - - "🌠 LIVE - Omnipkg Quantum Multiverse Warp (FINAL)" |
| 7 | + - "Package Discovery Demo - Omnipkg Intelligence" |
| 8 | + - "LIVE - Quantum Python Auto-Switch Test" |
| 9 | + - "Flask Port Finder & Auto-Healing Test" |
| 10 | + - "Live NumPy/SciPy Hot-Swapping" |
| 11 | + - "LIVE - Python Library Hot-Swap" |
| 12 | + - "Nuclear Test: TensorFlow Dependency Hot-Swap" |
| 13 | + - "LIVE - Package Upgrade Test" |
| 14 | + - "LIVE - Omnipkg Self-Upgrade Test" |
| 15 | + - "Omnipkg Multi-Language Intelligence Demo" |
| 16 | + - "LIVE - Omnipkg Quantum Multiverse Warp (FINAL)" |
17 | 17 | - "Package Manager Comparison Test" |
18 | | - - "🍎 macOS - Omnipkg Demo Test (CI - No Redis)" |
19 | | - - "🚀 Windows - Omnipkg Demo Test (CI - No Redis)" |
| 18 | + - "macOS - Omnipkg Demo Test (CI - No Redis)" |
| 19 | + - "Windows - Omnipkg Demo Test (CI - No Redis)" |
20 | 20 | - "Omnipkg True First-Run Test (Windows)" |
21 | | - - "🔄 UV Self-Downgrades → Auto-Revert" |
| 21 | + - "UV Self-Downgrades Auto-Revert" |
22 | 22 | - "Simple UV Multi-Version Test" |
23 | 23 | - "Old Rich Test" |
24 | 24 | - "Simple Python Adoption Test" |
25 | | - - "🎪 Demo Matrix Test (All Demos)" |
| 25 | + - "Demo Matrix Test (All Demos)" |
26 | 26 | types: |
27 | 27 | - completed |
28 | 28 | branches: |
|
31 | 31 | permissions: |
32 | 32 | contents: write |
33 | 33 | actions: read |
34 | | - issues: write |
35 | 34 |
|
36 | | -# Prevents two merges from happening at the same time |
37 | 35 | concurrency: |
38 | 36 | group: auto-merge-main |
39 | 37 | cancel-in-progress: false |
40 | 38 |
|
41 | 39 | jobs: |
42 | | - check-and-merge: |
| 40 | + auto-merge: |
43 | 41 | runs-on: ubuntu-latest |
44 | 42 | if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'development' |
45 | 43 |
|
46 | 44 | steps: |
47 | | - - uses: actions/checkout@v3 |
| 45 | + - name: Checkout |
| 46 | + uses: actions/checkout@v3 |
48 | 47 | with: |
49 | 48 | fetch-depth: 0 |
50 | 49 | token: ${{ secrets.GITHUB_TOKEN }} |
51 | 50 |
|
52 | | - - name: Configure git |
| 51 | + - name: Configure Git |
53 | 52 | run: | |
54 | 53 | git config user.name "github-actions[bot]" |
55 | 54 | git config user.email "github-actions[bot]@users.noreply.github.com" |
56 | 55 | |
57 | | - - name: Analyze Workflow Status |
58 | | - id: check_all |
| 56 | + - name: Check All Workflows Passed |
| 57 | + id: check |
59 | 58 | run: | |
60 | 59 | COMMIT_SHA="${{ github.event.workflow_run.head_sha }}" |
61 | | - SHORT_SHA=$(echo $COMMIT_SHA | cut -c1-7) |
62 | | - echo "📊 Analyzing commit: $SHORT_SHA" |
63 | 60 | |
64 | | - # Get all workflow runs for this specific commit |
65 | 61 | gh run list \ |
66 | 62 | --branch development \ |
67 | 63 | --commit $COMMIT_SHA \ |
68 | | - --json conclusion,status,name \ |
69 | | - --limit 200 > runs.json |
70 | | - |
71 | | - # Calculate stats |
72 | | - TOTAL=$(jq '. | length' runs.json) |
73 | | - SUCCESS=$(jq '[.[] | select(.conclusion == "success")] | length' runs.json) |
74 | | - SKIPPED=$(jq '[.[] | select(.conclusion == "skipped" or .conclusion == "neutral")] | length' runs.json) |
75 | | - IN_PROGRESS=$(jq '[.[] | select(.status == "in_progress" or .status == "queued" or .status == "waiting")] | length' runs.json) |
76 | | - FAILED=$(jq '[.[] | select(.conclusion == "failure" or .conclusion == "timed_out" or .conclusion == "cancelled")] | length' runs.json) |
| 64 | + --json conclusion,status \ |
| 65 | + --limit 100 > runs.json |
77 | 66 | |
78 | | - EFFECTIVE_PASS=$((SUCCESS + SKIPPED)) |
| 67 | + TOTAL=$(jq 'length' runs.json) |
| 68 | + SUCCESS=$(jq '[.[] | select(.conclusion == "success" or .conclusion == "skipped")] | length' runs.json) |
| 69 | + IN_PROGRESS=$(jq '[.[] | select(.status == "in_progress" or .status == "queued")] | length' runs.json) |
| 70 | + FAILED=$(jq '[.[] | select(.conclusion == "failure")] | length' runs.json) |
79 | 71 | |
80 | | - echo "📊 Stats for commit $SHORT_SHA:" |
81 | | - echo " Total workflows: $TOTAL" |
82 | | - echo " ✅ Success: $SUCCESS" |
83 | | - echo " ⏭️ Skipped: $SKIPPED" |
84 | | - echo " ⏳ In Progress: $IN_PROGRESS" |
85 | | - echo " ❌ Failed: $FAILED" |
86 | | - echo "" |
| 72 | + echo "Total: $TOTAL, Success: $SUCCESS, In Progress: $IN_PROGRESS, Failed: $FAILED" |
87 | 73 | |
88 | | - # 1. If anything is still running, wait for the last workflow to trigger merge |
89 | 74 | if [ "$IN_PROGRESS" -gt 0 ]; then |
90 | | - echo "⏳ Workflows still running. Waiting for completion..." |
| 75 | + echo "Workflows still running, skipping merge" |
91 | 76 | echo "should_merge=false" >> $GITHUB_OUTPUT |
92 | 77 | exit 0 |
93 | 78 | fi |
94 | 79 | |
95 | | - # 2. If anything failed, block merge |
96 | 80 | if [ "$FAILED" -gt 0 ]; then |
97 | | - echo "❌ Some workflows failed. Not merging." |
98 | | - echo "Failed workflows:" |
99 | | - jq -r '.[] | select(.conclusion == "failure" or .conclusion == "timed_out" or .conclusion == "cancelled") | " - \(.name): \(.conclusion)"' runs.json |
| 81 | + echo "Some workflows failed, skipping merge" |
100 | 82 | echo "should_merge=false" >> $GITHUB_OUTPUT |
101 | 83 | exit 0 |
102 | 84 | fi |
103 | 85 | |
104 | | - # 3. Safety check: Ensure we ran enough tests (at least 5) |
105 | | - if [ "$EFFECTIVE_PASS" -lt 5 ]; then |
106 | | - echo "⚠️ Too few workflows completed ($EFFECTIVE_PASS/5). Possible CI issue." |
| 86 | + if [ "$SUCCESS" -lt 5 ]; then |
| 87 | + echo "Not enough workflows passed, skipping merge" |
107 | 88 | echo "should_merge=false" >> $GITHUB_OUTPUT |
108 | 89 | exit 0 |
109 | 90 | fi |
110 | 91 | |
111 | | - echo "✅ All $EFFECTIVE_PASS workflows passed! Ready to merge." |
| 92 | + echo "All workflows passed" |
112 | 93 | echo "should_merge=true" >> $GITHUB_OUTPUT |
113 | 94 | echo "commit_sha=$COMMIT_SHA" >> $GITHUB_OUTPUT |
114 | | - echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT |
115 | 95 | env: |
116 | 96 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
117 | 97 |
|
118 | | - - name: Check if already merged |
119 | | - if: steps.check_all.outputs.should_merge == 'true' |
| 98 | + - name: Check Not Already Merged |
| 99 | + if: steps.check.outputs.should_merge == 'true' |
120 | 100 | id: check_merged |
121 | 101 | run: | |
122 | | - COMMIT_SHA="${{ steps.check_all.outputs.commit_sha }}" |
123 | | - SHORT_SHA="${{ steps.check_all.outputs.short_sha }}" |
124 | | - |
| 102 | + COMMIT_SHA="${{ steps.check.outputs.commit_sha }}" |
125 | 103 | git fetch origin main |
126 | 104 | |
127 | | - # Check if this commit (or its ancestors) are already in main |
128 | 105 | if git merge-base --is-ancestor $COMMIT_SHA origin/main; then |
129 | | - echo "✅ Commit $SHORT_SHA is already in main. Nothing to do." |
| 106 | + echo "Commit already in main" |
130 | 107 | echo "already_merged=true" >> $GITHUB_OUTPUT |
131 | 108 | else |
132 | | - echo "📝 Commit $SHORT_SHA not yet in main. Proceeding with merge." |
| 109 | + echo "Commit not yet merged" |
133 | 110 | echo "already_merged=false" >> $GITHUB_OUTPUT |
134 | 111 | fi |
135 | 112 | |
136 | | - - name: Merge development into main |
137 | | - if: steps.check_all.outputs.should_merge == 'true' && steps.check_merged.outputs.already_merged == 'false' |
| 113 | + - name: Merge to Main |
| 114 | + if: steps.check.outputs.should_merge == 'true' && steps.check_merged.outputs.already_merged == 'false' |
138 | 115 | run: | |
139 | | - COMMIT_SHA="${{ steps.check_all.outputs.commit_sha }}" |
140 | | - SHORT_SHA="${{ steps.check_all.outputs.short_sha }}" |
141 | | - |
142 | | - echo "🔄 Merging development (up to $SHORT_SHA) into main..." |
| 116 | + COMMIT_SHA="${{ steps.check.outputs.commit_sha }}" |
| 117 | + SHORT_SHA=$(echo $COMMIT_SHA | cut -c1-7) |
143 | 118 | |
144 | | - # Switch to main and update |
145 | 119 | git checkout main |
146 | 120 | git pull origin main |
147 | | - |
148 | | - # Fetch latest development |
149 | 121 | git fetch origin development |
150 | 122 | |
151 | | - # Merge the commit (this brings all ancestor commits too!) |
152 | | - WORKFLOW_COUNT=$(jq '. | length' runs.json) |
153 | | - |
154 | | - if git merge $COMMIT_SHA --no-ff -m "Auto-merge: development → main ($SHORT_SHA) |
155 | | -
|
156 | | -All CI checks passed for commit $SHORT_SHA. |
157 | | - |
158 | | -✅ Workflows completed: $WORKFLOW_COUNT |
159 | | -📦 Merged by: GitHub Actions |
160 | | -🔗 Triggered by: ${{ github.event.workflow_run.name }}"; then |
161 | | - |
162 | | - echo "✅ Merge successful!" |
163 | | - |
164 | | - # Push to main |
165 | | - git push origin main |
166 | | - |
167 | | - echo "🚀 Successfully merged to main!" |
168 | | - |
169 | | - else |
170 | | - echo "❌ Merge conflict detected!" |
171 | | - git merge --abort |
172 | | - |
173 | | - # Create issue for manual resolution |
174 | | - gh issue create \ |
175 | | - --title "🚨 Auto-merge Failed: Conflict in $SHORT_SHA" \ |
176 | | - --body "## Merge Conflict Detected |
177 | | - |
178 | | -Commit [$SHORT_SHA](https://github.com/${{ github.repository }}/commit/$COMMIT_SHA) passed all CI tests but has merge conflicts with main. |
179 | | - |
180 | | -**Manual intervention required:** |
181 | | - |
182 | | -\`\`\`bash |
183 | | -git checkout main |
184 | | -git pull origin main |
185 | | -git merge $COMMIT_SHA |
186 | | -# Resolve conflicts |
187 | | -git commit |
188 | | -git push origin main |
189 | | -\`\`\` |
190 | | - |
191 | | -**Or rebase development on main:** |
192 | | - |
193 | | -\`\`\`bash |
194 | | -git checkout development |
195 | | -git pull origin development |
196 | | -git rebase origin/main |
197 | | -# Resolve conflicts |
198 | | -git push --force-with-lease origin development |
199 | | -\`\`\` |
200 | | - |
201 | | -Once resolved, this workflow will retry automatically." \ |
202 | | - --label "auto-merge-conflict" \ |
203 | | - --label "needs-manual-merge" |
204 | | - |
205 | | - exit 1 |
206 | | - fi |
| 123 | + git merge $COMMIT_SHA --no-ff -m "Auto-merge development to main ($SHORT_SHA)" -m "All CI checks passed" |
| 124 | + git push origin main |
207 | 125 | env: |
208 | 126 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments