Skip to content

Include diff in spec-drift issue body#39

Merged
splch merged 7 commits intomainfrom
churchill/spec-drift-include-diff
May 6, 2026
Merged

Include diff in spec-drift issue body#39
splch merged 7 commits intomainfrom
churchill/spec-drift-include-diff

Conversation

@splch
Copy link
Copy Markdown
Collaborator

@splch splch commented May 6, 2026

Summary

Today the weekly spec-drift workflow only says "the spec changed upstream" — you have to go fetch and diff it yourself. This PR pastes the diff directly into the issue body so it's visible at a glance.

  • Pretty-print both specs with --sort-keys so cosmetic key reordering can't trip the check.
  • Attach diff -u of the two pretty-printed files inside a collapsed <details> block, truncated at 60 KB (GitHub's body cap is ~64 KB).
  • Update the already-open spec-drift issue on subsequent runs instead of skipping, so the diff always reflects the latest upstream rather than pinning to whichever week drift first appeared.

No change to schedule, label, title, permissions, or anything tests/test_docs_consistency.py asserts.

Also dogfoods the new behavior by refreshing openapi.json from upstream — the only delta is info.description's "Last updated" date (April 23 → April 30, 2026), which is OpenAPI metadata that does not surface in any generated Python, so the regen pipeline produces no changes under ionq_core/. Resolves #38.

Test plan

  • uv run pytest tests/test_docs_consistency.py — 18 passed; the /v0.4/api-docs mentions both consistency tests check are still in the workflow.
  • Workflow YAML re-parses cleanly via yaml.safe_load.
  • Reproduced the body-construction block locally with two divergent JSON files: <details> collapses, fenced ```diff block renders, truncation marker only appears past 60 KB.
  • Re-ran the full regen pipeline from CONTRIBUTING.md against the new openapi.json (oas-patch overlay → openapi-python-client generate); no changes under ionq_core/. uv run ruff check / ruff format --check clean.

Pretty-print both specs with --sort-keys so unrelated key reordering
doesn't trip the check, then attach a unified diff (truncated at 60 KB)
to the issue body inside a <details> block. Update the existing open
issue on subsequent runs so the diff stays current instead of pinning
to whatever week the drift first appeared.
@splch splch requested a review from a team as a code owner May 6, 2026 15:39
- Capture the diff directly in the existing `if ! diff …` (errexit is
  already exempt inside `if`), removing the separate `-q` pre-check,
  the intermediate pretty-printed tempfiles, and the `|| true` workaround.
- Replace the multi-echo body wrapper with two `printf`s and a 1-line
  bash `&&` truncation marker.
- Pass `--label vendored --label upstream` to `diff` so the issue body
  shows meaningful headers instead of `/dev/fd/63`.
@splch
Copy link
Copy Markdown
Collaborator Author

splch commented May 6, 2026

Concrete preview: running this workflow's logic against the live spec right now produces real drift — the API description's Last updated date has bumped from April 23 → April 30. Here is exactly the issue body that would be posted (or used to update the existing spec-drift issue) if the cron ran now:


The spec at api.ionq.co/v0.4/api-docs has diverged from the vendored openapi.json. Fetch the new spec and regenerate the client.

Diff (sorted, pretty-printed JSON)
--- vendored
+++ upstream
@@ -2576,7 +2576,7 @@
             "name": "IonQ",
             "url": "https://ionq.com/"
         },
-        "description": "*Last updated: April 23, 2026*\nIonQ's API for accessing the IonQ Quantum Cloud platform\n\nPlease subscribe for automated updates when we perform maintenance or\nexperience an outage.\n\nIn addition, you may use the [status endpoint](#tag/status) to check the\ncurrent status of our API.\n\n## Authentication\n\n<SecurityDefinitions />\n",
+        "description": "*Last updated: April 30, 2026*\nIonQ's API for accessing the IonQ Quantum Cloud platform\n\nPlease subscribe for automated updates when we perform maintenance or\nexperience an outage.\n\nIn addition, you may use the [status endpoint](#tag/status) to check the\ncurrent status of our API.\n\n## Authentication\n\n<SecurityDefinitions />\n",
         "title": "IonQ Cloud Platform API",
         "version": "v0.4"
     },

Body size: 1158 bytes (cap is 65 536; head -c 60000 truncation engages well before the GitHub API rejects it).

guenp
guenp previously approved these changes May 6, 2026
Copy link
Copy Markdown
Collaborator

@guenp guenp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one minor comment, looks good otherwise!

should the v0.4 version be stored as a variable somewhere instead of hard-coded here?

Only `info.description` changed ("Last updated: April 23, 2026" →
"April 30, 2026"); the field is OpenAPI metadata that does not surface
in any generated Python, so re-running the regen pipeline produces no
changes under `ionq_core/`. The upstream-sorted diff matches the
preview posted on this PR.

Resolves #38.
splch added 4 commits May 6, 2026 09:10
`linguist-vendored=true` only excludes a file from repo language
statistics; it does not suppress diffs in PRs (see github-linguist's
`generated.rb` and github-linguist/linguist#3234). Add
`linguist-generated=true` so reviewers see openapi.json collapsed by
default — the spec is fetched from upstream by the regen pipeline and
isn't intended for line-by-line review (the actual semantic diff lives
in the spec-drift issue body now).
@splch splch merged commit d15bb11 into main May 6, 2026
12 checks passed
@splch splch deleted the churchill/spec-drift-include-diff branch May 6, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAPI spec has changed upstream

2 participants