Wasm build and test #9619
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: Wasm build and test | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - "**" # target all branches | |
| schedule: | |
| - cron: '15 0 * * *' # every day at 00:15 UTC | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_LOG: debug | |
| RUST_BACKTRACE: full | |
| jobs: | |
| wasm_with_nodejs: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [18.x] | |
| steps: | |
| - name: Checkout the repository | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - name: Update the list of available system packages | |
| run: sudo apt-get update | |
| - name: Install build dependencies | |
| run: sudo apt-get install -yqq --no-install-recommends build-essential pkg-config libssl-dev | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version-file: './build-tools/.python-version' | |
| - name: Install Rust | |
| run: | | |
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ | |
| --default-toolchain $(python ./build-tools/cargo-info-extractor/extract.py --rust-version) | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - name: Install TypeScript & Knip | |
| run: npm install typescript knip | |
| - name: Install wasm-pack | |
| run: cargo install wasm-pack | |
| - name: Build the wasm module | |
| working-directory: ./wasm-wrappers | |
| run: wasm-pack build --target nodejs | |
| - name: Compile the tests | |
| working-directory: ./wasm-wrappers | |
| run: tsc --project js-bindings-test/tsconfig.json | |
| - name: Run the tests | |
| working-directory: ./wasm-wrappers | |
| run: node --enable-source-maps js-bindings-test/node-entry.js | |
| - name: Run Knip | |
| working-directory: ./wasm-wrappers/js-bindings-test | |
| run: npx knip | |
| wasm_artifacts: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout the repository | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| - name: Update the list of available system packages | |
| run: sudo apt-get update | |
| - name: Install build dependencies | |
| run: sudo apt-get install -yqq --no-install-recommends build-essential pkg-config libssl-dev | |
| - name: Install Rust | |
| run: | | |
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ | |
| --default-toolchain $(python ./build-tools/cargo-info-extractor/extract.py --rust-version) | |
| - name: Install wasm-pack | |
| run: cargo install wasm-pack | |
| - name: Build the wasm module for nodejs - release | |
| working-directory: ./wasm-wrappers | |
| run: wasm-pack build --target nodejs --out-dir wasm-wrappers-builds/nodejs/release --release | |
| - name: Build the wasm module for nodejs - debug | |
| working-directory: ./wasm-wrappers | |
| run: wasm-pack build --target nodejs --out-dir wasm-wrappers-builds/nodejs/debug --debug | |
| - name: Build the wasm module for web - release | |
| working-directory: ./wasm-wrappers | |
| run: wasm-pack build --target web --out-dir wasm-wrappers-builds/web/release --release | |
| - name: Build the wasm module for web - debug | |
| working-directory: ./wasm-wrappers | |
| run: wasm-pack build --target web --out-dir wasm-wrappers-builds/web/debug --debug | |
| - name: Build the wasm module for bundler - release | |
| working-directory: ./wasm-wrappers | |
| run: wasm-pack build --target bundler --out-dir wasm-wrappers-builds/bundler/release --release | |
| - name: Build the wasm module for bundler - debug | |
| working-directory: ./wasm-wrappers | |
| run: wasm-pack build --target bundler --out-dir wasm-wrappers-builds/bundler/debug --debug | |
| - name: Copy readme file into the package | |
| working-directory: ./wasm-wrappers | |
| run: cp README.md wasm-wrappers-builds/ && cp WASM-API.md wasm-wrappers-builds/ | |
| - name: Create artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wasm_builds | |
| path: | | |
| ./wasm-wrappers/wasm-wrappers-builds |