Skip to content

Commit ade9df6

Browse files
authored
Make Desk and its test suite work for a standard Windows user, and gate pull requests on it (#175)
* Record every failed test and the stuck process tree in the Windows suite results, and recognize 8.3 temp spellings in the test-state guard * Resolve the nearest existing ancestor of a card path in the task-status guard, and add an only filter to the Windows suite run * Fold in the stdio admission fix from #149: the activation-config tests use the shared real MCP client and wait for admission * Drop the #149 changelog fragment; this branch carries its own * WIP: probe, desk-relative paths with forward slashes * Spell desk paths with forward slashes, find SystemRoot in any case, and fix test portability for env, file URLs and path separators * Skip POSIX-only mode and shebang tests on Windows with named reasons, and make path expectations platform-correct * Skip re-protecting a Windows path this process already verified while its identity and change time are unchanged * Match Windows worktree paths from Git to the desk's own spelling in workspace tidy, and read the boot hook path with fileURLToPath in its test * Open workspace claims and compare receipt paths in the platform's own spelling * Fix Windows path spellings and portability across tidy, shell-git, coverage, docs and script checks * Compare worktree paths by spelling only, so a symlinked claim path is still refused, and skip the POSIX-mode refresh check on Windows * Add the workspace tidy changes to the changelog fragment * Pin the Windows suite to the pack's Node 24.18.0 and keep the raw output of a test file that exits without a failing assertion Node 24.19.0 and later abort when a better-sqlite3 build made against their headers collects a prepared statement (nodejs/node#65446), which ended eleven test files with exit code 134 after every test had passed. The Windows runtime pack is built with Node 24.18.0, so the suite now runs on that version. A file that exits non-zero with no failing assertion now records the end of its output so the cause is visible. * Fix Windows behavior in the index, search pins, folder cleanup, archive links and the workspace watcher, and make the tests expect forward-slash desk paths On Windows the refs graph and the search pin prefixes were keyed with backslashes, so planning, doing and feedback docs never linked to their task and pinned iterations never matched. A failed move or archive left an empty folder behind because Node returns the first folder it made with a \\?\ prefix that never matched the path being cleaned up. Archiving a task whose task.md is a symlink compared a walked path with a real path and refused safe archives when the spellings differed. The workspace watcher watched the desk root under an 8.3 short name, which makes libuv abort the whole controller process. The runtime test-state guard did not recognize 8.3 temp folders. Tests now expect the forward-slash spelling Desk uses, set USERPROFILE with HOME on Windows, accept EPERM for a rename onto a directory, and skip the one test that seeds the reserved file name con.md. * Add the index and watcher changes to the changelog fragment * Fold in the guard fixes: absolute Windows card paths, MSYS and Cygwin paths in the Bash guard, one spelling in denials, and test portability * Make three tests wait for what they assert on, and run the elevated mode only when asked * Find short and long spellings of the temp folder in the runtime test-state guard, keep Git on the PATH of isolated Windows sessions, and skip the POSIX-only Node discovery tests on Windows * Skip the native warm-up on Windows, fix the extended-length mkdir comparison, and keep PowerShell's module cache and Git on the isolated Windows session's environment * Run the Windows suite on Node 24.18.0 so better-sqlite3 compiles against safe headers, and drop the Windows warm-up skip that only hid the crash * Skip the native warm-up on Windows again: it still ends servers with an access violation on Node 24.18.0 headers * Put the server's stderr first in the admission status and activation test failures, and give the answer-time bound a Windows runner margin * Watch the long spelling of a Windows desk root so libuv does not abort on an 8.3 short name, and run ten concurrency rounds on Windows * Close the index database handle when opening it fails, so Windows can move a corrupt index aside * Fold in the admission engineer's test portability fixes: Git on the PATH, USERPROFILE, path separators, POSIX-only skips and Windows time margins * Make the Windows-failing tests portable: USERPROFILE for the home lookup, slash-spelled desk paths, a node.exe shim, named pipes, and a Windows endpoint check that rejects a missing endpoint * Accept jq's CRLF line ending in the session-start test, and name the running processes when a fixture folder cannot be removed on Windows * Normalise jq's line ending for the second start-hook comparison, and list what is left when a fixture folder cannot be removed * Treat a Windows fixture folder that is empty but still delete-pending as removed * Say why a fixture folder with files left cannot be removed on Windows * Accept a Windows fixture folder left holding only empty folders as removed * Share one PowerShell run between identical concurrent protection requests, and fix the last standard-mode test portability failures * Make the Windows suite job fail when any test file fails or times out, prove it with a synthetic failing run, and run the suite on pull requests * Protect the private feedback store on every open, without the skip for already verified paths * Port the improvement, sign-off, shell-git and derive tests to Windows, and fix the crew-desk card prefix The improvement tools passed the card library a person prefix built with path.relative, which is desks\alias on Windows, and the library only accepts desks/alias, so a crew desk could not open or claim cards on Windows. The prefix now uses the same slash spelling as every other desk path. The tests that build their own environment now carry SystemRoot through osEnv, expect slash desk paths, read POSIX-spelled fixtures through the host's own path rules, and skip the few checks that depend on POSIX permission bits or ENOTDIR with the exact Windows limit named. The hook dependency test now makes its cache unwritable with a path under a regular file, because /dev/null/x is creatable on Windows. * Treat a redirect to /dev/null as no file write on Windows, and finish the path spellings in the derive and fm tests Git Bash on Windows resolves a redirect to /dev/null into D:\dev\null, which the write filter no longer recognised, so the factory would have recorded a file write for every quiet command. The filter now checks the word as typed. The tests state PowerShell paths as Windows paths and the other fixtures through the host's own path rules. * Make the factory loop tests portable to Windows and fix two Windows defects: person prefixes spelled with forward slashes, and the Claude CLI found as claude.exe The loop, route, mirror, evaluator and reconcile tests built an environment without SystemRoot, so every protected write failed on Windows. They now use osEnv. Fixture paths in the binding tests are spelled as absolute paths for the platform, and tests that need chmod, an execute bit or a shell script standing in for git are skipped on Windows with the reason. The crew person prefix was built with path.relative, giving desks\sam on Windows, which the improvement card folder refuses. It now uses deskRelativePath. findAgentCli looked only for claude, so a Windows user's claude.exe was never found; it now looks for claude.exe on Windows. * Make the last two factory loop test cases portable to Windows: the repository fake splits on the platform separator, and the dangling-link lock case is left out on Windows * Spell two more card paths with forward slashes, and add the new product fixes to the changelog fragment * Cover the paths the coverage gate flagged, and finish the forward-slash expectations for crew-desk cards * Fix merged task_signoff test paths * Add a Windows suite aggregate job that counts per-file results * Make the new main tests and the cleanup index portable to Windows; wait longer for a server's late writes before removing a test fixture * Make private_view tests portable to Windows; cover refs.js fully and drop its unreachable branches * Wait for a Windows lock file whose deletion is pending instead of failing on EPERM * Remove the activation test fixture again when the server wrote late, since Node's retries do not re-list the folder * Give the feedback preview-version tests the Windows system variables * Give each Windows test file 30 minutes: the slowest takes about 20 with a protected write behind every factory call * Wait for the first flush's lock in the concurrent-flush test instead of a fixed 50 ms * Allow a second for a Windows answer while admission is busy: 506 ms failed a 500 ms bound on a loaded runner * Windows suite: review fixes (verdict checks, median answer times, bounded lock wait, declared skips) * Windows suite: make two new main tests host-path and slow-write safe * Artifact scripts test: generous budgets where the test is about output folders * Windows suite: tighter answer cap, no-test files fail the verdict, bounded lock retry for improvement cards
1 parent 6faf914 commit ade9df6

163 files changed

Lines changed: 1838 additions & 715 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 67 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,73 @@
11
// Runs the Desk unit test files one process each, with a per-file time limit, and writes a JSON result.
22
// A file that hangs is killed (whole process tree) and recorded as a timeout instead of stalling the shard.
3-
// Usage: node run-suite-files.mjs --shard 1/6 --out <results.json> [--timeout-ms 180000]
3+
// Usage: node run-suite-files.mjs --shard 1/6 --out <results.json> [--timeout-ms 1800000] [--only <file regex>] [--tests-root <folder>]
4+
// Exit code: 1 when any file failed, timed out or reported a failed test, so a job that runs this script is red whenever the suite is. 0 only when every file passed.
45
import { spawn, spawnSync } from "node:child_process"
56
import fs from "node:fs"
67
import path from "node:path"
78
import { fileURLToPath, pathToFileURL } from "node:url"
9+
import { suiteFiles } from "./suite-files.mjs"
810

911
const args = process.argv.slice(2)
1012
const arg = (name, fallback) => (args.includes(name) ? args[args.indexOf(name) + 1] : fallback)
1113
const [index, total] = arg("--shard", "1/1").split("/").map(Number)
1214
const out = arg("--out", "suite-results.json")
13-
const timeoutMs = Number(arg("--timeout-ms", "180000"))
15+
const timeoutMs = Number(arg("--timeout-ms", "1800000"))
1416
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..")
15-
const testsRoot = path.join(repoRoot, "tests", "desk", "mcp", "__tests__")
17+
const isolatedEnv = path.join(repoRoot, "tests", "desk", "mcp", "__tests__", "_isolated_env.mjs")
18+
// --tests-root points the runner at another folder of test files (the gate test uses a synthetic one).
19+
const testsRoot = path.resolve(arg("--tests-root", path.join(repoRoot, "tests", "desk", "mcp", "__tests__")))
1620
const mcpRoot = path.join(repoRoot, "plugins", "desk", "mcp")
1721

18-
const walk = (dir) => fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
19-
const full = path.join(dir, entry.name)
20-
return entry.isDirectory() ? walk(full) : entry.name.endsWith(".test.js") ? [full] : []
21-
})
22-
const files = walk(testsRoot).sort()
23-
// Round-robin keeps a slow directory's files spread over the shards.
24-
const mine = files.filter((_, i) => i % total === index - 1)
22+
// The same file list the verdict job checks against (suite-files.mjs). Round-robin keeps a slow directory's files spread over the shards.
23+
// --only <regex> narrows the run to matching files (relative to the tests folder, forward slashes) for quick investigation runs.
24+
const only = String(arg("--only", "") ?? "")
25+
const wanted = suiteFiles(testsRoot, only).map((file) => path.join(testsRoot, ...file.split("/")))
26+
const mine = wanted.filter((_, i) => i % total === index - 1)
27+
28+
// What is still running under the test process when it hit its time limit, so a hang names the stuck command.
29+
const describeDescendants = (rootPid) => {
30+
if (process.platform !== "win32") return ""
31+
const probe = spawnSync("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command",
32+
"Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,Name,CommandLine | ConvertTo-Json -Compress"],
33+
{ encoding: "utf8", timeout: 30000 })
34+
try {
35+
const all = [].concat(JSON.parse(probe.stdout || "[]"))
36+
const keep = new Set([rootPid])
37+
for (let grew = true; grew;) {
38+
grew = false
39+
for (const p of all) if (keep.has(p.ParentProcessId) && !keep.has(p.ProcessId)) { keep.add(p.ProcessId); grew = true }
40+
}
41+
return all.filter((p) => keep.has(p.ProcessId)).map((p) => `${p.ProcessId}<-${p.ParentProcessId} ${p.Name} ${String(p.CommandLine ?? "").slice(0, 300)}`).join("\n")
42+
} catch { return "(process list unavailable)" }
43+
}
2544

2645
const killTree = (pid) => {
2746
if (process.platform === "win32") spawnSync("taskkill", ["/pid", String(pid), "/T", "/F"], { stdio: "ignore" })
2847
else try { process.kill(-pid, "SIGKILL") } catch { /* already gone */ }
2948
}
3049

50+
// One compact record per failed test: its name, the assertion or error text and the first stack frames.
51+
const failures = (output) => [...output.matchAll(/^\s*not ok \d+ - ([^\n]+?)(?: # [^\n]*)?\n([\s\S]*?)(?=^\s*(?:# Subtest|ok \d+|not ok \d+|1\.\.))/gm)].map((m) => {
52+
const body = m[2]
53+
const error = /^\s*error: ([\s\S]*?)^\s*code:/m.exec(body)?.[1]?.trim() ?? ""
54+
const frames = (/^\s*stack: \|-\n([\s\S]*?)^\s*\.\.\./m.exec(body)?.[1] ?? "").split("\n").map((l) => l.trim().replace(/file:\/\/\/[A-Z]:\/a\/desk\/desk\//g, "")).filter(Boolean)
55+
// The first frames show where it failed; the first frames in the test files show what the test was doing.
56+
const stack = [...frames.slice(0, 3), ...frames.filter((l) => l.includes("__tests__") && !l.includes("_isolated_env")).slice(0, 3)].join(" | ")
57+
return { name: m[1], error: error.slice(0, 3000), stack: stack.slice(0, 700) }
58+
})
59+
3160
const runFile = (file) => new Promise((resolve) => {
3261
const started = Date.now()
3362
const child = spawn(process.execPath, [
34-
"--import", pathToFileURL(path.join(testsRoot, "_isolated_env.mjs")).href, "--test", "--test-reporter=tap", file,
63+
"--import", pathToFileURL(isolatedEnv).href, "--test", "--test-reporter=tap", file,
3564
], { cwd: mcpRoot, env: { ...process.env, GIT_TERMINAL_PROMPT: "0", GCM_INTERACTIVE: "never" }, detached: process.platform !== "win32" })
3665
let output = ""
3766
child.stdout.on("data", (chunk) => { output += chunk })
3867
child.stderr.on("data", (chunk) => { output += chunk })
3968
let timedOut = false
40-
const timer = setTimeout(() => { timedOut = true; killTree(child.pid) }, timeoutMs)
69+
let stuck = ""
70+
const timer = setTimeout(() => { timedOut = true; stuck = describeDescendants(child.pid); killTree(child.pid) }, timeoutMs)
4171
child.on("close", (code) => {
4272
clearTimeout(timer)
4373
const failed = [...output.matchAll(/^\s*not ok \d+ - (.+?)(?: # .*)?$/gm)].map((m) => m[1])
@@ -46,18 +76,40 @@ const runFile = (file) => new Promise((resolve) => {
4676
file: path.relative(testsRoot, file).split(path.sep).join("/"),
4777
exitCode: code, timedOut, ms: Date.now() - started,
4878
pass: count("pass"), fail: count("fail"), skipped: count("skipped"), failedTests: [...new Set(failed)],
79+
failures: failures(output),
80+
stuck, tail: timedOut ? output.slice(-2500) : "",
81+
// A file that exits non-zero with no failing assertion (a native abort) leaves its reason only in the raw output.
82+
outputTail: code !== 0 && !timedOut ? output.slice(-4000) : "",
4983
firstFailures: code === 0 ? "" : [...output.matchAll(/^\s*not ok \d+ - [\s\S]*?(?=^\s*(?:# Subtest|ok \d+|not ok \d+|1\.\.))/gm)].slice(0, 3).map((m) => m[0].slice(0, 1500)).join("\n----\n") || output.slice(-1500),
5084
})
5185
})
5286
})
5387

88+
// How long Windows PowerShell and Desk's own ACL provider take here, because every protected write starts one.
89+
const probeAcl = async () => {
90+
if (process.platform !== "win32") return null
91+
const timed = (fn) => { const t = Date.now(); const value = fn(); return [Date.now() - t, value] }
92+
const plain = Array.from({ length: 3 }, () => timed(() => spawnSync("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", "1"], { encoding: "utf8" }).status)[0])
93+
const { protectWindowsPaths } = await import(pathToFileURL(path.join(mcpRoot, "src", "factory", "windows-acl.js")).href)
94+
const dir = fs.mkdtempSync(path.join(process.env.TEMP ?? process.cwd(), "acl-probe-"))
95+
const provider = []
96+
for (let i = 0; i < 3; i += 1) {
97+
const t = Date.now()
98+
try { await protectWindowsPaths([{ path: dir, kind: "directory", created: false }]); provider.push(Date.now() - t) } catch (error) { provider.push(`${Date.now() - t}ms ${error.message.slice(0, 200)}`) }
99+
}
100+
fs.rmSync(dir, { recursive: true, force: true })
101+
return { powershellStartMs: plain, desk_acl_provider_ms: provider }
102+
}
103+
const aclProbe = args.includes("--probe-acl") ? await probeAcl() : null
104+
console.log("acl probe:", JSON.stringify(aclProbe))
105+
54106
const results = []
55107
for (const file of mine) {
56108
const result = await runFile(file)
57109
results.push(result)
58110
console.log(`${result.timedOut ? "TIMEOUT" : result.exitCode === 0 ? "ok " : "FAIL "} ${result.file} pass=${result.pass} fail=${result.fail} ${result.ms}ms`)
59111
}
60-
fs.writeFileSync(out, JSON.stringify({ shard: `${index}/${total}`, platform: process.platform, results }, null, 1))
112+
fs.writeFileSync(out, JSON.stringify({ shard: `${index}/${total}`, platform: process.platform, aclProbe, results }, null, 1))
61113
const bad = results.filter((r) => r.exitCode !== 0)
62114
const timeouts = results.filter((r) => r.timedOut)
63115
const sum = (key) => results.reduce((n, r) => n + r[key], 0)
@@ -72,5 +124,5 @@ const lines = [
72124
]
73125
if (timeouts.length > 0) lines.push(`Timed out: ${timeouts.map((r) => `\`${r.file}\``).join(", ")}`, "")
74126
fs.writeFileSync(out.replace(/\.json$/u, "") + "-summary.md", lines.join("\n") + "\n")
75-
// The comparison is the product; a red suite is reported in the results and the summary rather than as a failed job.
76-
process.exit(0)
127+
// The job result is the gate: any failing file, timeout or failed test makes it red. The results and summary are written first so a red job still shows what failed.
128+
process.exit(bad.length > 0 || timeouts.length > 0 || sum("fail") > 0 ? 1 : 0)

‎.github/scripts/suite-files.mjs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// The Desk unit test files, found the one way the shard runner and the verdict script both need: every `*.test.js` under the tests folder, as paths relative to it with forward slashes, sorted.
2+
import fs from "node:fs"
3+
import path from "node:path"
4+
5+
export function suiteFiles(testsRoot, only = "") {
6+
const walk = (dir) => fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
7+
const full = path.join(dir, entry.name)
8+
return entry.isDirectory() ? walk(full) : entry.name.endsWith(".test.js") ? [full] : []
9+
})
10+
const relative = walk(testsRoot).sort().map((file) => path.relative(testsRoot, file).split(path.sep).join("/"))
11+
// `only` narrows the list for an investigation run: a regular expression over the relative path.
12+
return only === "" ? relative : relative.filter((file) => new RegExp(only, "u").test(file))
13+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Decides the Windows suite's verdict from the per-file results the standard-user shards uploaded, not from the shards' job conclusions.
2+
// Usage: node windows-suite-verdict.mjs <folder holding one results folder per shard> <expected shard count> [<tests folder> [<only regex>]]
3+
// Exit code: 0 only when every expected shard reported, each results file names the shard its folder says, the files reported across the shards are exactly the suite's test files, and every one passed and ran at least one test (passed, failed or skipped).
4+
// The suite's files are found with the same code the shard runner uses (suite-files.mjs), so a shard that ran nothing, or a file no shard reported, is named and fails.
5+
import fs from "node:fs"
6+
import path from "node:path"
7+
import { fileURLToPath } from "node:url"
8+
import { suiteFiles } from "./suite-files.mjs"
9+
10+
const defaultTests = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..", "tests", "desk", "mcp", "__tests__")
11+
12+
export function verdict(root, expected, testsRoot = defaultTests, only = "") {
13+
const folders = fs.existsSync(root) ? fs.readdirSync(root, { withFileTypes: true }).filter((e) => e.isDirectory() && fs.existsSync(path.join(root, e.name, "results.json"))) : []
14+
const problems = []
15+
if (folders.length !== expected) problems.push(`${folders.length} of ${expected} shards reported results`)
16+
const reported = new Map()
17+
const numbers = new Set()
18+
for (const folder of folders) {
19+
const { shard, results } = JSON.parse(fs.readFileSync(path.join(root, folder.name, "results.json"), "utf8"))
20+
const named = /(\d+)$/u.exec(folder.name)?.[1]
21+
if (shard !== `${named}/${expected}`) problems.push(`${folder.name}: its results say shard ${shard}, not ${named}/${expected}`)
22+
numbers.add(named)
23+
for (const r of results) {
24+
reported.set(r.file, (reported.get(r.file) ?? 0) + 1)
25+
if (r.timedOut) problems.push(`${folder.name}: ${r.file} timed out`)
26+
else if (r.exitCode !== 0 || r.fail > 0) problems.push(`${folder.name}: ${r.file} failed (${r.fail} failed tests, exit ${r.exitCode})`)
27+
// A file that ran no test at all (it crashed while loading, or the runner printed nothing) is not a pass; an all-skipped file still ran its tests, so it counts.
28+
else if ((r.pass ?? 0) + (r.fail ?? 0) + (r.skipped ?? 0) < 1) problems.push(`${folder.name}: ${r.file} ran no tests`)
29+
}
30+
}
31+
if (numbers.size !== folders.length) problems.push("two result folders name the same shard")
32+
const suite = suiteFiles(testsRoot, only)
33+
for (const file of suite) if (!reported.has(file)) problems.push(`${file}: no shard reported it`)
34+
for (const [file, count] of reported) {
35+
if (!suite.includes(file)) problems.push(`${file}: reported but not a test file of this checkout`)
36+
else if (count > 1) problems.push(`${file}: reported by ${count} shards`)
37+
}
38+
return { files: reported.size, problems }
39+
}
40+
41+
if (process.argv[1] === fileURLToPath(import.meta.url)) {
42+
const { files, problems } = verdict(process.argv[2], Number(process.argv[3]), process.argv[4] ? path.resolve(process.argv[4]) : defaultTests, process.argv[5] ?? "")
43+
console.log(`${files} test files reported.`)
44+
for (const problem of problems) console.log(`::error::${problem}`)
45+
process.exit(problems.length > 0 ? 1 : 0)
46+
}

‎.github/workflows/desk-windows-suite.yml‎

Lines changed: 72 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
name: desk MCP tests on Windows
22

3-
# Runs the whole Desk unit suite (plugins/desk/mcp `npm test`) on a Windows runner two ways:
4-
# elevated - the runner's own administrator account (GitHub's default).
5-
# standard - a new local user outside the Administrators group, which is what a managed Windows machine gives a person.
6-
# The two modes are compared to show that nothing in the suite depends on elevation. The main desk MCP tests workflow
7-
# covers Linux only. This workflow is report-only for now: it is not a required check and runs on demand (workflow_dispatch) only. It has no pull_request trigger because the scheduled Superpowers refresh waits on every pull-request workflow, and it must not wait on a Windows suite that is not yet clean.
3+
# Runs the whole Desk unit suite (plugins/desk/mcp `npm test`) on a Windows runner as a standard user: a new local user outside
4+
# the Administrators group, which is what a managed Windows machine gives a person. The main desk MCP tests workflow covers Linux only.
5+
# Pull requests that touch the Desk server, its tests or this workflow run it, and the scheduled Superpowers refresh dispatches it with the
6+
# other pull-request workflows (CI_WORKFLOWS in superpowers-upstream.yml; scripts/test-refresh-superpowers.cjs checks that the two lists match).
7+
# A manual dispatch can add the elevated (administrator) mode with `elevated: true`. That mode is a diagnostic and is not gated: Desk refuses to
8+
# reuse a path owned by the Administrators group, which is what an elevated user's own existing files are.
89

910
on:
11+
pull_request:
12+
paths:
13+
- "plugins/desk/mcp/**"
14+
- "tests/desk/mcp/**"
15+
- ".github/scripts/**"
16+
- ".github/workflows/desk-windows-suite.yml"
1017
workflow_dispatch:
18+
inputs:
19+
only:
20+
description: "Only run test files whose path (under tests/desk/mcp/__tests__) matches this regular expression. Empty runs everything."
21+
required: false
22+
default: ""
23+
elevated:
24+
description: "Also run the elevated (administrator) mode. It is a diagnostic: Desk refuses to reuse a path owned by the Administrators group, which is what an administrator's own existing files are."
25+
type: boolean
26+
required: false
27+
default: false
1128

1229
permissions:
1330
contents: read
@@ -21,22 +38,27 @@ jobs:
2138
name: Windows ${{ matrix.mode }} (shard ${{ matrix.shard }}/6)
2239
runs-on: windows-latest
2340
timeout-minutes: 90
41+
# The elevated mode is a diagnostic that fails by policy (see the comment at the top), so it never turns the run red; the standard mode does.
42+
continue-on-error: ${{ matrix.mode == 'elevated' }}
2443
strategy:
2544
fail-fast: false
2645
matrix:
27-
mode: [elevated, standard]
46+
mode: ${{ fromJSON(inputs.elevated && '["elevated","standard"]' || '["standard"]') }}
2847
shard: [1, 2, 3, 4, 5, 6]
2948
steps:
3049
- name: Check out repository
3150
uses: actions/checkout@v4
3251
with:
52+
# The coverage tests resolve a merge base against origin/main, as the Linux suite does, so they need history.
53+
fetch-depth: 0
3354
# The standard user can read the checkout's .git/config, so it must not hold the job token.
3455
persist-credentials: false
3556

3657
- name: Set up Node
3758
uses: actions/setup-node@v4
3859
with:
39-
node-version: "24"
60+
# The Windows runtime pack is built with Node 24.18.0 (desk-mcp-tests.yml, win32-x64-node-137). Node 24.19.0 and later abort when a better-sqlite3 build made against their headers collects a prepared statement (nodejs/node#65446, WiseLibs/better-sqlite3#1515), so this suite pins the version the pack ships with.
61+
node-version: "24.18.0"
4062
cache: "npm"
4163
cache-dependency-path: plugins/desk/mcp/package-lock.json
4264

@@ -55,17 +77,19 @@ jobs:
5577
- name: Run the suite (elevated)
5678
if: matrix.mode == 'elevated'
5779
shell: pwsh
58-
run: node .github/scripts/run-suite-files.mjs --shard ${{ matrix.shard }}/6 --out results.json
80+
run: node .github/scripts/run-suite-files.mjs --shard ${{ matrix.shard }}/6 --out results.json --probe-acl --only "$env:ONLY_FILES"
5981
env:
6082
GIT_TERMINAL_PROMPT: "0"
83+
ONLY_FILES: ${{ inputs.only }}
6184

6285
- name: Run the suite (standard user)
6386
if: matrix.mode == 'standard'
6487
shell: pwsh
65-
run: >
66-
./.github/scripts/run-as-standard-user.ps1
67-
-WorkDir "$PWD"
68-
-Command 'node .github\scripts\run-suite-files.mjs --shard ${{ matrix.shard }}/6 --out results.json'
88+
run: |
89+
$command = 'node .github\scripts\run-suite-files.mjs --shard ${{ matrix.shard }}/6 --out results.json --probe-acl --only "' + $env:ONLY_FILES + '"'
90+
./.github/scripts/run-as-standard-user.ps1 -WorkDir "$PWD" -Command $command
91+
env:
92+
ONLY_FILES: ${{ inputs.only }}
6993

7094
- name: Show the result in the job summary
7195
if: always()
@@ -81,3 +105,39 @@ jobs:
81105
name: windows-${{ matrix.mode }}-shard-${{ matrix.shard }}
82106
path: results.json
83107
if-no-files-found: warn
108+
# A rerun of only the failed shards uploads under a name an earlier attempt already holds.
109+
overwrite: true
110+
111+
# One check that stands for the whole Windows suite, so a branch rule can require a single name. It judges the per-file results the
112+
# standard-user shards uploaded (not the shards' job conclusions), so a shard that never ran, was cancelled or reported a failed test
113+
# fails it. The elevated diagnostic is not counted. It is separate from "CI gate" (desk-mcp-tests.yml) because a job's `needs` cannot
114+
# reach another workflow, and this workflow only runs on pull requests that touch the paths above: requiring it before that filter is
115+
# removed would block every other pull request on a check that never reports.
116+
windows-suite-result:
117+
name: Windows suite
118+
needs: windows-suite
119+
if: ${{ always() }}
120+
runs-on: ubuntu-latest
121+
timeout-minutes: 10
122+
permissions:
123+
contents: read
124+
steps:
125+
- name: Check out the verdict script
126+
uses: actions/checkout@v4
127+
with:
128+
persist-credentials: false
129+
# The verdict compares the shards' files with the suite's test files, so it needs the tests folder's names too.
130+
sparse-checkout: |
131+
.github/scripts
132+
tests/desk/mcp/__tests__
133+
134+
- name: Download every standard-user shard's results
135+
uses: actions/download-artifact@v4
136+
with:
137+
pattern: windows-standard-shard-*
138+
path: shard-results
139+
140+
- name: Fail unless every shard reported and every file passed
141+
run: node .github/scripts/windows-suite-verdict.mjs shard-results 6 tests/desk/mcp/__tests__ "$ONLY_FILES"
142+
env:
143+
ONLY_FILES: ${{ inputs.only }}

0 commit comments

Comments
 (0)