-
Notifications
You must be signed in to change notification settings - Fork 0
222 lines (197 loc) · 7.33 KB
/
bulk-generate.yml
File metadata and controls
222 lines (197 loc) · 7.33 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
name: "Bulk: Generate"
run-name: "Bulk: ${{ inputs.library }} for ${{ inputs.specification_id }}"
# Dispatches multiple implementation workflows
# Use for bulk operations like "update all matplotlib" or "generate all for spec"
on:
workflow_dispatch:
inputs:
specification_id:
description: "Specification ID (or 'all' for all specs)"
required: true
type: string
default: 'all'
library:
description: "Library to generate (or 'all' for all libraries)"
required: true
type: choice
default: 'all'
options:
- all
- matplotlib
- seaborn
- plotly
- bokeh
- altair
- plotnine
- pygal
- highcharts
- letsplot
dry_run:
description: "List what would be generated without executing"
type: boolean
default: false
env:
ALL_LIBRARIES: "matplotlib seaborn plotly bokeh altair plotnine pygal highcharts letsplot"
jobs:
# ============================================================================
# Build matrix of (spec, library) pairs to generate
# ============================================================================
build-matrix:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
matrix: ${{ steps.build.outputs.matrix }}
count: ${{ steps.build.outputs.count }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Build generation matrix
id: build
env:
SPEC_INPUT: ${{ inputs.specification_id }}
LIBRARY_INPUT: ${{ inputs.library }}
run: |
# Get list of specifications
if [ "$SPEC_INPUT" == "all" ]; then
SPECS=$(ls -d plots/*/ 2>/dev/null | xargs -I{} basename {} | tr '\n' ' ')
else
SPECS="$SPEC_INPUT"
fi
# Get list of libraries
if [ "$LIBRARY_INPUT" == "all" ]; then
LIBRARIES="$ALL_LIBRARIES"
else
LIBRARIES="$LIBRARY_INPUT"
fi
# Build matrix JSON
MATRIX='{"include":['
FIRST=true
COUNT=0
for SPEC in $SPECS; do
# Skip if specification.md doesn't exist
if [ ! -f "plots/${SPEC}/specification.md" ]; then
echo "::warning::Skipping ${SPEC} - no specification.md found"
continue
fi
for LIB in $LIBRARIES; do
if [ "$FIRST" = true ]; then
FIRST=false
else
MATRIX="${MATRIX},"
fi
MATRIX="${MATRIX}{\"specification_id\":\"${SPEC}\",\"library\":\"${LIB}\"}"
COUNT=$((COUNT + 1))
done
done
MATRIX="${MATRIX}]}"
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
echo "count=$COUNT" >> $GITHUB_OUTPUT
echo "Generated matrix with $COUNT items:"
echo "$MATRIX" | jq .
# ============================================================================
# Display what will be generated (for review)
# ============================================================================
preview:
needs: build-matrix
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Preview generation plan
env:
MATRIX: ${{ needs.build-matrix.outputs.matrix }}
COUNT: ${{ needs.build-matrix.outputs.count }}
DRY_RUN: ${{ inputs.dry_run }}
run: |
echo "## Bulk Generation Plan"
echo ""
echo "**Total items:** $COUNT"
echo "**Concurrency:** max 3 parallel"
echo "**Dry run:** $DRY_RUN"
echo ""
echo "### Items to generate:"
echo "$MATRIX" | jq -r '.include[] | "- \(.specification_id) / \(.library)"'
# ============================================================================
# Generate implementations (max 3 parallel)
# ============================================================================
generate:
needs: [build-matrix, preview]
if: inputs.dry_run == false && needs.build-matrix.outputs.count != '0'
runs-on: ubuntu-latest
permissions:
contents: read
actions: write
strategy:
matrix: ${{ fromJson(needs.build-matrix.outputs.matrix) }}
max-parallel: 3
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
sparse-checkout: |
plots/${{ matrix.specification_id }}/specification.yaml
- name: Read issue number from specification.yaml
id: spec
run: |
SPEC_YAML="plots/${{ matrix.specification_id }}/specification.yaml"
if [ -f "$SPEC_YAML" ]; then
# Extract issue number using yq for robust YAML parsing
ISSUE=$(yq '.issue' "$SPEC_YAML" 2>/dev/null || echo "")
if [ -n "$ISSUE" ] && [ "$ISSUE" != "null" ]; then
echo "issue_number=$ISSUE" >> $GITHUB_OUTPUT
echo "::notice::Found issue #$ISSUE for ${{ matrix.specification_id }}"
else
echo "issue_number=" >> $GITHUB_OUTPUT
echo "::warning::No issue number in $SPEC_YAML"
fi
else
echo "issue_number=" >> $GITHUB_OUTPUT
echo "::warning::$SPEC_YAML not found"
fi
- name: Trigger impl-generate for ${{ matrix.specification_id }} / ${{ matrix.library }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE: ${{ steps.spec.outputs.issue_number }}
run: |
echo "Triggering impl-generate.yml for ${{ matrix.specification_id }} / ${{ matrix.library }}"
# Run workflow with optional issue_number (avoid eval for security)
if [ -n "$ISSUE" ]; then
gh workflow run impl-generate.yml --repo ${{ github.repository }} \
-f specification_id="${{ matrix.specification_id }}" \
-f library="${{ matrix.library }}" \
-f issue_number="$ISSUE"
else
gh workflow run impl-generate.yml --repo ${{ github.repository }} \
-f specification_id="${{ matrix.specification_id }}" \
-f library="${{ matrix.library }}"
fi
echo "::notice::Dispatched impl-generate for ${{ matrix.specification_id }} / ${{ matrix.library }} (issue: ${ISSUE:-none})"
# ============================================================================
# Summary
# ============================================================================
summary:
needs: [build-matrix, generate]
if: always()
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Post summary
env:
COUNT: ${{ needs.build-matrix.outputs.count }}
DRY_RUN: ${{ inputs.dry_run }}
GENERATE_RESULT: ${{ needs.generate.result }}
run: |
echo "## Bulk Generation Complete"
echo ""
echo "**Total dispatched:** $COUNT"
if [ "$DRY_RUN" == "true" ]; then
echo "**Mode:** Dry run (no workflows triggered)"
else
echo "**Mode:** Live execution"
echo "**Generate job result:** $GENERATE_RESULT"
fi
echo ""
echo "Check the Actions tab for individual impl-generate workflow runs."