test: add Bazel runfiles source aggregation #16
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: test npm | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| name: Build npm packages | |
| runs-on: macos-15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Bazel | |
| uses: bazel-contrib/setup-bazel@0.19.0 | |
| with: | |
| bazelisk-cache: true | |
| disk-cache: ${{ github.workflow }}-build | |
| repository-cache: true | |
| - name: Build npm packages | |
| run: | | |
| bazel build \ | |
| //crates/codescythe_napi:release_nodes \ | |
| //packages/codescythe:package \ | |
| //packages/codescythe-darwin-arm64:package \ | |
| //packages/codescythe-linux-amd64:package \ | |
| //packages/codescythe-linux-arm64:package | |
| - name: Prepare smoke artifacts | |
| run: | | |
| set -euo pipefail | |
| mkdir -p artifacts | |
| copy_loader_package() { | |
| local pkg="$1" | |
| local out="artifacts/$pkg" | |
| mkdir -p "$out" | |
| cp "packages/$pkg/README.md" "$out/" | |
| cp "packages/$pkg/index.d.ts" "$out/" | |
| cp "packages/$pkg/index.ts" "$out/" | |
| cp "packages/$pkg/package.json" "$out/" | |
| cp -R "packages/$pkg/bin" "$out/" | |
| } | |
| copy_native_package() { | |
| local pkg="$1" | |
| local target="$2" | |
| local node_file="$3" | |
| local out="artifacts/$pkg" | |
| local built_node | |
| mkdir -p "$out" | |
| cp "packages/$pkg/README.md" "$out/" | |
| cp "packages/$pkg/index.ts" "$out/" | |
| cp "packages/$pkg/package.json" "$out/" | |
| built_node="$(bazel cquery --output=files "$target" | tail -n 1)" | |
| cp "$built_node" "$out/$node_file" | |
| } | |
| copy_loader_package codescythe | |
| copy_native_package codescythe-darwin-arm64 //packages/codescythe-darwin-arm64:native_node codescythe.darwin-arm64.node | |
| copy_native_package codescythe-linux-amd64 //packages/codescythe-linux-amd64:native_node codescythe.linux-amd64.node | |
| copy_native_package codescythe-linux-arm64 //packages/codescythe-linux-arm64:native_node codescythe.linux-arm64.node | |
| - name: Upload loader package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: codescythe | |
| path: artifacts/codescythe | |
| retention-days: 7 | |
| - name: Upload Darwin arm64 package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: codescythe-darwin-arm64 | |
| path: artifacts/codescythe-darwin-arm64 | |
| retention-days: 7 | |
| - name: Upload Linux amd64 package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: codescythe-linux-amd64 | |
| path: artifacts/codescythe-linux-amd64 | |
| retention-days: 7 | |
| - name: Upload Linux arm64 package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: codescythe-linux-arm64 | |
| path: artifacts/codescythe-linux-arm64 | |
| retention-days: 7 | |
| smoke: | |
| name: Smoke test npm (${{ matrix.name }}) | |
| needs: build | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: darwin-arm64 | |
| runner: macos-15 | |
| package: codescythe-darwin-arm64 | |
| - name: linux-amd64 | |
| runner: ubuntu-24.04 | |
| package: codescythe-linux-amd64 | |
| - name: linux-arm64 | |
| runner: ubuntu-24.04-arm | |
| package: codescythe-linux-arm64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Enable pnpm | |
| run: corepack enable pnpm | |
| - name: Install npm test dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Download loader package | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: codescythe | |
| path: smoke/codescythe | |
| - name: Download native package | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ matrix.package }} | |
| path: smoke/${{ matrix.package }} | |
| - name: Smoke test package | |
| run: | | |
| set -euo pipefail | |
| CODESCYTHE_PACKAGE_DIR=smoke/codescythe \ | |
| CODESCYTHE_NATIVE_PACKAGE_DIR=smoke/${{ matrix.package }} \ | |
| pnpm test:npm | |
| if [ "${{ runner.os }}" = "Linux" ]; then | |
| native_node="$(find "smoke/${{ matrix.package }}" -name '*.node' -print -quit)" | |
| file "$native_node" | |
| ldd_output="$(ldd "$native_node" 2>&1 || true)" | |
| echo "$ldd_output" | |
| if echo "$ldd_output" | grep -q 'not found'; then | |
| echo "$native_node has missing runtime libraries" >&2 | |
| exit 1 | |
| fi | |
| fi |