From b5b06bfed59cb8089da1d77937fdd2b82f44106e Mon Sep 17 00:00:00 2001 From: Yunfei He Date: Wed, 17 Apr 2024 13:00:13 +0800 Subject: [PATCH] ci(test/wasi): enable tests in multiple platforms (#894) --- .github/workflows/ci.yml | 47 ++++------------ .github/workflows/reusable-node-test.yml | 2 +- .github/workflows/reusable-wasi-test.yml | 71 ++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/reusable-wasi-test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c243bd442..2c240795c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,7 @@ jobs: with: filters: | rust-changes: &rust-changes + - '.github/workflows/**' - 'crates/**' - 'Cargo.toml' - 'Cargo.lock' @@ -89,42 +90,6 @@ jobs: - name: Lint run: just lint-rust - build-wasi: - name: Build WASI - runs-on: ubuntu-latest - needs: changes - if: needs.changes.outputs.rust-changes == 'true' - steps: - - uses: actions/checkout@v4 - - uses: moonrepo/setup-rust@v1 - with: - targets: wasm32-wasi-preview1-threads - cache-base: main - - name: Install pnpm - uses: pnpm/action-setup@v3 - - - name: Install node - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: pnpm - - - name: Install dependencies - # Node.js wasi runtime has bug with `std::fs::read_link` - run: | - touch .npmrc - echo "node-linker=hoisted" >> .npmrc - pnpm install - - - name: Build wasi - run: | - pnpm --filter=rolldown build-binding:wasi:release - pnpm --filter=rolldown build-node - pnpm --filter=@example/basic build - env: - NAPI_RS_FORCE_WASI: 1 - RUST_LOG: trace - cargo-test: needs: changes strategy: @@ -145,6 +110,16 @@ jobs: os: ${{ matrix.target }} changed: ${{ needs.changes.outputs.node-changes == 'true' }} + wasi-test: + needs: changes + strategy: + matrix: + target: [ubuntu-latest, macos-latest, windows-latest] + uses: ./.github/workflows/reusable-wasi-test.yml + with: + os: ${{ matrix.target }} + changed: ${{ needs.changes.outputs.node-changes == 'true' }} + node-validation: name: Node Validation needs: changes diff --git a/.github/workflows/reusable-node-test.yml b/.github/workflows/reusable-node-test.yml index 1abd4165ee..f9afc0df8c 100644 --- a/.github/workflows/reusable-node-test.yml +++ b/.github/workflows/reusable-node-test.yml @@ -41,7 +41,7 @@ jobs: - name: Install dependencies run: pnpm install - - name: Build Rolldown with native binding + - name: Build Native Rolldown run: just build native - name: Type Check diff --git a/.github/workflows/reusable-wasi-test.yml b/.github/workflows/reusable-wasi-test.yml new file mode 100644 index 0000000000..b9eb5b5c03 --- /dev/null +++ b/.github/workflows/reusable-wasi-test.yml @@ -0,0 +1,71 @@ +name: WASI Test + +on: + workflow_call: + inputs: + os: + required: true + type: string + changed: + required: true + type: boolean + +jobs: + run: + name: WASI Test + if: ${{ inputs.changed }} + runs-on: ${{ inputs.os }} + timeout-minutes: 15 + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v4 + with: + submodules: true # Pull submodules for additional files + + - name: Install Rust + uses: moonrepo/setup-rust@v1 + with: + bins: just + cache-base: main + targets: wasm32-wasi-preview1-threads + + - name: Install pnpm + uses: pnpm/action-setup@v3 + + - name: Install node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm + + - name: Pnpm install + # Node.js wasi runtime has bug with `std::fs::read_link` + run: | + touch .npmrc + echo "node-linker=hoisted" >> .npmrc + pnpm install + + - name: Build WASI Rolldown + run: just build wasi release + + - name: Build Basic Example + run: pnpm --filter=@example/basic build + if: ${{ inputs.os == 'ubuntu-latest' }} + env: + NAPI_RS_FORCE_WASI: 1 + RUST_LOG: trace + + - name: Node Test + run: pnpm run --recursive --filter=!rollup-tests test + if: false + env: + NAPI_RS_FORCE_WASI: 1 + RUST_LOG: trace + + - name: Rollup Test + run: pnpm run --filter rollup-tests test + if: false + env: + NAPI_RS_FORCE_WASI: 1 + RUST_LOG: trace