fix: Windows compatibility for npm scripts and cross-platform CI #325
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| name: Linux x64 | |
| - os: ubuntu-24.04-arm | |
| name: Linux ARM64 | |
| - os: windows-latest | |
| name: Windows x64 | |
| - os: windows-11-arm | |
| name: Windows ARM64 | |
| # Use x64-baseline build via emulation (native ARM64 not yet available) | |
| bun-download-url: https://github.com/oven-sh/bun/releases/latest/download/bun-windows-x64-baseline.zip | |
| - os: macos-latest | |
| name: macOS ARM64 | |
| name: Build (${{ matrix.name }}) | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Verify no private URLs in package-lock.json | |
| shell: bash | |
| run: '! grep -E "\"resolved\": \"https?://" package-lock.json | grep -v registry.npmjs.org' | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| bun-download-url: ${{ matrix.bun-download-url }} | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - run: npm install | |
| # Build SDK (all platforms) and examples (Unix only - they use INPUT=... syntax) | |
| - run: npm run build | |
| - name: Build examples | |
| if: runner.os != 'Windows' | |
| run: npm run examples:build | |
| - name: Verify generated schemas are up-to-date | |
| shell: bash | |
| run: | | |
| npm run generate:schemas | |
| git diff --exit-code src/generated/ || (echo "Generated schemas are out of date. Run 'npm run generate:schemas' and commit." && exit 1) | |
| - run: npm test | |
| - run: npm run prettier | |
| # Test build in Windows WSL (Ubuntu) | |
| build-wsl: | |
| name: Build (Windows WSL) | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: Vampire/setup-wsl@v5 | |
| with: | |
| distribution: Ubuntu-24.04 | |
| - name: Install dependencies in WSL | |
| shell: wsl-bash {0} | |
| run: | | |
| # Install Node.js and Bun | |
| sudo apt-get update | |
| sudo apt-get install -y unzip | |
| curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - | |
| sudo apt-get install -y nodejs | |
| curl -fsSL https://bun.sh/install | bash | |
| echo 'export BUN_INSTALL="$HOME/.bun"' >> ~/.bashrc | |
| echo 'export PATH="$BUN_INSTALL/bin:$PATH"' >> ~/.bashrc | |
| - name: Build and test in WSL | |
| shell: wsl-bash {0} | |
| run: | | |
| export BUN_INSTALL="$HOME/.bun" | |
| export PATH="$BUN_INSTALL/bin:$PATH" | |
| npm install | |
| npm run build | |
| npm test | |
| npm run prettier | |
| # Test that the package can be installed from git (triggers prepare script) | |
| test-git-install: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| name: Linux x64 | |
| - os: ubuntu-24.04-arm | |
| name: Linux ARM64 | |
| - os: windows-latest | |
| name: Windows x64 | |
| - os: windows-11-arm | |
| name: Windows ARM64 | |
| bun-download-url: https://github.com/oven-sh/bun/releases/latest/download/bun-windows-x64-baseline.zip | |
| - os: macos-latest | |
| name: macOS ARM64 | |
| name: Test git install (${{ matrix.name }}) | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| bun-download-url: ${{ matrix.bun-download-url }} | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Create test project and install from git | |
| shell: bash | |
| run: | | |
| mkdir test-project | |
| cd test-project | |
| npm init -y | |
| # Install from the PR branch | |
| npm install "git+https://github.com/${{ github.repository }}#${{ github.head_ref || github.ref_name }}" | |
| # Verify the package is usable (ESM import) | |
| node --input-type=module -e "import { App } from '@modelcontextprotocol/ext-apps'; console.log('Import successful:', typeof App)" |