Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 19, 2025

The test-reference-server.yml workflow was failing on Windows with the error:

SERVER_PID=$!: The term 'SERVER_PID=$!' is not recognized as a name of a cmdlet

This occurred because the workflow used bash-specific syntax (SERVER_PID=$!, kill $SERVER_PID) in the "Start server (smoke test)" step, which doesn't work in PowerShell on Windows runners.

Solution

Replaced the bash-specific inline server lifecycle management with the existing cross-platform Node.js tests that properly handle server startup and shutdown using child_process.spawn().

Key Changes

  1. Removed bash-specific workflow step: Eliminated 20 lines of bash code that used npm start &, SERVER_PID=$!, and kill $SERVER_PID

  2. Enhanced existing npm test: Modified the "Test reference server" step to run without continue-on-error, making it the primary test mechanism

  3. Fixed Node.js test file: Updated reference-server/test/server.test.js to:

    • Use CommonJS syntax to match TypeScript output format
    • Correct health endpoint assertions to match actual API response (status and timestamp fields)
    • Fix npm test glob pattern from test/**/*.test.js to test/*.test.js

Before vs After

Before (bash-specific):

run: |
  npm start &
  SERVER_PID=$!
  sleep 10
  curl -f http://localhost:3000/health || exit 1
  kill $SERVER_PID

After (cross-platform):

run: npm test

The Node.js test properly manages server lifecycle using spawn('npm', ['start']) and server.kill('SIGTERM'), which works consistently across all platforms.

Testing

Verified the complete workflow sequence passes on Linux:

  • ✅ Install dependencies
  • ✅ Lint reference server
  • ✅ Build reference server
  • ✅ Test reference server (health + OpenAPI endpoints)

This solution follows the repository's "script-first approach" philosophy where workflows call scripts that can be run locally, enabling easier debugging and development.

Fixes #5.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: horner <6094599+horner@users.noreply.github.com>
Copilot AI changed the title [WIP] Pre-publish Tests / Test on Node.js 18 (windows-latest) is failing Fix Windows PowerShell compatibility in reference server tests Aug 19, 2025
Copilot AI requested a review from horner August 19, 2025 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pre-publish Tests / Test on Node.js 18 (windows-latest) is failing

2 participants