-
Notifications
You must be signed in to change notification settings - Fork 0
276 lines (242 loc) · 9.55 KB
/
generate.yml
File metadata and controls
276 lines (242 loc) · 9.55 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
name: Generate (Complete Pipeline)
on:
workflow_dispatch:
inputs:
version:
description: 'CAPI version to process (e.g., 3.195.0)'
required: true
type: string
skip-tests:
description: 'Skip validation tests'
required: false
type: boolean
default: false
workflow_call:
inputs:
version:
required: true
type: string
skip-tests:
required: false
type: boolean
default: false
outputs:
spec-generated:
description: 'Whether the OpenAPI spec was successfully generated'
value: ${{ jobs.generate.outputs.spec-generated }}
sdk-generated:
description: 'Whether the SDK was successfully generated'
value: ${{ jobs.generate.outputs.sdk-generated }}
docs-generated:
description: 'Whether the documentation was successfully generated'
value: ${{ jobs.generate.outputs.docs-generated }}
jobs:
generate:
name: Generate All (make all)
runs-on: ubuntu-latest
outputs:
spec-generated: ${{ steps.spec.outputs.generated }}
sdk-generated: ${{ steps.sdk.outputs.generated }}
docs-generated: ${{ steps.docs.outputs.generated }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
# ============================================
# Dependencies Installation (make deps equivalent)
# ============================================
- name: Set up Perl
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: '5.38'
- name: Install Perl dependencies
run: |
cpanm --quiet --notest JSON::XS YAML::XS Mojo::DOM Mojo::JSON File::Slurp LWP::Simple
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Bun
uses: oven-sh/setup-bun@v2
- name: Install Node dependencies
run: |
bun install -g @redocly/cli @openapitools/openapi-generator-cli
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.4'
- name: Install Go tools
run: |
go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@latest
- name: Install additional tools
run: |
# Install spruce
wget -q https://github.com/geofffranks/spruce/releases/latest/download/spruce-linux-amd64
chmod +x spruce-linux-amd64
sudo mv spruce-linux-amd64 /usr/local/bin/spruce
# Verify installations
echo "Checking dependencies..."
which perl && perl --version
which bun && bun --version
which java && java --version
which go && go version
which oapi-codegen && oapi-codegen --version
which spruce && spruce --version
which redocly && redocly --version
# ============================================
# Step 1: Generate OpenAPI Specification (make spec)
# ============================================
- name: Download HTML documentation (make prepare)
run: |
echo "::group::Downloading HTML documentation"
./bin/gen prepare --version=${{ inputs.version }}
echo "::endgroup::"
- name: Generate OpenAPI specification (make spec)
id: spec
run: |
echo "::group::Generating OpenAPI specification"
./bin/gen spec --version=${{ inputs.version }}
# Check if spec was generated
if [[ -f "capi/${{ inputs.version }}/openapi.json" ]]; then
echo "generated=true" >> $GITHUB_OUTPUT
echo "✅ OpenAPI spec generated successfully"
ls -la capi/${{ inputs.version }}/openapi.*
else
echo "generated=false" >> $GITHUB_OUTPUT
echo "❌ Failed to generate OpenAPI spec"
exit 1
fi
echo "::endgroup::"
# ============================================
# Step 2: Generate SDK (make sdk)
# ============================================
- name: Generate Go SDK (make sdk)
id: sdk
run: |
echo "::group::Generating Go SDK"
./bin/gen sdk --version=${{ inputs.version }} --language=go
# Check if SDK was generated
if [[ -d "sdk/${{ inputs.version }}/go/capiclient" ]]; then
echo "generated=true" >> $GITHUB_OUTPUT
echo "✅ Go SDK generated successfully"
ls -la sdk/${{ inputs.version }}/go/capiclient/
else
echo "generated=false" >> $GITHUB_OUTPUT
echo "❌ Failed to generate Go SDK"
exit 1
fi
echo "::endgroup::"
# ============================================
# Step 3: Generate Documentation (make docs)
# ============================================
- name: Generate API documentation (make docs)
id: docs
run: |
echo "::group::Generating API documentation"
mkdir -p capi/${{ inputs.version }}/docs
# Generate Redocly documentation
redocly build-docs capi/${{ inputs.version }}/openapi.json -o capi/${{ inputs.version }}/docs/index.html
# Check if docs were generated
if [[ -f "capi/${{ inputs.version }}/docs/index.html" ]]; then
echo "generated=true" >> $GITHUB_OUTPUT
echo "✅ Documentation generated successfully"
ls -la capi/${{ inputs.version }}/docs/
else
echo "generated=false" >> $GITHUB_OUTPUT
echo "❌ Failed to generate documentation"
exit 1
fi
echo "::endgroup::"
# ============================================
# Step 4: Run Tests (make test)
# ============================================
- name: Validate OpenAPI specification
if: ${{ !inputs.skip-tests }}
run: |
echo "::group::Validating OpenAPI specification"
./bin/validate-spec --version=${{ inputs.version }}
echo "::endgroup::"
- name: Validate examples
if: ${{ !inputs.skip-tests }}
run: |
echo "::group::Validating examples"
./bin/validate-examples capi/${{ inputs.version }}/openapi.json
echo "::endgroup::"
- name: Test schemas
if: ${{ !inputs.skip-tests }}
run: |
echo "::group::Testing schemas"
./bin/test-schemas --version=${{ inputs.version }}
echo "::endgroup::"
# ============================================
# Upload Artifacts
# ============================================
- name: Upload OpenAPI specification
uses: actions/upload-artifact@v4
with:
name: openapi-spec-${{ inputs.version }}
path: |
capi/${{ inputs.version }}/openapi.json
capi/${{ inputs.version }}/openapi.yaml
retention-days: 30
- name: Upload Go SDK
uses: actions/upload-artifact@v4
with:
name: go-sdk-${{ inputs.version }}
path: sdk/${{ inputs.version }}/go/
retention-days: 30
- name: Upload documentation
uses: actions/upload-artifact@v4
with:
name: api-docs-${{ inputs.version }}
path: capi/${{ inputs.version }}/docs/
retention-days: 30
- name: Upload reports
if: always()
uses: actions/upload-artifact@v4
with:
name: generation-reports-${{ inputs.version }}
path: capi/${{ inputs.version }}/*-report.md
retention-days: 30
# ============================================
# Summary
# ============================================
- name: Generation Summary
if: always()
run: |
echo "## Generation Summary for CAPI ${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Spec status
if [[ "${{ steps.spec.outputs.generated }}" == "true" ]]; then
echo "✅ **OpenAPI Specification**: Generated successfully" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **OpenAPI Specification**: Generation failed" >> $GITHUB_STEP_SUMMARY
fi
# SDK status
if [[ "${{ steps.sdk.outputs.generated }}" == "true" ]]; then
echo "✅ **Go SDK**: Generated successfully" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Go SDK**: Generation failed" >> $GITHUB_STEP_SUMMARY
fi
# Docs status
if [[ "${{ steps.docs.outputs.generated }}" == "true" ]]; then
echo "✅ **API Documentation**: Generated successfully" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **API Documentation**: Generation failed" >> $GITHUB_STEP_SUMMARY
fi
# Test status
if [[ "${{ inputs.skip-tests }}" == "true" ]]; then
echo "⏭️ **Tests**: Skipped" >> $GITHUB_STEP_SUMMARY
else
echo "✅ **Tests**: All validation tests passed" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Artifacts" >> $GITHUB_STEP_SUMMARY
echo "- OpenAPI Specification (JSON/YAML)" >> $GITHUB_STEP_SUMMARY
echo "- Go SDK" >> $GITHUB_STEP_SUMMARY
echo "- API Documentation" >> $GITHUB_STEP_SUMMARY
echo "- Generation Reports" >> $GITHUB_STEP_SUMMARY