Skip to content

Testing - #4

Draft
l0lawrence wants to merge 18 commits into
l0lawrence/python-regen-html-difffrom
testing
Draft

l0lawrence wants to merge 18 commits into
l0lawrence/python-regen-html-difffrom
testing

Conversation

@l0lawrence

Copy link
Copy Markdown
Owner

No description provided.

@l0lawrence l0lawrence closed this Jun 23, 2026
@l0lawrence l0lawrence reopened this Jun 23, 2026
@github-actions

github-actions Bot commented Jun 23, 2026 •

Copy link
Copy Markdown

🐍 Python emitter — generated test diff

195 files changed · +195 / -0

👉 View the rendered HTML diff

👇 This PR changes generated output — update the baseline

Review the rendered diff above. If the changes are expected, refresh the
baseline and pin the new tag so it ships with this PR:

cd packages/http-client-python
npm run regenerate            # produce fresh generated output
npm run regenerate:push-assets  # publish baseline + bump assets.json

Then commit the updated packages/http-client-python/assets.json (its
Tag now points at the new baseline). Pushing it makes this check pass
with 0 differences.

Baseline tag: `python/tests_481763e148` · updated for the latest commit. Re-runs of CI refresh this preview.

github-actions Bot added a commit that referenced this pull request Jun 23, 2026
github-actions Bot added a commit that referenced this pull request Jun 23, 2026
github-actions Bot added a commit that referenced this pull request Jun 23, 2026
github-actions Bot added a commit that referenced this pull request Jun 23, 2026
l0lawrence and others added 3 commits June 23, 2026 13:14
# Conflicts:
#	packages/http-client-python/eng/scripts/ci/regenerate-common.ts
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 23, 2026
github-actions Bot added a commit that referenced this pull request Jun 23, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 23, 2026
git diff --no-index prefixes each path with baseline/ vs current/, so
diff2html mistook every file for a rename ({baseline -> current}). Strip
those temp-dir prefixes from the per-file chunk header so old == new path
and it renders as a normal modification.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions Bot added a commit that referenced this pull request Jun 23, 2026
l0lawrence and others added 4 commits June 23, 2026 15:47
Add a --open flag that prints a clickable file:// URL and opens the
rendered diff in the default browser, plus two npm scripts:
  - regenerate:diff     render the diff and open it
  - regenerate:review   regenerate then render+open
so contributors get the same grouped HTML diff locally, no PR/CI needed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
tests/**/generated is git-ignored, so the regenerated output never shows
in VS Code Source Control. Add a --vscode mode that restores the
assets-tag baseline, persists both normalized trees to temp/diff-trees,
and opens a native 'code --diff' editor per changed file (capped via
--max). New regenerate:vscode-diff script.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Extract the Python-specific regen-diff baseline + HTML-diff PR-preview
system into a self-contained, language-agnostic tool under
eng/common/scripts/regen-diff (render + push-assets CLI driven by a
per-package regen-diff.config.json). Convert the Python emitter to use it
as the reference adopter and generalize the publish/cleanup workflows so a
single pair serves every emitter language (slug-namespaced gh-pages
previews, sticky comment, and regen-diff/<slug> commit status). Adds an
onboarding README.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the diff2html dependency with a small built-in renderer that emits
a line-numbered, colorized unified diff per file, so the shared tool has no
runtime rendering dependency (only picocolors remains). Rename the emitted
stylesheet diff2html.css -> styles.css and update the publish allowlist.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@l0lawrence
l0lawrence requested a lite review from Copilot September 16, 2026 15:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Critical workflow, security, path-validation, and build issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR centralizes generated-test diff rendering and baseline publishing into a shared tool, integrating the Python package.

Changes:

  • Adds shared config-driven rendering, asset, and CLI tooling.
  • Updates Python templates, packaging, scripts, and baseline configuration.
  • Replaces Python-specific publishing and cleanup workflows.
File summaries
File Description
packages/http-client-python/regen-diff.config.json Python diff configuration
packages/http-client-python/package.json Shared diff scripts and dependencies
packages/http-client-python/generator/pygen/codegen/templates/version.py.jinja2 Generated-file marker
packages/http-client-python/generator/pygen/codegen/templates/packaging_templates/pyproject.toml.jinja2 Packaging version configuration
packages/http-client-python/assets.json Baseline tag configuration
eng/common/scripts/regen-diff/tsconfig.json Shared tool TypeScript configuration
eng/common/scripts/regen-diff/src/render-diff.ts Diff rendering implementation
eng/common/scripts/regen-diff/src/push-assets.ts Baseline publishing implementation
eng/common/scripts/regen-diff/src/config.ts Configuration loading and validation
eng/common/scripts/regen-diff/src/cli.ts Shared CLI
eng/common/scripts/regen-diff/src/assets.ts Baseline asset helpers
eng/common/scripts/regen-diff/README.md Tool documentation
eng/common/scripts/regen-diff/package.json Shared tool package definition
.github/workflows/regen-diff-publish.yml Shared preview publishing workflow
.github/workflows/regen-diff-cleanup.yml Preview cleanup workflow
.github/workflows/python-regen-diff.yml Python workflow integration
.github/workflows/python-regen-diff-publish.yml Python-specific publisher removal
Review details

Suppressed comments (6)

eng/common/scripts/regen-diff/README.md:57

  • This claims the tool has a package-lock.json, but none is present in this package and CI explicitly runs npm install --no-package-lock. The shared CI tool therefore resolves semver ranges afresh on every run, which makes previews non-reproducible; either commit/use the lockfile with npm ci, or document that the tool intentionally has no lockfile.
The tool has its own `package.json`/`package-lock.json`, so it is **independent
of the consuming package's package manager** (npm, pnpm, …). Install its deps once with `npm install` in this directory before running it.

eng/common/scripts/regen-diff/src/push-assets.ts:145

  • flavors: ["."] is explicitly documented for flat outputs. When AssetsRepoPrefixPath is empty, prefixRoot === tempDir, so this destination is the temporary git repository itself; rmSync(dest) deletes .git, and the subsequent git add/commit fails. Preserve the repository metadata while replacing the root contents, or reject this configuration.
    eng/common/scripts/regen-diff/src/render-diff.ts:330
  • These paths are interpolated into a shell command. Double quotes do not prevent $() or backtick expansion, and the relative names come from changed generated files, so running --vscode on a crafted PR can execute commands on the maintainer's machine. Invoke code with an argument array (using a Windows-specific executable when needed) rather than constructing a shell string.
    eng/common/scripts/regen-diff/src/render-diff.ts:14
  • The implementation now uses renderUnifiedDiff to produce a unified, line-numbered page, and the diff2html dependency was removed from the renderer. This output description is therefore inaccurate and will mislead users about the generated pages.
    eng/common/scripts/regen-diff/src/render-diff.ts:630
  • Once a hunk has started, an added line whose content begins with +++ (or a removed line beginning --- ) still matches this metadata branch. It is rendered without add/delete styling and its line counter is not advanced, so subsequent line numbers are wrong; only classify these prefixes as metadata before the first @@ hunk header.
    packages/http-client-python/package.json:56
  • After these scripts switch rendering to the self-contained shared tool, diff2html is no longer imported anywhere under this package but remains in its dependencies and lockfile. Keeping it adds an unused install and contradicts the zero-rendering-dependency migration; remove the package dependency and lockfile entry.
    "regenerate:push-assets": "tsx ../../eng/common/scripts/regen-diff/src/cli.ts push-assets --package .",
    "regenerate:render-diff": "tsx ../../eng/common/scripts/regen-diff/src/cli.ts render --package .",
    "regenerate:diff": "tsx ../../eng/common/scripts/regen-diff/src/cli.ts render --package . --open",
    "regenerate:vscode-diff": "tsx ../../eng/common/scripts/regen-diff/src/cli.ts render --package . --vscode",
  • Files reviewed: 17/17 changed files
  • Comments generated: 8
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +54 to +63
if [ ! -f diff-site/pr.txt ]; then
echo "No pr.txt in artifact; nothing to publish."
echo "pr=" >> "$GITHUB_OUTPUT"
exit 0
fi
PR="$(tr -d '[:space:]' < diff-site/pr.txt)"
if ! printf '%s' "$PR" | grep -Eq '^[0-9]+$'; then
echo "::error::pr.txt is not a positive integer: '$PR'"
exit 1
fi
Comment on lines +94 to +98
# Allowlist the rendered output (no arbitrary files from the artifact)
# so a fork PR cannot host unexpected content on the *.github.io origin.
cp diff-site/index.html "$dest/" 2>/dev/null || true
cp diff-site/styles.css "$dest/" 2>/dev/null || true
cp diff-site/summary.json "$dest/" 2>/dev/null || true
await github.rest.repos.createCommitStatus({
owner, repo, sha: process.env.SHA,
context: `regen-diff/${slug}`,
state: summary.changed ? 'failure' : 'success',
}

main().catch((err) => {
console.error(pc.red(`Fatal error: ${err?.stack ?? err}`));
Comment on lines +70 to +74
const flavors = Array.isArray(raw.flavors) ? raw.flavors.map((f) => String(f)) : [];
if (flavors.length === 0) {
throw new Error(`regen-diff.config.json: "flavors" must be a non-empty array of folder names.`);
}

Comment on lines +75 to +77
const pruneFilePrefixes = Array.isArray(raw.pruneFilePrefixes)
? raw.pruneFilePrefixes.map((p) => String(p))
: [];
Comment on lines +64 to +66
- name: Install regen-diff tool
working-directory: eng/common/scripts/regen-diff
run: npm install --no-package-lock
actions: read

concurrency:
group: regen-diff-publish-${{ github.event.workflow_run.id }}

This branch has not been deployed

No deployments
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.

2 participants