Test Published Package #298
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: Test Published Package | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 */12 * * *" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| test-published: | |
| name: Test Published (${{ matrix.name }}) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: Linux x64 glibc | |
| runner: ubuntu-latest | |
| - name: Linux arm64 glibc | |
| runner: ubuntu-24.04-arm | |
| - name: macOS arm64 | |
| runner: macos-latest | |
| - name: Windows x64 | |
| runner: windows-latest | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22.x" | |
| - name: Debug Environment | |
| run: node -p "process.platform + ' ' + process.arch" | |
| - name: Prepare Test Project | |
| shell: pwsh | |
| run: | | |
| $testDir = Join-Path $env:RUNNER_TEMP "zvec-published-test" | |
| Remove-Item -Recurse -Force $testDir -ErrorAction SilentlyContinue | |
| New-Item -ItemType Directory -Force $testDir | Out-Null | |
| Copy-Item -Recurse tests -Destination (Join-Path $testDir "tests") | |
| Copy-Item jest.config.json -Destination $testDir | |
| Copy-Item tsconfig.json -Destination $testDir | |
| node scripts/patch-imports.js (Join-Path $testDir "tests") '@zvec/zvec' | |
| Set-Location $testDir | |
| npm init -y | |
| npm install --no-package-lock --save-dev '@types/jest@^29.5.0' 'jest@^29.7.0' 'ts-jest@^29.1.2' 'typescript@^5.9.3' | |
| npm install --no-package-lock '@zvec/zvec@latest' | |
| - name: Verify Installed Version | |
| shell: pwsh | |
| run: | | |
| Set-Location (Join-Path $env:RUNNER_TEMP "zvec-published-test") | |
| npm ls '@zvec/zvec' | |
| - name: Smoke Test Entry Points | |
| shell: pwsh | |
| run: | | |
| Set-Location (Join-Path $env:RUNNER_TEMP "zvec-published-test") | |
| node -e "require('@zvec/zvec')" | |
| node --input-type=module -e "await import('@zvec/zvec')" | |
| - name: Run Unit Tests | |
| shell: pwsh | |
| run: | | |
| Set-Location (Join-Path $env:RUNNER_TEMP "zvec-published-test") | |
| npx jest | |
| test-published-musl: | |
| name: Test Published (${{ matrix.name }}) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: Linux x64 musl | |
| runner: ubuntu-24.04 | |
| bindings_package: "@zvec/bindings-linux-x64-musl" | |
| - name: Linux arm64 musl | |
| runner: ubuntu-24.04-arm | |
| bindings_package: "@zvec/bindings-linux-arm64-musl" | |
| runs-on: ${{ matrix.runner }} | |
| env: | |
| MUSL_CONTAINER: zvec-node-published-musl | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Start musllinux Container | |
| run: | | |
| docker run -d --name "$MUSL_CONTAINER" \ | |
| -v "$GITHUB_WORKSPACE:/work:ro" \ | |
| -w /work \ | |
| node:22-alpine sleep infinity | |
| - name: Prepare Test Project | |
| run: | | |
| docker exec "$MUSL_CONTAINER" sh -c ' | |
| TEST_DIR=/tmp/zvec-published-test | |
| rm -rf "$TEST_DIR" | |
| mkdir -p "$TEST_DIR" | |
| cp -R /work/tests "$TEST_DIR/tests" | |
| cp /work/jest.config.json /work/tsconfig.json "$TEST_DIR" | |
| node /work/scripts/patch-imports.js "$TEST_DIR/tests" "@zvec/zvec" | |
| cd "$TEST_DIR" | |
| npm init -y | |
| npm install --no-package-lock --save-dev \ | |
| "@types/jest@^29.5.0" \ | |
| "jest@^29.7.0" \ | |
| "ts-jest@^29.1.2" \ | |
| "typescript@^5.9.3" | |
| npm install --no-package-lock "@zvec/zvec@latest" | |
| ' | |
| - name: Verify Installed Version | |
| run: | | |
| docker exec \ | |
| -w /tmp/zvec-published-test \ | |
| "$MUSL_CONTAINER" \ | |
| npm ls '@zvec/zvec' "${{ matrix.bindings_package }}" | |
| - name: Smoke Test Entry Points | |
| run: | | |
| docker exec \ | |
| -w /tmp/zvec-published-test \ | |
| "$MUSL_CONTAINER" \ | |
| node -e "require('@zvec/zvec')" | |
| docker exec \ | |
| -w /tmp/zvec-published-test \ | |
| "$MUSL_CONTAINER" \ | |
| node --input-type=module -e "await import('@zvec/zvec')" | |
| - name: Run Unit Tests | |
| run: | | |
| docker exec \ | |
| -w /tmp/zvec-published-test \ | |
| "$MUSL_CONTAINER" \ | |
| npx jest --runInBand | |
| - name: Tear Down musllinux Container | |
| if: always() | |
| run: docker rm -f "$MUSL_CONTAINER" || true |