-
Notifications
You must be signed in to change notification settings - Fork 0
435 lines (378 loc) · 17.3 KB
/
gen-new-plot.yml
File metadata and controls
435 lines (378 loc) · 17.3 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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
name: "Gen: New Plot"
run-name: "Generate: ${{ github.event.issue.title }}"
on:
issues:
types: [labeled]
concurrency:
group: spec-to-code-${{ github.event.issue.number }}
cancel-in-progress: true
env:
LIBRARIES: "matplotlib seaborn plotly bokeh altair plotnine pygal highcharts"
jobs:
# ============================================================================
# Step 1: Check conditions and extract spec ID
# ============================================================================
check-conditions:
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.check.outputs.should_run }}
spec_id: ${{ steps.extract_spec.outputs.spec_id }}
is_update: ${{ steps.extract_spec.outputs.is_update }}
target_library: ${{ steps.extract_spec.outputs.target_library }}
steps:
- name: Check conditions
id: check
run: |
echo "=== Debug Info ==="
echo "Label added: ${{ github.event.label.name }}"
echo "Issue labels: ${{ join(github.event.issue.labels.*.name, ', ') }}"
echo "=================="
# Check 1: Must be "approved" label being added
if [[ "${{ github.event.label.name }}" != "approved" ]]; then
echo "::notice::Skipping: Not the 'approved' label"
echo "should_run=false" >> $GITHUB_OUTPUT
exit 0
fi
# Check 2: Issue must have "plot-request" label
HAS_PLOT_REQUEST="${{ contains(github.event.issue.labels.*.name, 'plot-request') }}"
if [[ "$HAS_PLOT_REQUEST" != "true" ]]; then
echo "::notice::Skipping: Issue does not have 'plot-request' label"
echo "should_run=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "::notice::All conditions met - proceeding with code generation"
echo "should_run=true" >> $GITHUB_OUTPUT
- name: Checkout repository
if: steps.check.outputs.should_run == 'true'
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Extract spec ID from issue
if: steps.check.outputs.should_run == 'true'
id: extract_spec
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_TITLE: ${{ github.event.issue.title }}
run: |
# Check for [update] or [update:library] prefix in title
IS_UPDATE="false"
TARGET_LIBRARY=""
if echo "$ISSUE_TITLE" | grep -qiP '^\[update(:[a-z]+)?\]'; then
IS_UPDATE="true"
# Extract target library if specified (e.g., [update:seaborn])
TARGET_LIBRARY=$(echo "$ISSUE_TITLE" | grep -oiP '^\[update:\K[a-z]+(?=\])' | tr '[:upper:]' '[:lower:]' || echo "")
# Remove [update...] prefix from title for spec ID extraction
CLEAN_TITLE=$(echo "$ISSUE_TITLE" | sed 's/^\[update[^]]*\]\s*//')
echo "::notice::Update mode detected. Target library: ${TARGET_LIBRARY:-all}"
else
CLEAN_TITLE="$ISSUE_TITLE"
fi
# Validate TARGET_LIBRARY if specified
if [ -n "$TARGET_LIBRARY" ]; then
VALID_LIBS="matplotlib seaborn plotly bokeh altair plotnine pygal highcharts"
if ! echo "$VALID_LIBS" | grep -qw "$TARGET_LIBRARY"; then
echo "::error::Invalid library '$TARGET_LIBRARY'. Must be one of: $VALID_LIBS"
exit 1
fi
fi
# Check if issue was marked as duplicate
COMMENTS=$(gh issue view ${{ github.event.issue.number }} --json comments -q '.comments[].body')
if echo "$COMMENTS" | grep -q "Duplicate Detected"; then
echo "::error::This issue was marked as a duplicate"
exit 1
fi
# For updates, try to extract spec ID from cleaned title first
if [ "$IS_UPDATE" == "true" ]; then
SPEC_ID=$(echo "$CLEAN_TITLE" | grep -oiP '^[a-z]+-[a-z]+(-[a-z0-9]+)?' | tr '[:upper:]' '[:lower:]' || echo "")
fi
# Extract spec ID from issue comments (assigned by validate-plot-request workflow)
if [ -z "$SPEC_ID" ]; then
SPEC_ID=$(echo "$COMMENTS" | grep -oP '\*\*Assigned ID:\*\* `\K[a-z0-9-]+(?=`)' | tail -1 || echo "")
fi
if [ -z "$SPEC_ID" ]; then
SPEC_ID=$(echo "$COMMENTS" | grep -oP '\*\*Existing Spec:\*\* `\K[a-z0-9-]+(?=`)' | tail -1 || echo "")
fi
if [ -z "$SPEC_ID" ]; then
SPEC_ID=$(echo "$ISSUE_TITLE" | grep -oiP '^[a-z]+-[a-z]+(-[a-z0-9]+)?' | tr '[:upper:]' '[:lower:]' || echo "")
fi
if [ -z "$SPEC_ID" ]; then
SPEC_ID=$(echo "$ISSUE_TITLE" | grep -oiP '^[a-z]+-[a-z]+-\d{3,4}' | tr '[:upper:]' '[:lower:]' || echo "")
fi
if [ -z "$SPEC_ID" ]; then
echo "::error::Could not extract spec ID from issue"
exit 1
fi
echo "spec_id=$SPEC_ID" >> $GITHUB_OUTPUT
echo "is_update=$IS_UPDATE" >> $GITHUB_OUTPUT
echo "target_library=$TARGET_LIBRARY" >> $GITHUB_OUTPUT
echo "::notice::Extracted spec ID: $SPEC_ID (update=$IS_UPDATE, target=$TARGET_LIBRARY)"
# ============================================================================
# Step 2: Create sub-issues for each library
# ============================================================================
create-sub-issues:
needs: check-conditions
if: needs.check-conditions.outputs.should_run == 'true'
runs-on: ubuntu-latest
outputs:
matplotlib_issue: ${{ steps.create.outputs.matplotlib_issue }}
seaborn_issue: ${{ steps.create.outputs.seaborn_issue }}
plotly_issue: ${{ steps.create.outputs.plotly_issue }}
bokeh_issue: ${{ steps.create.outputs.bokeh_issue }}
altair_issue: ${{ steps.create.outputs.altair_issue }}
plotnine_issue: ${{ steps.create.outputs.plotnine_issue }}
pygal_issue: ${{ steps.create.outputs.pygal_issue }}
highcharts_issue: ${{ steps.create.outputs.highcharts_issue }}
permissions:
contents: read
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: React with eyes emoji
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/reactions \
-f content=eyes
- name: Add in-progress label
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh issue edit ${{ github.event.issue.number }} --add-label "in-progress"
- name: Create sub-issues for each library
id: create
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
SPEC_ID="${{ needs.check-conditions.outputs.spec_id }}"
PARENT_NUM="${{ github.event.issue.number }}"
PARENT_NODE_ID=$(gh api repos/${{ github.repository }}/issues/$PARENT_NUM --jq '.node_id')
for LIBRARY in ${{ env.LIBRARIES }}; do
echo "Creating sub-issue for $LIBRARY..."
# Check if sub-issue already exists
EXISTING=$(gh issue list --label "library:$LIBRARY" --search "[$SPEC_ID] in:title" --json number -q '.[0].number' 2>/dev/null || echo "")
if [ -n "$EXISTING" ]; then
echo "${LIBRARY}_issue=$EXISTING" >> $GITHUB_OUTPUT
echo "::notice::Sub-issue for $LIBRARY already exists: #$EXISTING"
continue
fi
# Create sub-issue
SUB_BODY="## [$SPEC_ID] $LIBRARY Implementation
**Parent Issue:** #$PARENT_NUM
**Spec:** \`specs/$SPEC_ID.md\`
**Library:** $LIBRARY
---
### Attempt History
_Attempts will be documented below as comments._
"
SUB_ISSUE=$(gh issue create \
--title "[$SPEC_ID] $LIBRARY implementation" \
--body "$SUB_BODY" \
--label "library:$LIBRARY,plot-request:impl,generating")
SUB_NUM=$(echo "$SUB_ISSUE" | grep -oP '\d+$')
SUB_NODE_ID=$(gh api repos/${{ github.repository }}/issues/$SUB_NUM --jq '.node_id')
# Link as sub-issue using GitHub's sub-issues API
gh api graphql -f query='
mutation($parent: ID!, $child: ID!) {
addSubIssue(input: {issueId: $parent, subIssueId: $child}) {
issue { id }
}
}' -f parent="$PARENT_NODE_ID" -f child="$SUB_NODE_ID" 2>/dev/null || echo "Note: Sub-issue linking not available"
echo "${LIBRARY}_issue=$SUB_NUM" >> $GITHUB_OUTPUT
echo "::notice::Created sub-issue for $LIBRARY: #$SUB_NUM"
done
# ============================================================================
# Step 3: Generate implementations in parallel (one job per library)
# ============================================================================
generate-matplotlib:
needs: [check-conditions, create-sub-issues]
if: |
needs.check-conditions.outputs.should_run == 'true' &&
(needs.check-conditions.outputs.target_library == '' ||
needs.check-conditions.outputs.target_library == 'matplotlib')
uses: ./.github/workflows/gen-library-impl.yml
with:
spec_id: ${{ needs.check-conditions.outputs.spec_id }}
library: matplotlib
main_issue_number: ${{ github.event.issue.number }}
sub_issue_number: ${{ needs.create-sub-issues.outputs.matplotlib_issue }}
deps: "matplotlib>=3.9.0 numpy>=1.26.0"
secrets:
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
generate-seaborn:
needs: [check-conditions, create-sub-issues]
if: |
needs.check-conditions.outputs.should_run == 'true' &&
(needs.check-conditions.outputs.target_library == '' ||
needs.check-conditions.outputs.target_library == 'seaborn')
uses: ./.github/workflows/gen-library-impl.yml
with:
spec_id: ${{ needs.check-conditions.outputs.spec_id }}
library: seaborn
main_issue_number: ${{ github.event.issue.number }}
sub_issue_number: ${{ needs.create-sub-issues.outputs.seaborn_issue }}
deps: "seaborn>=0.13.0 matplotlib numpy>=1.26.0"
secrets:
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
generate-plotly:
needs: [check-conditions, create-sub-issues]
if: |
needs.check-conditions.outputs.should_run == 'true' &&
(needs.check-conditions.outputs.target_library == '' ||
needs.check-conditions.outputs.target_library == 'plotly')
uses: ./.github/workflows/gen-library-impl.yml
with:
spec_id: ${{ needs.check-conditions.outputs.spec_id }}
library: plotly
main_issue_number: ${{ github.event.issue.number }}
sub_issue_number: ${{ needs.create-sub-issues.outputs.plotly_issue }}
deps: "plotly>=5.18.0 kaleido>=0.2.1 numpy>=1.26.0"
secrets:
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
generate-bokeh:
needs: [check-conditions, create-sub-issues]
if: |
needs.check-conditions.outputs.should_run == 'true' &&
(needs.check-conditions.outputs.target_library == '' ||
needs.check-conditions.outputs.target_library == 'bokeh')
uses: ./.github/workflows/gen-library-impl.yml
with:
spec_id: ${{ needs.check-conditions.outputs.spec_id }}
library: bokeh
main_issue_number: ${{ github.event.issue.number }}
sub_issue_number: ${{ needs.create-sub-issues.outputs.bokeh_issue }}
deps: "bokeh>=3.4.0 numpy>=1.26.0"
secrets:
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
generate-altair:
needs: [check-conditions, create-sub-issues]
if: |
needs.check-conditions.outputs.should_run == 'true' &&
(needs.check-conditions.outputs.target_library == '' ||
needs.check-conditions.outputs.target_library == 'altair')
uses: ./.github/workflows/gen-library-impl.yml
with:
spec_id: ${{ needs.check-conditions.outputs.spec_id }}
library: altair
main_issue_number: ${{ github.event.issue.number }}
sub_issue_number: ${{ needs.create-sub-issues.outputs.altair_issue }}
deps: "altair>=5.2.0 vl-convert-python>=1.3.0 numpy>=1.26.0"
secrets:
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
generate-plotnine:
needs: [check-conditions, create-sub-issues]
if: |
needs.check-conditions.outputs.should_run == 'true' &&
(needs.check-conditions.outputs.target_library == '' ||
needs.check-conditions.outputs.target_library == 'plotnine')
uses: ./.github/workflows/gen-library-impl.yml
with:
spec_id: ${{ needs.check-conditions.outputs.spec_id }}
library: plotnine
main_issue_number: ${{ github.event.issue.number }}
sub_issue_number: ${{ needs.create-sub-issues.outputs.plotnine_issue }}
deps: "plotnine>=0.13.0 numpy>=1.26.0"
secrets:
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
generate-pygal:
needs: [check-conditions, create-sub-issues]
if: |
needs.check-conditions.outputs.should_run == 'true' &&
(needs.check-conditions.outputs.target_library == '' ||
needs.check-conditions.outputs.target_library == 'pygal')
uses: ./.github/workflows/gen-library-impl.yml
with:
spec_id: ${{ needs.check-conditions.outputs.spec_id }}
library: pygal
main_issue_number: ${{ github.event.issue.number }}
sub_issue_number: ${{ needs.create-sub-issues.outputs.pygal_issue }}
deps: "pygal>=3.0.0 cairosvg>=2.7.0"
secrets:
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
generate-highcharts:
needs: [check-conditions, create-sub-issues]
if: |
needs.check-conditions.outputs.should_run == 'true' &&
(needs.check-conditions.outputs.target_library == '' ||
needs.check-conditions.outputs.target_library == 'highcharts')
uses: ./.github/workflows/gen-library-impl.yml
with:
spec_id: ${{ needs.check-conditions.outputs.spec_id }}
library: highcharts
main_issue_number: ${{ github.event.issue.number }}
sub_issue_number: ${{ needs.create-sub-issues.outputs.highcharts_issue }}
deps: "highcharts-core>=1.10.0 numpy>=1.26.0"
secrets:
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
# ============================================================================
# Step 4: Summary after all generations complete
# ============================================================================
summary:
needs:
- check-conditions
- create-sub-issues
- generate-matplotlib
- generate-seaborn
- generate-plotly
- generate-bokeh
- generate-altair
- generate-plotnine
- generate-pygal
- generate-highcharts
if: always() && needs.check-conditions.outputs.should_run == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Check if summary already posted
id: check_summary
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Check if "Generation Complete" comment already exists (idempotency)
EXISTING=$(gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments \
--jq '[.[] | select(.body | startswith("## Generation Complete"))] | length')
if [ "$EXISTING" -gt "0" ]; then
echo "Summary already posted, skipping"
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
- name: Post summary to main issue
if: steps.check_summary.outputs.skip != 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
SPEC_ID="${{ needs.check-conditions.outputs.spec_id }}"
# Post summary comment
gh issue comment ${{ github.event.issue.number }} --body "## Generation Complete
All 8 library generation jobs have been dispatched for \`$SPEC_ID\`.
### Sub-Issues Created
- matplotlib: #${{ needs.create-sub-issues.outputs.matplotlib_issue }}
- seaborn: #${{ needs.create-sub-issues.outputs.seaborn_issue }}
- plotly: #${{ needs.create-sub-issues.outputs.plotly_issue }}
- bokeh: #${{ needs.create-sub-issues.outputs.bokeh_issue }}
- altair: #${{ needs.create-sub-issues.outputs.altair_issue }}
- plotnine: #${{ needs.create-sub-issues.outputs.plotnine_issue }}
- pygal: #${{ needs.create-sub-issues.outputs.pygal_issue }}
- highcharts: #${{ needs.create-sub-issues.outputs.highcharts_issue }}
### Next Steps
Each library will:
1. Generate implementation code
2. Create a separate PR
3. Run tests
4. Generate preview images
5. Undergo AI quality review
6. Auto-merge if quality score >= 85
Check the **Implementation Status** table above for real-time progress.
---
:robot: *[gen-new-plot workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})*"
- name: Remove in-progress label
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh issue edit ${{ github.event.issue.number }} --remove-label "in-progress" || true