Skip to content

Node.js SDK Tests #3043

Node.js SDK Tests

Node.js SDK Tests #3043

name: "Node.js SDK Tests"
env:
HUSKY: 0
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- "nodejs/**"
- "test/**"
- ".github/workflows/nodejs-sdk-tests.yml"
- "!nodejs/scripts/**"
- "!**/*.md"
- "!**/LICENSE*"
- "!**/.gitignore"
- "!**/.editorconfig"
- "!**/*.png"
- "!**/*.jpg"
- "!**/*.jpeg"
- "!**/*.gif"
- "!**/*.svg"
workflow_dispatch:
merge_group:
permissions:
contents: read
jobs:
test:
name: "Node.js SDK Tests (${{ matrix.os }}, ${{ matrix.transport }})"
if: github.event.repository.fork == false
env:
POWERSHELL_UPDATECHECK: Off
strategy:
fail-fast: false
matrix:
os: [windows-latest]
transport: ["inprocess"]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
working-directory: ./nodejs
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-node@v6
with:
cache: "npm"
cache-dependency-path: "./nodejs/package-lock.json"
node-version: 22
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Run prettier check
if: runner.os == 'Linux'
run: npm run format:check
- name: Run ESLint
run: npm run lint
- name: Typecheck SDK
run: npm run typecheck
- name: Build SDK
run: npm run build
- name: Install test harness dependencies
working-directory: ./test/harness
run: npm ci --ignore-scripts
- name: Warm up PowerShell
if: runner.os == 'Windows'
run: pwsh.exe -Command "Write-Host 'PowerShell ready'"
- name: Select inprocess transport
if: matrix.transport == 'inprocess'
run: |
echo "COPILOT_SDK_DEFAULT_CONNECTION=inprocess" >> "$GITHUB_ENV"
echo "COPILOT_SDK_TEST_DIAGNOSTICS=1" >> "$GITHUB_ENV"
- name: Run Node.js SDK tests
env:
COPILOT_HMAC_KEY: ${{ secrets.COPILOT_DEVELOPER_CLI_INTEGRATION_HMAC_KEY }}
COPILOT_SDK_PRESERVE_TEST_HOME: "1"
run: |
pwsh.exe -NoProfile -Command '
while ($true) {
$cpu = [math]::Round((Get-Counter "\Processor(_Total)\% Processor Time").CounterSamples.CookedValue)
$memory = [math]::Round((Get-Counter "\Memory\Available MBytes").CounterSamples.CookedValue)
$nodeCount = @(Get-Process -Name node -ErrorAction SilentlyContinue).Count
Write-Host "[resource-diagnostic] $(Get-Date -Format o) cpu=$cpu availableMb=$memory nodeProcesses=$nodeCount"
Start-Sleep -Seconds 5
}
' &
monitor_pid=$!
trap 'kill "$monitor_pid"' EXIT
npm test
- name: Collect runtime diagnostics
if: failure()
shell: pwsh
run: |
$paths = Get-ChildItem $env:TEMP -Directory -Filter "copilot-test-home-*"
if ($paths) {
Compress-Archive -Path $paths.FullName -DestinationPath runtime-diagnostics.zip
}
- name: Upload runtime diagnostics
if: failure()
uses: actions/upload-artifact@v4
with:
name: nodejs-runtime-diagnostics
path: nodejs/runtime-diagnostics.zip