Skip to content

Commit 2872ea4

Browse files
committed
Major refactoring: automated CAPI OpenAPI spec generation from HTML spec
This commit introduces a complete overhaul of the OpenAPI specification generation process, moving from manual YAML maintenance ('curateion' 🤪) to automated extraction from CAPI HTML documentation. Key changes: - Added Perl-based HTML parsing infrastructure for extracting API schemas - Implemented test suite with initial edge case handling - Generated documentation covering the generation toolchain and process - Introduced automated validation, enhancement, and error fixing scripts - Added support for multiple SDK language generation - Restructured project to support versioned specifications - Removed incomplete 3.181.0 spec work in favor of generated 3.195.0 - Added GitHub Actions workflows for CI/CD, monitoring, and SDK generation The new system automatically: - Parses CAPI HTML docs to extract endpoints, schemas, and examples - Generates valid OpenAPI 3.1.1 specifications - Validates and enhances specs with proper types and constraints - Generates client SDKs for multiple languages - Monitors CAPI releases for updates
1 parent 6110c0a commit 2872ea4

File tree

109 files changed

+60580
-52821
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+60580
-52821
lines changed

.github/workflows/README.md

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
# GitHub Actions Workflows
2+
3+
This directory contains automated workflows for the CAPI OpenAPI specification project.
4+
5+
## Workflow Architecture
6+
7+
The workflows are organized into a clear hierarchy that mirrors the `make all` pipeline:
8+
9+
### Core Workflows
10+
11+
#### 1. Generate (`generate.yml`) - Complete Pipeline
12+
13+
**Purpose**: Primary workflow that mirrors the `make all` command, providing the complete generation pipeline.
14+
15+
**Triggers**:
16+
- Manual dispatch with version input
17+
- Called by other workflows (reusable)
18+
19+
**Pipeline Steps** (matches `make all`):
20+
1. **Dependencies**: Install Perl, Node.js, Java, Go 1.24.4 tools
21+
2. **Spec Generation**:
22+
- Download HTML documentation (`make prepare`)
23+
- Generate OpenAPI specification (`make spec`)
24+
3. **SDK Generation**: Generate Go SDK using oapi-codegen (`make sdk`)
25+
4. **Documentation**: Generate API documentation with Redocly (`make docs`)
26+
5. **Testing**: Validate spec, examples, and schemas (`make test`)
27+
28+
**Outputs**:
29+
- OpenAPI specification (JSON/YAML)
30+
- Go SDK
31+
- API documentation
32+
- Generation reports
33+
34+
**Usage**:
35+
```bash
36+
# Manual trigger via GitHub UI
37+
# Go to Actions > Generate (Complete Pipeline) > Run workflow
38+
# Enter version: 3.195.0
39+
```
40+
41+
#### 2. Test Comprehensive (`test-comprehensive.yml`)
42+
43+
**Purpose**: Consolidated testing for specifications and SDKs.
44+
45+
**Triggers**:
46+
- Pull requests (automatic)
47+
- Manual dispatch
48+
- Called by other workflows
49+
50+
**Test Suite**:
51+
- OpenAPI specification validation (Spectral, Redocly)
52+
- Example validation
53+
- Schema testing
54+
- Multi-language SDK generation testing (Go, Python, Java, TypeScript, Ruby)
55+
- Integration tests
56+
57+
**Features**:
58+
- Automatic PR comments with results
59+
- Parallel testing across languages
60+
- Artifact uploads for generated SDKs
61+
62+
### Automation Workflows
63+
64+
#### 3. Check and Generate (`check-and-generate.yml`)
65+
66+
**Purpose**: Daily automation to check for updates and generate new versions.
67+
68+
**Triggers**:
69+
- Daily schedule (2 AM UTC)
70+
- Manual dispatch with dry-run option
71+
72+
**Process**:
73+
1. Check for new CAPI releases on GitHub
74+
2. Generate specs and SDKs for new versions
75+
3. Run comprehensive tests
76+
4. Create pull requests automatically
77+
5. Create/update tracking issue
78+
79+
**Features**:
80+
- Dry-run mode for testing
81+
- Automatic PR creation with full details
82+
- Issue tracking for updates
83+
- Batch processing of multiple versions
84+
85+
#### 4. Monitor Releases (`monitor-releases.yml`)
86+
87+
**Purpose**: Hourly monitoring with notifications.
88+
89+
**Triggers**:
90+
- Hourly schedule
91+
- Manual dispatch
92+
93+
**Features**:
94+
- Creates GitHub issues for new releases
95+
- Triggers generation workflow
96+
- Sends Slack notifications (if configured)
97+
- Maintains state to avoid duplicates
98+
99+
### Publishing Workflow
100+
101+
#### 5. Publish Go Client (`publish-go-client.yml`)
102+
103+
**Purpose**: Publish Go SDK to the separate capi-openapi-go-client repository.
104+
105+
**Triggers**:
106+
- Manual dispatch with version and force options
107+
108+
**Process**:
109+
1. Uses `generate.yml` workflow to create spec and SDK
110+
2. Downloads generated artifacts
111+
3. Clones target repository
112+
4. Updates with new SDK code
113+
5. Creates version tag and GitHub release
114+
6. Uses Go 1.24.4 (latest stable)
115+
116+
**Target Repository**: [cloudfoundry-community/capi-openapi-go-client](https://github.com/cloudfoundry-community/capi-openapi-go-client)
117+
118+
### Deprecated Workflows
119+
120+
The following workflows are deprecated but kept for backwards compatibility:
121+
122+
- **`test-sdks.yml`**: Redirects to `test-comprehensive.yml`
123+
- **`validate-pr.yml`**: Redirects to `test-comprehensive.yml`
124+
- **`generate-spec.yml`**: Removed (replaced by `generate.yml`)
125+
- **`check-updates.yml`**: Removed (replaced by `check-and-generate.yml`)
126+
127+
## Workflow Dependencies
128+
129+
```mermaid
130+
graph TD
131+
A[check-and-generate.yml] --> B[generate.yml]
132+
C[monitor-releases.yml] --> B
133+
B --> D[test-comprehensive.yml]
134+
D --> E[Create PR]
135+
F[publish-go-client.yml] --> B
136+
F --> G[capi-openapi-go-client repo]
137+
H[Pull Request] --> D
138+
139+
B -.->|artifacts| F
140+
141+
style B fill:#f9f,stroke:#333,stroke-width:4px
142+
style D fill:#bbf,stroke:#333,stroke-width:2px
143+
```
144+
145+
## Configuration
146+
147+
### Required Secrets
148+
149+
- `GITHUB_TOKEN`: Automatically provided by GitHub Actions
150+
- `CAPI_GO_CLIENT_DEPLOY_KEY`: SSH key for pushing to go client repo
151+
- `SLACK_WEBHOOK`: (Optional) For Slack notifications
152+
153+
### Environment Variables
154+
155+
- `CAPI_VERSION`: Default version to process
156+
- `PR_REVIEWERS`: Comma-separated list of reviewers for auto-created PRs
157+
158+
## Workflow Execution Flow
159+
160+
### Automated Daily Flow
161+
1. `check-and-generate.yml` runs daily at 2 AM UTC
162+
2. If new versions found:
163+
- Calls `generate.yml` for each version
164+
- Runs `test-comprehensive.yml`
165+
- Creates pull requests
166+
- Updates tracking issue
167+
168+
### Manual Publishing Flow
169+
1. Merge PR with new CAPI version
170+
2. Run `publish-go-client.yml` manually
171+
3. Go client published to separate repository
172+
4. GitHub release created automatically
173+
174+
### PR Validation Flow
175+
1. Developer creates PR with changes
176+
2. `test-comprehensive.yml` runs automatically
177+
3. Results commented on PR
178+
4. All tests must pass before merge
179+
180+
## Manual Intervention
181+
182+
### When Updates Are Detected
183+
1. Review the automatically created PR
184+
2. Check the test results in the PR
185+
3. Review breaking changes if any
186+
4. Merge the PR after validation
187+
5. Run publish workflow if needed
188+
189+
### Failed Workflows
190+
1. Check workflow logs for errors
191+
2. Common issues:
192+
- Dependency installation failures
193+
- Network timeouts downloading specs
194+
- Validation errors in generated specs
195+
- SDK generation failures
196+
3. Re-run failed jobs or trigger manually
197+
198+
## Local Testing
199+
200+
To test workflows locally, use [act](https://github.com/nektos/act):
201+
202+
```bash
203+
# Test generation workflow
204+
act workflow_dispatch -j generate -s GITHUB_TOKEN=$GITHUB_TOKEN
205+
206+
# Test PR validation
207+
act pull_request -j test-comprehensive
208+
209+
# Test publishing (dry run)
210+
act workflow_dispatch -j publish --dry-run
211+
```
212+
213+
## Maintenance
214+
215+
### Updating Dependencies
216+
- Go version: Update to latest stable in all workflows (currently 1.24.4)
217+
- Perl version: Update in `shogo82148/actions-setup-perl@v1`
218+
- Node.js version: Update in `actions/setup-node@v4`
219+
- Java version: Update in `actions/setup-java@v4`
220+
221+
### Adding New Languages for SDK Testing
222+
1. Add to matrix in `test-comprehensive.yml`
223+
2. Add language-specific setup steps
224+
3. Add compilation/test commands
225+
4. Update this documentation
226+
227+
### Changing Schedules
228+
Edit cron expressions in workflow files:
229+
- Daily automation: `0 2 * * *` (2 AM UTC)
230+
- Hourly monitoring: `0 * * * *` (every hour)
231+
232+
See [crontab.guru](https://crontab.guru/) for help with cron syntax.
233+
234+
## Best Practices
235+
236+
1. **Version Management**: Always specify explicit versions when triggering workflows
237+
2. **Testing**: All PRs are automatically tested via `test-comprehensive.yml`
238+
3. **Monitoring**: Two-tier monitoring (hourly + daily) ensures quick detection
239+
4. **Dependencies**: Workflows use latest stable versions (Go 1.24.4)
240+
5. **Artifacts**: All generated files preserved for 30 days
241+
6. **Reusability**: Core workflows designed to be called by others
242+
7. **Idempotency**: Workflows can be safely re-run without side effects

0 commit comments

Comments
 (0)