Skip to content

Commit a793ed4

Browse files
cliffhallclaude
andcommitted
fix(interface-diff): Dependabot, root tsconfig, Windows quoting (#4860)
Copilot round 3 on #4975 ("previously missed"): - Skip the comment job on Dependabot PRs, which are same-repo but get a read-only token; they keep the summary and artifact like fork PRs. - Trigger on the root tsconfig.json, which everything's tsconfig extends. - Spawn only npm through a shell on Windows, with its arguments quoted by winShellArgs; git needs no shell. - Silence the expected usage error in the script test. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 0c2a61d commit a793ed4

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎.github/workflows/everything-mcp-diff.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ on:
3636
- "src/everything/**"
3737
- "package.json"
3838
- "package-lock.json"
39+
- "tsconfig.json"
3940
- "scripts/interface-diff.mjs"
4041
- ".github/workflows/everything-mcp-diff.yml"
4142
# No branch filter: PRs to v2/main and to main both run, and so does a PR
@@ -45,6 +46,7 @@ on:
4546
- "src/everything/**"
4647
- "package.json"
4748
- "package-lock.json"
49+
- "tsconfig.json"
4850
- "scripts/interface-diff.mjs"
4951
- ".github/workflows/everything-mcp-diff.yml"
5052
# A published Release (a milestone, tagged vX.Y.Z on main; see RELEASING.md)
@@ -187,13 +189,16 @@ jobs:
187189
# navigating to the Actions tab. One comment per PR, found again by its
188190
# marker and edited on each push. This job checks nothing out and runs none
189191
# of the PR's code; it only reads the report the `diff` job uploaded.
192+
# Dependabot's PRs are same-repo but get a read-only token, so they are
193+
# skipped like fork PRs and keep the job summary and the artifact.
190194
comment:
191195
name: Post the diff on the PR
192196
needs: diff
193197
if: >-
194198
always() &&
195199
github.event_name == 'pull_request' &&
196200
github.event.pull_request.head.repo.full_name == github.repository &&
201+
github.event.pull_request.user.login != 'dependabot[bot]' &&
197202
(needs.diff.result == 'success' || needs.diff.result == 'failure')
198203
timeout-minutes: 5
199204
runs-on: ubuntu-latest

‎scripts/interface-diff.mjs‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import {
5656
import { createRequire } from "node:module";
5757
import path from "node:path";
5858
import { fileURLToPath, pathToFileURL } from "node:url";
59+
import { winShellArgs } from "./lib/win-shell-args.mjs";
5960

6061
const repoRoot = path.resolve(
6162
path.dirname(fileURLToPath(import.meta.url)),
@@ -191,14 +192,19 @@ export function renderReport(verdict, { base, head }) {
191192
return lines.join("\n");
192193
}
193194

194-
/** Run a command to completion; throw with its output when it fails. */
195+
/**
196+
* Run a command to completion; throw with its output when it fails. Only
197+
* `npm` needs a shell, and only on Windows (it is a `.cmd` shim there); its
198+
* arguments are then quoted for `cmd.exe`. `git` is spawned without one.
199+
*/
195200
function run(command, args, cwd, env) {
196-
const res = spawnSync(command, args, {
201+
const shell = process.platform === "win32" && command === "npm";
202+
const res = spawnSync(command, shell ? winShellArgs(args) : args, {
197203
cwd,
198204
env: env ?? process.env,
199205
encoding: "utf8",
200206
maxBuffer: 64 * 1024 * 1024,
201-
shell: process.platform === "win32",
207+
shell,
202208
});
203209
if (res.error) throw res.error;
204210
if (res.status !== 0)

‎scripts/interface-diff.test.mjs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ test("parseArgs refuses an unknown flag or a missing value", () => {
3737
assert.throws(() => parseArgs(["--base="]), /--base needs a value/);
3838
});
3939

40-
test("main exits 2 on a bad command line, before building anything", async () => {
40+
test("main exits 2 on a bad command line, before building anything", async (t) => {
41+
// The usage error it prints is expected; keep it out of the test output.
42+
const error = t.mock.method(console, "error", () => {});
4143
assert.equal(await main(["--nope"]), 2);
44+
assert.match(String(error.mock.calls[0]?.arguments[0]), /unknown argument/);
4245
});
4346

4447
test("an identical interface is unchanged", () => {

0 commit comments

Comments
 (0)