-
Notifications
You must be signed in to change notification settings - Fork 16
Replace spec-drift issues with an auto-merging weekly regeneration PR #101
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a8618ad
Replace spec-drift issues with an auto-merging weekly regeneration PR
splch 654ff37
Shorten spec-sync workflow, policy, and docs
splch cea0db7
Poll for required checks before watching; exempt sync PRs from CHANGELOG
splch 224dd38
Add a self-reverting x- key to openapi.json so the first spec-sync ru…
splch 7f6d170
Remove stray empty npm files committed by mistake
splch d8be14e
Pin exact version comments so zizmor ref-version-mismatch survives up…
splch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # spec-sync opens the weekly OpenAPI-regeneration PR and merges it into this repo only, | ||
| # holding no key. Pattern: self-modify in ionq-actions/octo-sts/docs/patterns/release-please.md. | ||
| issuer: https://token.actions.githubusercontent.com | ||
| # Name and immutable-ID subject forms; ionq=25356822, ionq-core-python=1204464907. | ||
| subject_pattern: "^repo:(ionq/ionq-core-python|[^/@]+@25356822/[^/@:]+@1204464907):ref:refs/heads/main$" | ||
| claim_pattern: | ||
| enterprise: "^ionq$" | ||
| permissions: | ||
| contents: write | ||
| pull_requests: write | ||
| issues: write # PR labels ride the issues API |
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
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
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| name: Spec sync | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "0 9 * * 1" | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: spec-sync | ||
| cancel-in-progress: false | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| sync: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| - name: Check for drift | ||
| id: drift | ||
| run: | | ||
| BASE_URL=$(jq -r '.servers[0].url' openapi.json) | ||
| curl -sf "${BASE_URL}/api-docs" -o /tmp/latest-spec.json | ||
| norm() { jq -S 'del(.info.description)' "$1"; } | ||
| if ! diff -u --label vendored --label upstream <(norm openapi.json) <(norm /tmp/latest-spec.json) > /tmp/spec.diff; then | ||
| echo "drifted=true" >> "$GITHUB_OUTPUT" | ||
| { | ||
| echo "Weekly sync of \`openapi.json\` with ${BASE_URL}/api-docs and client regeneration. Merges automatically once all required checks pass." | ||
| printf '\n<details><summary>Diff (sorted, pretty-printed JSON)</summary>\n\n```diff\n' | ||
| head -c 60000 /tmp/spec.diff | ||
| [[ $(wc -c < /tmp/spec.diff) -gt 60000 ]] && printf '\n... (truncated)\n' | ||
| printf '```\n</details>\n' | ||
| } > /tmp/pr-body.md | ||
| fi | ||
| - if: steps.drift.outputs.drifted == 'true' | ||
| uses: ./.github/actions/setup-uv | ||
| - name: Regenerate client | ||
| if: steps.drift.outputs.drifted == 'true' | ||
| run: | | ||
| cp /tmp/latest-spec.json openapi.json | ||
| uv sync --group regen | ||
| uv run oas-patch overlay openapi.json openapi-overlay.yaml -o /tmp/patched-spec.json | ||
| uv run openapi-python-client generate \ | ||
| --path /tmp/patched-spec.json \ | ||
| --meta none \ | ||
| --config openapi-python-client-config.yaml \ | ||
| --custom-template-path custom-templates \ | ||
| --output-path ionq_core \ | ||
| --overwrite | ||
| - name: Mint token | ||
| if: steps.drift.outputs.drifted == 'true' | ||
| id: sts | ||
| uses: octo-sts/action@f603d3be9d8dd9871a265776e625a27b00effe05 # v1.1.1 | ||
| with: | ||
| domain: octo-sts.gh.ionq.co | ||
| scope: ${{ github.repository }} | ||
| identity: spec-sync | ||
| - name: Create or update PR | ||
| if: steps.drift.outputs.drifted == 'true' | ||
| id: pr | ||
| uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 | ||
| with: | ||
| token: ${{ steps.sts.outputs.token }} | ||
| add-paths: | | ||
| openapi.json | ||
| ionq_core | ||
| branch: spec-sync | ||
| commit-message: Sync OpenAPI spec with upstream | ||
| title: Sync OpenAPI spec with upstream | ||
| body-path: /tmp/pr-body.md | ||
| labels: spec-drift | ||
| sign-commits: true | ||
| delete-branch: true | ||
| - name: Merge once checks pass | ||
| if: steps.pr.outputs.pull-request-number | ||
| env: | ||
| GH_TOKEN: ${{ steps.sts.outputs.token }} | ||
| PR: ${{ steps.pr.outputs.pull-request-number }} | ||
| run: | | ||
| # Poll until required check runs attach; gh errors instead of waiting when none are reported yet. | ||
| for _ in $(seq 30); do gh pr checks "$PR" --required --json name >/dev/null 2>&1 && break; sleep 10; done | ||
| gh pr checks "$PR" --required --watch --fail-fast | ||
| gh pr merge "$PR" --squash --admin | ||
|
antalszava marked this conversation as resolved.
|
||
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.