Skip to content

Commit

Permalink
ci(test/wasi): enable tests in multiple platforms (#894)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyf0 committed Apr 17, 2024
1 parent 4316426 commit b5b06bf
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 37 deletions.
47 changes: 11 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
with:
filters: |
rust-changes: &rust-changes
- '.github/workflows/**'
- 'crates/**'
- 'Cargo.toml'
- 'Cargo.lock'
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-node-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/reusable-wasi-test.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b5b06bf

Please sign in to comment.