-
Notifications
You must be signed in to change notification settings - Fork 61
fix(sdk): sync generator templates with hand-edited SDK output #884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
371aee0
f0a9e8b
181e02d
1c67d92
9c90ebf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| name: SDK Drift Check | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| paths: | ||
| - 'components/ambient-sdk/generator/**' | ||
| - 'components/ambient-sdk/go-sdk/**' | ||
| - 'components/ambient-sdk/python-sdk/**' | ||
| - 'components/ambient-sdk/ts-sdk/**' | ||
| - 'components/ambient-api-server/openapi/**' | ||
| - '.github/workflows/sdk-drift-check.yml' | ||
|
|
||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - 'components/ambient-sdk/generator/**' | ||
| - 'components/ambient-sdk/go-sdk/**' | ||
| - 'components/ambient-sdk/python-sdk/**' | ||
| - 'components/ambient-sdk/ts-sdk/**' | ||
| - 'components/ambient-api-server/openapi/**' | ||
| - '.github/workflows/sdk-drift-check.yml' | ||
|
|
||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: sdk-drift-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| check-drift: | ||
| name: SDK Generator Drift | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: components/ambient-sdk/generator/go.mod | ||
| cache-dependency-path: components/ambient-sdk/generator/go.sum | ||
|
|
||
| - name: Regenerate SDK from OpenAPI spec | ||
| working-directory: components/ambient-sdk/generator | ||
| run: | | ||
| go run . \ | ||
| -spec ../../ambient-api-server/openapi/openapi.yaml \ | ||
| -go-out ../go-sdk \ | ||
| -python-out ../python-sdk/ambient_platform \ | ||
| -ts-out ../ts-sdk | ||
|
|
||
| - name: Run gofmt on generated Go code | ||
| working-directory: components/ambient-sdk/go-sdk | ||
| run: go fmt ./... | ||
|
|
||
| - name: Fix trailing newlines (match pre-commit end-of-file-fixer) | ||
| run: | | ||
| find components/ambient-sdk/go-sdk components/ambient-sdk/python-sdk components/ambient-sdk/ts-sdk \ | ||
| -type f \( -name '*.go' -o -name '*.py' -o -name '*.ts' \) \ | ||
| -exec sed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}' {} + | ||
|
|
||
| - name: Check for drift | ||
| run: | | ||
| # Ignore timestamp and hash lines (they change every run) | ||
| # Patterns cover both // (Go/TS) and # (Python) comment styles | ||
| DRIFT=$(git diff \ | ||
| --ignore-matching-lines='Spec SHA256:' \ | ||
| --ignore-matching-lines='Generated:' \ | ||
| -- components/ambient-sdk/go-sdk/ \ | ||
| components/ambient-sdk/python-sdk/ \ | ||
| components/ambient-sdk/ts-sdk/) | ||
|
|
||
| if [ -n "$DRIFT" ]; then | ||
| echo "❌ SDK drift detected — regenerated code differs from committed code." | ||
| echo "" | ||
| echo "This means either:" | ||
| echo " 1. A generator template was updated but the SDK was not regenerated" | ||
| echo " 2. The OpenAPI spec changed but the SDK was not regenerated" | ||
| echo " 3. Generated files were hand-edited (update the templates instead)" | ||
| echo "" | ||
| echo "Fix: cd components/ambient-sdk && make generate-sdk" | ||
| echo "" | ||
| echo "Diff:" | ||
| echo "$DRIFT" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "✅ No SDK drift detected" | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.