Repository navigation
Testing - #4
Testing#4l0lawrence wants to merge 18 commits into
Conversation
🐍 Python emitter — generated test diff195 files changed · 👇 This PR changes generated output — update the baselineReview the rendered diff above. If the changes are expected, refresh the cd packages/http-client-python
npm run regenerate # produce fresh generated output
npm run regenerate:push-assets # publish baseline + bump assets.jsonThen commit the updated |
# Conflicts: # packages/http-client-python/eng/scripts/ci/regenerate-common.ts
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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>
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>
There was a problem hiding this comment.
🟡 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 runsnpm 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 withnpm 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. WhenAssetsRepoPrefixPathis 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--vscodeon a crafted PR can execute commands on the maintainer's machine. Invokecodewith 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
renderUnifiedDiffto produce a unified, line-numbered page, and thediff2htmldependency 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,
diff2htmlis 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.
| 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 |
| # 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}`)); |
| 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.`); | ||
| } | ||
|
|
| const pruneFilePrefixes = Array.isArray(raw.pruneFilePrefixes) | ||
| ? raw.pruneFilePrefixes.map((p) => String(p)) | ||
| : []; |
| - 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 }} |
No description provided.