Skip to content

Improve contributor setup and avoid macOS CI memory thrashing - #11975

Merged
Bill Schnurr (bschnurr) merged 9 commits into
microsoft:mainfrom
bschnurr:bschnurr/docs-mac-ci-fix
Nov 16, 2026
Merged

Bill Schnurr (bschnurr) merged 9 commits into
microsoft:mainfrom
bschnurr:bschnurr/docs-mac-ci-fix

Conversation

@bschnurr

@bschnurr Bill Schnurr (bschnurr) commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Document Node.js 24 and pinned pnpm setup, Corepack troubleshooting, build/test commands, and contributor links.
  • Inject Math into the Jest sandbox to avoid cross-context fingerprinting overhead without disabling TypeScript checking.
  • Limit macOS CI to one Jest worker; retain default parallelism locally and on Linux/Windows. The final configuration has no percentage-based heap override and retains the test script's fixed 8 GiB old-space limit.
  • Upload macOS test output and Jest JSON results, and publish bounded, escaped test summaries, slow suites, and failures as workflow annotations.

This separates the documentation and CI fixes from #11970. No typeshed or dependency changes are included.

Performance evidence

The original single-worker trial used 3 M1 virtual CPUs and 7 GiB RAM. Both historical runs passed 3,659 tests across 99 suites with identical test code/dependencies:

Historical Mac configuration Test step Swap reads / writes
2 Jest workers 15m46s 28.7 / 30.7 GiB
1 Jest worker, no percentage heap cap 8m24s 0 / 0 GiB

The eight-minute result was not reproduced on the final PR revision. More recent runs passed 3,704 tests across 99 suites:

PR revision / Mac configuration Jest Test step
59d826806, 1 worker, 50% heap cap 27m48s 28m21s
af18d4408, 1 worker, no percentage heap cap 17m16s 17m35s

These are separate hosted runs, not controlled or repeated measurements. They do not establish a guaranteed eight-minute runtime or prove that the heap cap caused the slowdown. Large post-suite delays remain; their cause is not established.

The current workflow does not publish runner-resource or vm_stat swap-counter annotations. Its /usr/bin/time output is retained in the uploaded log; a reported 0 swaps there is not equivalent to measured zero macOS swap-in/out traffic.

Validation

  • All required checks passed on af18d4408: Typecheck, Style, macOS/Linux/Windows tests, Build, and Required.
  • NumPy complexity canary, mypy_primer, and CLA checks passed. The type checker benchmark was skipped.
  • Final macOS run: 3,704 tests and 99 suites passed; 12 tests and one suite skipped.
  • Prettier, git diff --check, and two existing executable YAML-reading workflow guards passed.
  • Executable configuration assertions verified one macOS worker, injected Math, no heap override, and retained log artifacts.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rchiodo

Rich Chiodo (rchiodo) commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

🔒 Automated review in progress — Rich Chiodo (@rchiodo) is auto-reviewing this PR.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rchiodo

Copy link
Copy Markdown
Collaborator

Result: ⚠️ partially-verified

Verification details

Verification: Automated verification is best effort. The PR author remains responsible for testing.

Summary: Offline dependency preparation succeeded in the Linux container. All 198 targeted Jest tests and two existing YAML-reading workflow guards passed, as did targeted ESLint and formatting checks. Additional checks confirmed that Math is injected, default TypeScript checking remains enabled, and the real pnpm test script forwards the single-worker override. Initial Git discovery failed because the container lacks Git metadata; no tests failed. Hosted macOS memory improvements remain unverified, and current HEAD contains no diagnostic-reporting scripts matching the PR description.

Test runs: 5 passed, 1 failed, 1 not run

  • ⚠️ Not run | Hosted macOS single-worker memory and performance validation | pnpm test --maxWorkers=1
  • ❌ Failed | unrelated to this PR | Batched dependency and test discovery | pwd; git status --short; git diff --stat; git log -3 --oneline; printf '\nEnvironment\n'; printf 'AUTOMATION_SANDBOX_PROFILE=%s\n' "$AUTOMATION_SANDBOX_PROFILE"; node --version; npm --version; pnpm --version; printf '\nManifests and dependency availability\n'; cat package.json; cat packages/pyright-internal/package.json; test ! -d node_modules || ls node_modules/.bin; test ! -d packages/pyright-internal/node_modules || ls packages/pyright-internal/node_modules/.bin; printf '\nChanged files\n'; git diff HEAD~1 --name-only
  • ✅ Passed | Fingerprint, parser, and overload-result-controller tests | node ./node_modules/jest/bin/jest.js src/tests/stringUtils.test.ts src/tests/parser.test.ts src/tests/overloadResultController.test.ts --runInBand
  • ✅ Passed | Existing YAML-reading workflow guards | python -m pytest build/benchmark/test_compare_benchmarks.py -q -k 'test_workflows_use_current_pnpm_setup or test_benchmark_workflow_preserves_candidate_and_reporting'
  • ✅ Passed | Targeted lint and formatting checks | pnpm exec eslint packages/pyright-internal/jest.config.js && pnpm exec prettier --check .github/workflows/validation.yml CONTRIBUTING.md README.md docs/build-debug.md packages/pyright-internal/jest.config.js
  • ✅ Passed | Offline dependency preparation | printf 'profile=%s\n' "$AUTOMATION_SANDBOX_PROFILE"; pwd; ls -a; node --version; pnpm --version; pnpm install --offline --frozen-lockfile
  • ✅ Passed | Effective Jest configuration and real pnpm argument forwarding | node <<'NODE'
    const assert = require('node:assert/strict');
    const fs = require('node:fs');
    const { execFileSync } = require('node:child_process');
    const YAML = require('yaml');
    const workflow = YAML.parse(fs.readFileSync('.github/workflows/validation.yml', 'utf8'));
    const step = workflow.jobs.test.steps.find(s => s.name === 'pnpm test (pyright-internal)');
    assert.equal(step['working-directory'], 'packages/pyright-internal');
    assert.equal(step.run, "pnpm test ${{ matrix.os == 'macos-latest' && '--maxWorkers=1' || '' }}");
    const cwd = step['working-directory'];
    const config = require('./packages/pyright-internal/jest.config.js');
    assert.deepEqual(config.sandboxInjectedGlobals, ['Math']);
    assert.equal(config.transform['^.+\.tsx?$'][1].tsconfig, 'tsconfig.jest.json');
    assert.notEqual(config.transform['^.+\.tsx?$'][1].diagnostics, false);
    assert.notEqual(config.transform['^.+\.tsx?$'][1].isolatedModules, true);
    const base = JSON.parse(execFileSync(process.execPath, ['./node_modules/jest/bin/jest.js', '--showConfig'], { cwd, encoding: 'utf8' }));
    assert.deepEqual(base.configs[0].sandboxInjectedGlobals, ['Math']);
    const output = execFileSync('pnpm', ['test', '--maxWorkers=1', '--showConfig'], { cwd, encoding: 'utf8' });
    const single = JSON.parse(output.slice(output.indexOf('{\n "configs"')));
    assert.equal(single.globalConfig.maxWorkers, 1);
    assert.equal(base.globalConfig.maxWorkers, Math.max(require('node:os').availableParallelism() - 1, 1));
    console.log(PASS real pnpm test builds test server and forwards --maxWorkers=1 (effective workers=${single.globalConfig.maxWorkers}));
    console.log(PASS default workers=${base.globalConfig.maxWorkers}; workflow restricts override to macOS and leaves Windows/Linux unchanged);
    console.log('PASS Math is injected and default ts-jest type checking remains enabled');
    console.log(Runner platform: ${process.platform}; live macOS swapping/performance not measured);
    NODE
⚠️ Hosted macOS single-worker memory and performance validation diagnostic output
The workflow targets macos-latest for this override. The verification command reported 'Runner platform: linux'; hosted macOS swapping and timing were not measured.
❌ Batched dependency and test discovery diagnostic output
[container exit=129]
/workspace
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Git-based discovery was unavailable in the container; repository inspection continued using read-only navigation tools.

@rchiodo Rich Chiodo (rchiodo) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved via Review Center.

@rchiodo Rich Chiodo (rchiodo) added the review-auto:approved Automated review: no blocking findings (approval posted). label Nov 4, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

@rchiodo

Copy link
Copy Markdown
Collaborator

Result: ⚠️ partially-verified

Verification details

Verification: Automated verification is best effort. The PR author remains responsible for testing.

Summary: Offline dependency installation succeeded, but the targeted Jest run timed out after 240 seconds and destroyed the sandbox. Workflow reporter fixtures passed for successful results, failures, escaping, missing JSON, and bounded output; the combined harness then failed on an incorrect container-memory assumption. Configuration and Bash-syntax checks passed, while two existing workflow guards subsequently failed because the replacement sandbox lacked the declared YAML dependency. No PR-caused failure was established, but Jest results and hosted macOS performance remain unverified. **Reviewer dependency follow-up (nonblocking):** Suggest a separate PR adding `jest ^30.2.0`, `ts-jest ^29.4.7`, `typescript ~6.0.3`, `yaml ^2.9.0` to the official reviewer dependency declarations, using `package.json`, `package.json; packages/pyright-internal/package.json` as the dependency/version evidence. Do not automatically create that PR. This is reviewer environment maintenance, not a required change to the reviewed PR.

Test runs: 2 passed, 3 failed, 2 not run

  • ❌ Failed | relationship unknown | Targeted fingerprint, parser, and overload-controller Jest suites | node ./node_modules/jest/bin/jest.js 'src/tests/(overloadResultController|stringUtils|parser).test.ts$' --runInBand --forceExit
  • ❌ Failed | unrelated to this PR | Existing YAML-reading workflow guards | node -e "console.log(JSON.stringify({platform:process.platform,node:process.version,totalMemory:require('node:os').totalmem(),constrainedMemory:process.constrainedMemory(),availableMemory:process.availableMemory()}))"; python -m pytest -q test_compare_benchmarks.py::CompareBenchmarksTest::test_workflows_use_current_pnpm_setup test_compare_benchmarks.py::CompareBenchmarksTest::test_benchmark_workflow_preserves_candidate_and_reporting
  • ⚠️ Not run | Hosted macOS test timing and swap measurement | /usr/bin/time -lp pnpm test --maxWorkers=1 --json --outputFile=mac-test-results.json 2>&1 | tee mac-test.log
  • ⚠️ Not run | Dependency and test discovery | pwd; git status --short; git log -3 --oneline; git diff --stat HEAD^ HEAD; printf '\nEnvironment\n'; printf 'AUTOMATION_SANDBOX_PROFILE=%s\n' "$AUTOMATION_SANDBOX_PROFILE"; node --version; npm --version; pnpm --version; printf '\nDependency paths\n'; ls -d node_modules packages/pyright-internal/node_modules 2>/dev/null; printf '\nRoot manifest\n'; cat package.json; printf '\nPackage manifest and Jest config\n'; cat packages/pyright-internal/package.json packages/pyright-internal/jest.config.js; printf '\nWorkflow test/guard paths\n'; git ls-files 'test' 'spec' 'guard' | grep -E 'workflow|validation|overload|Overload|resource|jest' | head -80
  • ❌ Failed | unrelated to this PR | Workflow reporter fixtures and heap probe | node <<'NODE'
    const assert = require('node:assert/strict');
    const fs = require('node:fs');
    const os = require('node:os');
    const path = require('node:path');
    const { spawnSync } = require('node:child_process');
    const workflow = fs.readFileSync('.github/workflows/validation.yml', 'utf8');
    const report = workflow.split(' - name: Report macOS test timings\n')[1].split(' - name: Upload macOS test logs\n')[0];
    const script = report.split(" node <<'NODE'\n")[1].split(' NODE\n')[0].split('\n').map(line => line.slice(10)).join('\n');
    const root = fs.mkdtempSync(path.join(os.tmpdir(), 'mac-report-'));
    let checks = 0;
    function run(name, results, log, expectedStatus, inspect) {
    const cwd = path.join(root, name);
    fs.mkdirSync(cwd);
    fs.writeFileSync(path.join(cwd, 'mac-test.log'), log);
    if (results !== undefined) fs.writeFileSync(path.join(cwd, 'mac-test-results.json'), JSON.stringify(results));
    const child = spawnSync(process.execPath, ['-e', script], { cwd, encoding: 'utf8' });
    assert.equal(child.status, expectedStatus, child.stderr);
    inspect(child);
    checks++;
    console.log(PASS reporter: ${name});
    }
    const suites = Array.from({ length: 10 }, (_, n) => ({ name: /tests/suite${n}.test.ts, startTime: 0, endTime: n * 1000, status: 'passed', assertionResults: [] }));
    const results = { success: true, numPassedTests: 10, numFailedTests: 0, numPassedTestSuites: 10, numFailedTestSuites: 0, testResults: suites };
    try {
    run('passing', results, 'ok\n', 0, ({stdout}) => {
    assert.match(stdout, /"success":true/);
    assert.match(stdout, /suite9.test.ts: 9s (passed)%0Asuite8.test.ts/);
    assert.equal((stdout.match(/suite\d+.test.ts/g) || []).length, 8);
    assert.doesNotMatch(stdout, /Mac test failures/);
    });
    const failing = { ...results, success: false, numFailedTests: 1, numFailedTestSuites: 1, testResults: [{ name: '/tests/fail.test.ts', startTime: 0, endTime: 1000, status: 'failed', message: 'suite 100%\r\n::error::not a command', assertionResults: [{ status: 'failed', fullName: 'case\nname', failureMessages: ['failure 25%\r\nmessage'] }] }] };
    run('failing-and-escaped', failing, 'log 50%\r\n::error::fixture\n', 0, ({stdout}) => {
    assert.match(stdout, /"success":false/);
    assert.match(stdout, /Mac test failures/);
    assert.match(stdout, /100%25%0D%0A::error::not a command/);
    assert.match(stdout, /failure 25%25%0D%0Amessage/);
    assert.equal(stdout.trimEnd().split('\n').length, 4);
    assert.doesNotMatch(stdout, /\r/);
    });
    run('missing-json', undefined, 'last known output\n', 1, ({stdout, stderr}) => {
    assert.match(stdout, /Mac test log tail.*last known output/);
    assert.match(stderr, /Mac tests did not produce JSON results/);
    });
    run('bounded-output', results, 'x'.repeat(20000), 0, ({stdout}) => {
    const line = stdout.split('\n')[0];
    assert.equal(line.split('::')[2].length, 6000);
    });
    assert.match(workflow, /if: matrix.os != 'macos-latest'\n run: pnpm test/);
    assert.match(workflow, /id: mac_tests\n if: matrix.os == 'macos-latest'/);
    assert.match(workflow, /set -o pipefail\n /usr/bin/time -lp pnpm test --maxWorkers=1 --json --outputFile=mac-test-results.json 2>&1 | tee mac-test.log/);
    assert.equal((workflow.match(/always() && matrix.os == 'macos-latest' && steps.mac_tests.outcome != 'skipped'/g) || []).length, 2);
    const config = require('./packages/pyright-internal/jest.config.js');
    assert.deepEqual(config.sandboxInjectedGlobals, ['Math']);
    assert.notEqual(config.transform['^.+\.tsx?$'][1].diagnostics, false);
    console.log('PASS workflow routing, pipefail, artifact/report conditions, Math injection, default typechecking');
    const option = workflow.match(/NODE_OPTIONS: (.+)/)[1].trim();
    const heap = spawnSync(process.execPath, ['--max-old-space-size=8192', '-e', "console.log(require('node:v8').getHeapStatistics().heap_size_limit)"], { env: { ...process.env, NODE_OPTIONS: option }, encoding: 'utf8' });
    assert.equal(heap.status, 0, heap.stderr);
    const limit = Number(heap.stdout);
    assert.ok(Math.abs(limit - os.totalmem() / 2) < 128 * 1024 * 1024, heap=${limit} totalmem=${os.totalmem()});
    console.log(PASS heap percentage overrides fixed 8192 MiB: ${limit} bytes, Node ${process.version}, platform ${process.platform});
    console.log(${checks} reporter fixtures passed; macOS time/swap measurement not run on Linux.);
    } finally { fs.rmSync(root, { recursive: true, force: true }); }
    NODE
  • ✅ Passed | Offline dependency preparation | pnpm install --offline --frozen-lockfile
  • ✅ Passed | Configuration contracts, Bash syntax, and setup documentation checks | node <<'NODE'
    const assert = require('node:assert/strict');
    const fs = require('node:fs');
    const {spawnSync} = require('node:child_process');
    try { require.resolve('yaml'); console.log('yaml available'); } catch (error) { console.log(Dependency diagnostic: yaml ${error.code}; node_modules exists=${fs.existsSync(&#x27;node_modules&#x27;)}; interpreter=${process.execPath}); }
    const source = fs.readFileSync('.github/workflows/validation.yml', 'utf8');
    const mac = source.split(' - name: pnpm test (pyright-internal, macOS)\n')[1].split(' - name: Report macOS test timings\n')[0];
    const bash = mac.split(' run: |\n')[1].split(' working-directory:')[0].split('\n').map(line => line.slice(10)).join('\n');
    const syntax = spawnSync('bash', ['-n'], {input:bash, encoding:'utf8'});
    assert.equal(syntax.status, 0, syntax.stderr);
    console.log('PASS macOS test step Bash syntax');
    for (const mode of ['0', '1']) {
    const child = spawnSync(process.execPath, ['-e', const assert=require(&#x27;node:assert/strict&#x27;);const config=require(&#x27;./packages/pyright-internal/jest.config.js&#x27;);assert.deepEqual(config.sandboxInjectedGlobals,[&#x27;Math&#x27;]);const transform=Object.values(config.transform)[0][1];if(process.env.PYLANCE_JEST_TRANSPILE_ONLY===&#x27;1&#x27;){assert.equal(transform.diagnostics,false);assert.equal(transform.isolatedModules,true);}else{assert.deepEqual(transform.diagnostics,{ignoreCodes:[151002]});assert.equal(transform.tsconfig,&#x27;tsconfig.jest.json&#x27;);}], {env:{...process.env,PYLANCE_JEST_TRANSPILE_ONLY:mode},encoding:'utf8'});
    assert.equal(child.status, 0, child.stderr);
    console.log(PASS Math injection and unchanged transformer contract in mode ${mode});
    }
    const manifest = JSON.parse(fs.readFileSync('package.json', 'utf8'));
    const bootstrap = fs.readFileSync('build/installPinnedPackageManager.js', 'utf8');
    assert.ok(manifest.packageManager.startsWith('pnpm@'));
    assert.equal(manifest.scripts.installPinnedPackageManager, 'node ./build/installPinnedPackageManager.js');
    assert.equal(manifest.scripts['install:all'], 'pnpm install');
    assert.match(bootstrap, /packageManager/);
    console.log('PASS documented bootstrap commands match manifests');
    console.log(Platform coverage: ${process.platform}; macOS time/swap and hosted artifacts not executed.);
    NODE
❌ Targeted fingerprint, parser, and overload-controller Jest suites diagnostic output
[error] command timed out after 240.0s; the sandbox container was destroyed.
No test counts or individual results were returned.
❌ Existing YAML-reading workflow guards diagnostic output
Node v24.19.0, linux; constrainedMemory=8589934592, totalMemory=33627455488.
Both tests failed in _load_yaml when its Node subprocess exited 1.
2 failed in 1.16s.
A subsequent diagnostic confirmed: yaml MODULE_NOT_FOUND; node_modules exists=false; interpreter=/usr/local/bin/node.
Root package.json declares yaml ^2.9.0. pnpm install --offline --frozen-lockfile had succeeded before the preceding timeout destroyed the sandbox; dependencies were absent afterward. The single permitted bootstrap had already been used.
⚠️ Hosted macOS test timing and swap measurement diagnostic output
The workflow selects macos-latest and uses macOS /usr/bin/time -lp. Verification ran on Linux; hosted macOS timing, swap behavior, and artifact publication were not exercised.
⚠️ Dependency and test discovery diagnostic output
AUTOMATION_SANDBOX_PROFILE=typescript; Node v24.19.0; npm 11.17.0; pnpm 11.21.0.
Both node_modules directories were absent, preventing test execution at discovery. Manifests declare the listed requirements.
Git discovery was unavailable because the copied sandbox has no .git directory.
Dependencies were subsequently prepared with pnpm install --offline --frozen-lockfile, which exited 0.
❌ Workflow reporter fixtures and heap probe diagnostic output
PASS reporter: passing
PASS reporter: failing-and-escaped
PASS reporter: missing-json
PASS reporter: bounded-output
PASS workflow routing, pipefail, artifact/report conditions, Math injection, default typechecking
AssertionError: heap=4496293888 totalmem=33627455488
The reviewer assertion incorrectly compared the heap against host RAM. A subsequent diagnostic established the container's constrainedMemory=8589934592; this assertion failure is not evidence of a PR defect.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@rchiodo

Rich Chiodo (rchiodo) commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Reviewed commit: af18d44088370d38316c32f386585b461edbfdcc

Result: 🔴 could-not-verify

Verification details

Verification: Automated verification is best effort. The PR author remains responsible for testing.

Summary: [unavailable] Container verification could not start and local execution was not authorized for this PR HEAD: Could not cache pnpm@11.21.0: stderr: NVM blocked package-manager execution because a delegated command could not be trusted. Command: npm File: C:\Users\rchiodo\AppData\Local\Author Software\nvm\installs\v24.19.0\node_modules\npm\bin\npm-cli.js Reason: delegated script trust key unavailable Action: If you trust this change, run `nvm firewall trust module npm`. `nvm reshim` alone will not keep this module trusted after the next self-update. If this change was unexpected, contact your administrator and review NVM event logs. Event code: NVM4306

Test runs: none recorded.

@bschnurr
Bill Schnurr (bschnurr) merged commit b2df5a4 into microsoft:main Nov 16, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-auto:approved Automated review: no blocking findings (approval posted).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants