-
Notifications
You must be signed in to change notification settings - Fork 7
240 lines (221 loc) · 7.85 KB
/
Copy pathpr-orchestrator.yml
File metadata and controls
240 lines (221 loc) · 7.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
name: Gemini Orchestrator
on:
pull_request:
types: [opened, synchronize]
workflow_dispatch:
inputs:
pr_number:
description: 'PR Number (optional, for manual trigger context)'
required: false
type: string
base_ref:
description: 'Base branch for path filtering'
required: false
type: string
base_branch:
description: 'Base branch for protection rules lookup'
required: false
type: string
head_ref:
description: 'Head branch for path filtering'
required: false
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || inputs.pr_number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
issues: write
checks: write
actions: read
jobs:
filter:
name: 🔍 Path Filter
runs-on: ubuntu-latest
outputs:
should_review: ${{ steps.changes.outputs.src }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dorny/paths-filter@v3
if: github.event_name == 'pull_request'
id: changes-pr
with:
filters: |
src:
- 'app/**'
- 'components/**'
- 'constants/**'
- 'context/**'
- 'hooks/**'
- 'lib/**'
- 'services/**'
- 'utils/**'
- 'types/**'
- 'package.json'
- 'pnpm-lock.yaml'
- 'tsconfig.json'
- 'next.config.js'
- 'tailwind.config.ts'
- '.env*'
- '.github/**'
- 'scripts/**'
- 'tests/**'
- 'stories/**'
- '.storybook/**'
- 'verification/**'
- '*.config.*'
- '*.ts'
- 'ecosystem.config.cjs'
- 'verify_empty_dashboard.py'
- uses: dorny/paths-filter@v3
if: github.event_name == 'workflow_dispatch'
id: changes-dispatch
with:
base: ${{ inputs.base_ref }}
ref: ${{ inputs.head_ref }}
filters: |
src:
- 'app/**'
- 'components/**'
- 'constants/**'
- 'context/**'
- 'hooks/**'
- 'lib/**'
- 'services/**'
- 'utils/**'
- 'types/**'
- 'package.json'
- 'pnpm-lock.yaml'
- 'tsconfig.json'
- 'next.config.js'
- 'tailwind.config.ts'
- '.env*'
- '.github/**'
- 'scripts/**'
- 'tests/**'
- 'stories/**'
- '.storybook/**'
- 'verification/**'
- '*.config.*'
- '*.ts'
- 'ecosystem.config.cjs'
- 'verify_empty_dashboard.py'
- name: Consolidate Changes
id: changes
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "src=${{ steps.changes-pr.outputs.src }}" >> $GITHUB_OUTPUT
else
echo "src=${{ steps.changes-dispatch.outputs.src }}" >> $GITHUB_OUTPUT
fi
check-diff:
name: 🔍 Check Diff
needs: [filter]
if: needs.filter.outputs.should_review == 'true'
runs-on: ubuntu-latest
outputs:
is_meaningful: ${{ steps.diff_check.outputs.is_meaningful }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: pip install unidiff
- name: Generate Diff and Run Script
id: diff_check
env:
PR_TITLE: ${{ github.event.pull_request.title }}
HEAD_REF: ${{ github.head_ref || inputs.head_ref }}
run: |
# Bypass check for E2E tests to ensure they always run the full quality gate
if [[ "$PR_TITLE" == *"E2E Test PR"* ]] || [[ "$HEAD_REF" == "e2e-test-"* ]]; then
echo "::notice::Detected E2E Test PR (Title: '$PR_TITLE', Branch: '$HEAD_REF'). Forcing meaningful changes."
echo "is_meaningful=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if [ "${{ github.event_name }}" == "pull_request" ]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
else
BASE_SHA="${{ inputs.base_ref || 'origin/leader' }}"
HEAD_SHA="${{ inputs.head_ref || 'HEAD' }}"
if [[ "$BASE_SHA" == "origin/"* ]]; then
git fetch origin "${BASE_SHA#origin/}"
elif ! git cat-file -e $BASE_SHA^{commit}; then
git fetch origin leader
BASE_SHA="origin/leader"
fi
fi
echo "Generating diff between $BASE_SHA and $HEAD_SHA"
git diff "$BASE_SHA...$HEAD_SHA" > pr.diff
set +e
python3 scripts/check_diff.py pr.diff --exclude 'pnpm-lock.yaml' 'package-lock.json' '*.lock' '*.md'
RESULT=$?
set -e
if [ "$RESULT" -eq 2 ]; then
echo "No meaningful changes detected (exit code 2)."
echo "is_meaningful=false" >> "$GITHUB_OUTPUT"
elif [ "$RESULT" -eq 0 ]; then
echo "Meaningful changes detected (exit code 0)."
echo "is_meaningful=true" >> "$GITHUB_OUTPUT"
else
echo "::warning::Diff check failed with error code $RESULT. Assuming meaningful changes to be safe."
echo "is_meaningful=true" >> "$GITHUB_OUTPUT"
fi
pr-quality:
name: 🛡️ Quality Gates
needs: [filter, check-diff]
# Requisite: Path Filter must have succeeded (even if no src changes).
# check-diff must not have failed (success or skipped is fine).
if: |
needs.filter.result == 'success' &&
!cancelled() &&
(needs.check-diff.result == 'success' || needs.check-diff.result == 'skipped')
uses: ./.github/workflows/pr-quality.yml
with:
pr_number: ${{ github.event.pull_request.number || inputs.pr_number }}
branch: ${{ github.base_ref || inputs.base_branch || inputs.base_ref || 'leader' }}
secrets:
GH_TOKEN: ${{ secrets.ARI_PAT }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
pr-review:
name: 🤖 Gemini AI Review
needs: [filter, pr-quality, check-diff]
# Requisite: Filter matches AND Quality Gate passed AND Changes are meaningful
if: |
always() &&
needs.filter.outputs.should_review == 'true' &&
needs.pr-quality.result == 'success' &&
needs.check-diff.outputs.is_meaningful == 'true'
uses: ./.github/workflows/reusable-gemini-review.yml
with:
pr_quality_result: ${{ needs.pr-quality.result }}
trigger_event: 'pull_request'
# Path filter handles the diff logic; we pass current HEAD for analysis
last_non_empty_commit: ${{ github.event.pull_request.head.sha || github.sha }}
pr_number: ${{ github.event.pull_request.number || inputs.pr_number }}
base_sha: ${{ github.event.pull_request.base.sha || inputs.base_ref }}
head_sha: ${{ github.event.pull_request.head.sha || inputs.head_ref }}
secrets: inherit
create-review-issues:
name: 🚀 Create Review Issues
needs: [pr-review]
if: |
always() &&
needs.pr-review.result == 'success' &&
needs.pr-review.outputs.review_performed == 'true'
uses: ./.github/workflows/reusable-create-review-issues.yml
with:
pr_number: ${{ github.event.pull_request.number || inputs.pr_number }}
base_sha: ${{ github.event.pull_request.base.sha || inputs.base_ref }}
run_id: ${{ github.run_id }}
secrets:
gh_token: ${{ secrets.GITHUB_TOKEN }}