CI: post VSIX download + size-delta comment on PRs#53
Open
nmetulev wants to merge 1 commit into
Open
Conversation
Mirror microsoft/winappcli's post-metrics-comment pattern, scoped to the single
VSIX artifact (no CLI/MSIX/NuGet/test/coverage/startup metrics).
- build.yml (additive): measure the packaged VSIX into artifacts/vsix-sizes.json
({"vsix": <bytes>}); on push to main save it as an immutable-cache baseline
(winappvsce-vsix-baseline, deleting the old entry first); on pull_request
restore the baseline and upload a metrics-data artifact (current + baseline +
pr-context). Adds actions:write for `gh cache delete`; keeps the existing
vscode-extension artifact and every prior step unchanged.
- post-vsix-comment.yml (new): workflow_run on "Build and Test" runs in the base
repo so it has pull-requests:write even for fork PRs. Preserves the winappcli
security model - trusts only workflow_run head_sha + run id, resolves/verifies
the PR via listPullRequestsAssociatedWithCommit, allowlists the single `vsix`
key, coerces values with safeNum. Renders an idempotent "## VSIX Build" comment
(Baseline | Current | Delta) linking the row to the vscode-extension artifact
download URL, with an absolute-size fallback on the first PR.
- mark-vsix-stale.yml (new): pull_request_target banner marking the comment
stale while a new build runs.
Validated: yaml.safe_load on all three files, node --check on both
github-script blocks, PowerShell parser on all new pwsh blocks, plus a mocked
end-to-end render of the comment (baseline / no-baseline / update paths, and
the allowlist dropping unknown keys).
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b889e1ad-e208-4032-a52a-c3ed2429c58b
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Adds a PR bot comment that posts the built extension VSIX download link and its size delta vs. the
mainbaseline — mirroring the pattern the sibling repomicrosoft/winappclialready uses (post-metrics-comment.yml), scoped down to our single VSIX artifact (no CLI/MSIX/NuGet/test/coverage/startup metrics).The
Build and Testworkflow already builds and uploads the extension as thevscode-extensionartifact, but never surfaced its size on PRs. Now it does.How it works
build.yml(additive): afterPackage VSIX, a step measures the VSIX intoartifacts/vsix-sizes.json({"vsix": <bytes>}). On push tomainit saves that as an immutable-cache baseline (winappvsce-vsix-baseline, deleting the old entry first since caches are immutable). Onpull_requestit restores the baseline and uploads ametrics-dataartifact (current size + baseline +pr-context.json).post-vsix-comment.yml(new): triggered byworkflow_runonBuild and Test, so it runs in the base repo context and haspull-requests: writeeven for fork PRs — that split is the whole point. It downloadsmetrics-data, resolves the PR, and creates/updates one idempotent comment.mark-vsix-stale.yml(new): onpull_request_target, prepends a "build in progress" banner to the existing comment when a new commit lands.Security model (preserved from winappcli)
The
metrics-dataartifact is produced by the PR's own code, so it is treated as untrusted. The comment workflow:workflow_runmetadata (head_sha, run id) — never the artifact'spr-context.json;listPullRequestsAssociatedWithCommitand verifies the PR head still matches (an older run won't clobber a newer commit's report);vsixkey and coerces values (safeNum), so a malicious build can't inject table breaks, mentions, hidden HTML, or links.Usage Example
Rendered comment on a PR (marker
<!-- vsix-size-report -->, updated in place):Related Issue
Type of Change
Checklist
package.jsoncontribution points / command/debugger/custom-editor docs updated (if extension surface changed) — N/A, CI-only changeAdditional Notes
workflow_run/pull_request_targetcomment workflows only run from the version on the default branch. So the first live comment appears on the next PR after this one merges — this PR itself will uploadmetrics-databut won't get a comment, becausepost-vsix-comment.ymlisn't onmainyet. Likewise themainbaseline cache is first written when this merges tomain, so the earliest PRs will show the absolute-size fallback until a baseline exists.Permissions: the build job gains
actions: write(needed forgh cache deleteonmain). Commenting deliberately stays out of the build job — it happens only in the separate privileged workflow. Thevscode-extensionartifact is reused as-is (not renamed).Validation performed locally:
yaml.safe_loadon all three workflow files;node --checkon bothactions/github-scriptblocks;[Parser]::ParseInput) on every newpwshblock;AI Description
This section is auto-generated by AI when the PR is opened or updated. To opt out, delete this entire section including the marker comments.