Files
orca/.github/workflows/node-server-tests.yml
T

95 lines
6.4 KiB
YAML

name: Windows native report boundary diagnostic
on:
workflow_dispatch:
permissions:
contents: read
jobs:
conpty:
runs-on: windows-2022
timeout-minutes: 30
env:
ORCA_BACKGROUND_LAUNCH: '1'
JOBS: max
ORCA_VITEST_ISOLATE_EVERY_FILE: '0'
steps:
- name: Parallelize Windows checkout
shell: bash
run: |
git config --global checkout.workers 0
echo 'TrackFileAccess=false' >> "$GITHUB_ENV"
- uses: actions/checkout@v6
with:
ref: 2a9d86a4f3d7ccd29c335df6922c06455b6e99f8
persist-credentials: false
- uses: ./.github/actions/install-node-dependencies
id: dependencies
with:
native-runtime: node
cache-pnpm-store: 'false'
cache-pnpm-store-lookup-only: 'true'
- uses: ./.github/actions/prepare-orcad-prebuilds
with:
resolve-windows-cache: 'true'
restore-windows-cache: 'true'
- uses: ./.github/actions/prepare-windows-cli-launcher
with:
arches: x64
- uses: ./.github/actions/build-mobile-web-bundle
- run: pnpm build:orcad
env:
ORCA_REUSE_PREPARED_WINDOWS_SECURITY: ${{ steps.dependencies.outcome == 'success' }}
- name: Record exact source and built native identities
shell: pwsh
run: |
New-Item -ItemType Directory -Force "$env:RUNNER_TEMP/conpty-diagnostic" | Out-Null
git rev-parse HEAD | Tee-Object "$env:RUNNER_TEMP/conpty-diagnostic/source.txt"
if ((git rev-parse HEAD) -ne '2a9d86a4f3d7ccd29c335df6922c06455b6e99f8') { throw 'Unexpected source SHA' }
Get-ChildItem out/orcad -Recurse -File | Where-Object { $_.Extension -in '.node', '.dll', '.exe' } | Get-FileHash -Algorithm SHA256 | Format-Table -AutoSize | Out-String -Width 4096 | Tee-Object "$env:RUNNER_TEMP/conpty-diagnostic/native-sha256.txt"
- name: Generate diagnostic-only worker trace and config
shell: bash
env:
ORCA_DIAGNOSTIC_TRACE_DIR: ${{ runner.temp }}/conpty-diagnostic
run: |
node --input-type=module <<'JS'
import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
import { createHash } from 'node:crypto'
const dir = '.build/conpty-diagnostic'
mkdirSync(dir, { recursive: true })
const setup = "import { appendFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { afterAll, beforeAll, beforeEach, expect } from 'vitest'\n\nconst tracePath = join(process.env.ORCA_DIAGNOSTIC_TRACE_DIR, `worker-${process.pid}.jsonl`)\nfunction record(event) {\n appendFileSync(tracePath, JSON.stringify({\n event,\n file: expect.getState().testPath,\n test: expect.getState().currentTestName,\n pid: process.pid,\n ppid: process.ppid,\n worker: process.env.VITEST_WORKER_ID,\n pool: process.env.VITEST_POOL_ID,\n monotonicNs: process.hrtime.bigint().toString()\n }) + '\\n')\n}\nrecord('setup')\nbeforeAll(() => record('file-start'))\nbeforeEach(() => record('test-start'))\nafterAll(() => record('file-end'))\n\nif (expect.getState().testPath?.endsWith('/orcad-windows-conpty-breakaway.integration.test.ts')) {\n const report = process.report\n const originalGetReport = report?.getReport\n if (typeof originalGetReport === 'function') {\n function tracedGetReport(...args) {\n record('report-enter')\n let result\n try {\n result = Reflect.apply(originalGetReport, this, args)\n } catch (error) {\n record('report-throw')\n throw error\n }\n record('report-return')\n return result\n }\n report.getReport = tracedGetReport\n record('report-wrapper-installed')\n afterAll(() => {\n if (report.getReport === tracedGetReport) {\n report.getReport = originalGetReport\n }\n record('report-wrapper-restored')\n })\n } else {\n record('report-function-missing')\n }\n}\n";
const config = "import { resolve } from 'node:path'\nimport base from '../../config/vitest.config'\n\nconst traceSetup = resolve('.build/conpty-diagnostic/worker-trace.mjs')\nexport default {\n ...base,\n test: {\n ...base.test,\n projects: base.test.projects.map((project) => ({\n ...project,\n test: {\n ...project.test,\n setupFiles: [...project.test.setupFiles, traceSetup]\n }\n }))\n }\n}\n";
writeFileSync(dir + '/worker-trace.mjs', setup)
writeFileSync(dir + '/vitest.config.mts', config)
const wrapperPath = 'config/scripts/ci/unit-selection/run-node-server-tests.mjs'
const original = readFileSync(wrapperPath, 'utf8')
const oldPath = "'config/vitest.config.ts'"
if (original.split(oldPath).length !== 2) throw new Error('Unexpected wrapper config selection')
const diagnostic = original.replace(oldPath, "'.build/conpty-diagnostic/vitest.config.mts'")
writeFileSync(wrapperPath.replace('.mjs', '.diagnostic.mjs'), diagnostic)
for (const [name, body] of Object.entries({ 'worker-trace.mjs': setup, 'vitest.config.mts': config, 'original-wrapper.mjs': original, 'diagnostic-wrapper.mjs': diagnostic })) {
writeFileSync(process.env.ORCA_DIAGNOSTIC_TRACE_DIR + '/' + name, body)
console.log(name, createHash('sha256').update(body).digest('hex'))
}
JS
git diff --exit-code
- name: Full original artifact suite with worker identity tracing
shell: pwsh
env:
ORCA_DIAGNOSTIC_TRACE_DIR: ${{ runner.temp }}/conpty-diagnostic
run: |
node -e "console.log(JSON.stringify({source: '2a9d86a4f3d7ccd29c335df6922c06455b6e99f8', availableParallelism: require('node:os').availableParallelism(), isolation: process.env.ORCA_VITEST_ISOLATE_EVERY_FILE}))" | Tee-Object "$env:RUNNER_TEMP/conpty-diagnostic/policy.json"
node config/scripts/ci/unit-selection/run-node-server-tests.diagnostic.mjs --artifact 2>&1 | Tee-Object "$env:RUNNER_TEMP/conpty-diagnostic/full-suite.log"
$testExit = $LASTEXITCODE
"exit=$testExit" | Add-Content "$env:RUNNER_TEMP/conpty-diagnostic/full-suite.log"
exit $testExit
- name: Upload diagnostic evidence
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v7
with:
name: conpty-diagnostic-${{ github.run_id }}
path: ${{ runner.temp }}/conpty-diagnostic/
if-no-files-found: warn
retention-days: 7