Regenerate Client from API Spec #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Regenerate Client from API Spec | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| spec_version: | |
| description: 'API Spec Version' | |
| required: true | |
| type: string | |
| spec_commit: | |
| description: 'Devgraph commit SHA that triggered this' | |
| required: true | |
| type: string | |
| # Optional: Also trigger on schedule to check for missed updates | |
| schedule: | |
| - cron: '0 2 * * *' # Daily at 2am UTC | |
| jobs: | |
| regenerate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install Poetry | |
| uses: snok/install-poetry@v1 | |
| with: | |
| version: 1.7.1 | |
| virtualenvs-create: true | |
| virtualenvs-in-project: true | |
| - name: Download API spec | |
| run: | | |
| mkdir -p specs | |
| curl -o specs/openapi.yaml \ | |
| https://raw.githubusercontent.com/arctir/devgraph-api/v${{ inputs.spec_version }}/v1/spec.yaml | |
| echo "✓ Downloaded API spec v${{ inputs.spec_version }}" | |
| - name: Generate Python client | |
| run: | | |
| # Install openapi-python-client | |
| pip install openapi-python-client | |
| # Generate client (overwrite existing) | |
| openapi-python-client generate \ | |
| --path specs/openapi.yaml \ | |
| --output-path . \ | |
| --config openapi-generator-config.yaml \ | |
| --overwrite | |
| echo "✓ Client generated" | |
| - name: Install dependencies | |
| run: | | |
| poetry install --no-interaction | |
| - name: Run linting | |
| run: | | |
| poetry run ruff check src/ || true | |
| poetry run mypy src/ || true | |
| - name: Run tests | |
| run: | | |
| poetry run pytest tests/ -v || echo "⚠️ Tests failed - review in PR" | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| token: ${{ secrets.ARCTIR_GH_ACTIONS_TOKEN }} | |
| commit-message: | | |
| Update client for API v${{ inputs.spec_version }} | |
| Auto-generated from devgraph@${{ inputs.spec_commit }} | |
| branch: api-update-${{ inputs.spec_version }} | |
| delete-branch: true | |
| title: "Update client for API v${{ inputs.spec_version }}" | |
| body: | | |
| ## API Spec Update | |
| - **API Version**: `${{ inputs.spec_version }}` | |
| - **Source Commit**: [${{ inputs.spec_commit }}](https://github.com/arctir/devgraph/commit/${{ inputs.spec_commit }}) | |
| - **Spec URL**: https://github.com/arctir/devgraph-api/tree/v${{ inputs.spec_version }} | |
| This PR was automatically generated when the API spec was updated. | |
| ### Checklist | |
| - [ ] Review generated code changes | |
| - [ ] Verify tests pass | |
| - [ ] Check for breaking changes | |
| - [ ] Update client version in `pyproject.toml` if needed | |
| - [ ] Update CHANGELOG.md | |
| ### Testing | |
| ```bash | |
| poetry install | |
| poetry run pytest | |
| ``` | |
| --- | |
| 🤖 Auto-generated by [regenerate-client workflow](https://github.com/arctir/devgraph-python-client/actions) | |
| labels: | | |
| automated | |
| api-update |