Skip to content

ci: Python emitter regen-diff check (PoC)#5

Draft
l0lawrence wants to merge 1 commit into
mainfrom
l0lawrence/emitter-regen-diff-ci
Draft

ci: Python emitter regen-diff check (PoC)#5
l0lawrence wants to merge 1 commit into
mainfrom
l0lawrence/emitter-regen-diff-ci

Conversation

@l0lawrence

Copy link
Copy Markdown
Owner

What

Proof-of-concept CI check that detects when a change to the Python emitter (packages/http-client-python) alters its generated test code.

On a PR touching packages/http-client-python/**, the workflow:

  1. Regenerates the emitter's generated test code twice — once with the emitter at the PR head, once with the emitter at a pinned baseline commit stored in packages/http-client-python/eng/regen-diff-baseline.txt.
  2. Diffs the two generated trees.
  3. Fails CI if there is any diff.
  4. Uploads a colorized HTML view of the diff as a workflow artifact (python-regen-diff-html).
  5. Posts/updates a PR comment (via the secure workflow_run pattern) linking to the artifact.

If a diff is expected, the author bumps the baseline SHA to accept the new output.

Files

  • packages/http-client-python/eng/regen-diff-baseline.txt — pinned baseline commit SHA.
  • packages/http-client-python/eng/scripts/ci/regen-diff-html.ts — dependency-free reporter (git diff --no-index → HTML + comment payload + result.json).
  • .github/workflows/python-emitter-regen-diff.ymlpull_request: generate (head/base matrix) → diff → fail-on-diff.
  • .github/workflows/python-emitter-regen-diff-comment.ymlworkflow_run: posts the PR comment (works for fork PRs).

Notes / caveats

  • Cost: regenerates twice per PR (full Python setup each time). A follow-up could cache the base regen keyed by the baseline SHA to halve the work.
  • Both regens fetch the same production baseline seed, so it cancels out in the diff; current-date values also cancel since both run in the same CI run (hence no cross-day caching).
  • Proof-of-concept — Python only. A sibling PR ports the same setup to Azure/typespec-azure. Intended to be extended to the csharp/java/js emitters next.

Regenerate the http-client-python generated test code with the emitter at the
PR head and at a pinned baseline commit, diff the two outputs, fail CI on any
diff, and post a PR comment linking to an HTML view of the diff (uploaded as a
workflow artifact).

Adds:
- packages/http-client-python/eng/regen-diff-baseline.txt (pinned baseline SHA)
- packages/http-client-python/eng/scripts/ci/regen-diff-html.ts (diff -> HTML/comment)
- .github/workflows/python-emitter-regen-diff.yml (regen x2 + diff + fail)
- .github/workflows/python-emitter-regen-diff-comment.yml (workflow_run comment)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

❌ There is undocummented changes. Run chronus add to add a changeset or click here.

The following packages have changes but are not documented.

  • @typespec/http-client-python
Show changes

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.

1 participant