Skip to content

chore: add cpp and python build toolchains #5753

chore: add cpp and python build toolchains

chore: add cpp and python build toolchains #5753

Workflow file for this run

name: test
on:
merge_group:
push:
branches:
- main
pull_request:
branches:
- main
defaults:
run:
shell: bash
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions: {}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "latest"
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
with:
version: 11
- name: Install Rust
run: rustup update stable --no-self-update
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
shared-key: jco-${{ hashFiles('Cargo.lock') }}
- name: Enable sccache
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10
- name: Setup sccache
run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
- name: Cache node modules
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
- name: Install node modules
run: pnpm install
- name: Build jco for test
working-directory: packages/jco
run: |
pnpm --filter '@bytecodealliance/jco' run build
pnpm --filter '@bytecodealliance/jco' run build:test:components
- name: Upload jco build output
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: build
path: packages/jco/obj
- name: Upload artifacts for js tests
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: js-generated-tests
path: packages/jco/test/output
- name: Build jco-transpile
run: pnpm --filter '@bytecodealliance/jco-transpile' run build
- name: Upload jco-transpile vendor
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: jco-transpile-vendor
path: |
packages/jco-transpile/vendor
test-jco:
runs-on: ${{ matrix.os }}
needs:
- build
strategy:
matrix:
os:
- ubuntu-22.04 # https://github.com/puppeteer/puppeteer/issues/12818#issuecomment-2593659514
- macos-latest
node:
- 20.x
- 22.x
- 24.x
- latest # 26.x
include:
- os: ubuntu-22.04
weval-bin-path: .weval-bin/weval
- os: macos-latest
weval-bin-path: .weval-bin/weval
exclude:
- os: macos-latest
node: 20.x
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ matrix.node }}
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
with:
version: 11
- uses: taiki-e/cache-cargo-install-action@417450f3c33ee20393705369577571770643d4c7 # v3.0.7
with:
tool: wasm-tools@1.244.0
# Determine weval version
- name: Determine weval version
id: weval-meta
run: |
export WEVAL_LATEST_URL=`curl -Ls -o /dev/null -w %{url_effective} https://github.com/bytecodealliance/weval/releases/latest`
export WEVAL_VERSION=${WEVAL_LATEST_URL#https://github.com/bytecodealliance/weval/releases/tag/}
echo -e "version=$WEVAL_VERSION" >> $GITHUB_OUTPUT
# Use cached weval bin if present
- name: Cache weval bin
id: cache-weval-bin
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: .weval-bin
key: weval-bin-${{ steps.weval-meta.outputs.version }}-${{ matrix.os }}
# (no cached weval bin) download weval release
- if: ${{ steps.cache-weval-bin.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu') }}
run: |
curl -LO https://github.com/bytecodealliance/weval/releases/download/${{ steps.weval-meta.outputs.version }}/weval-${{ steps.weval-meta.outputs.version }}-x86_64-linux.tar.xz
tar -xvJf weval-${{ steps.weval-meta.outputs.version }}-x86_64-linux.tar.xz
mv weval-${{ steps.weval-meta.outputs.version }}-x86_64-linux/weval .weval-bin
- if: ${{ steps.cache-weval-bin.outputs.cache-hit != 'true' && startsWith(matrix.os, 'macos') }}
run: |
curl -LO https://github.com/bytecodealliance/weval/releases/download/${{ steps.weval-meta.outputs.version }}/weval-${{ steps.weval-meta.outputs.version }}-aarch64-macos.tar.xz
tar -xvJf weval-${{ steps.weval-meta.outputs.version }}-aarch64-macos.tar.xz
mkdir .weval-bin
mv weval-${{ steps.weval-meta.outputs.version }}-aarch64-macos/weval .weval-bin/
- name: Install NPM packages
run: pnpm install
- name: Cache puppeteer install
if: ${{ startsWith(matrix.os, 'ubuntu') }}
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: puppeteer-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
/home/runner/.cache/puppeteer
- name: Cache puppeteer install
if: ${{ startsWith(matrix.os, 'macos') }}
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: puppeteer-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
/Users/runner/.cache/puppeteer
# NOTE: We can stop pinning the version of puppeteer when the version that the mac atttempts to use
# syncs up (right now newest is 148.0.7778.178, but puppeteer will attempt to use 148.0.7778.97)
- name: Install puppeteer (pinned)
if: ${{ matrix.node == 'latest' }}
run: |
export PUPPETEER_VERSION=148.0.7778.97
pnpm run test:setup:puppeteer
- name: Install puppeteer
if: ${{ matrix.node != 'latest' }}
run: |
pnpm run test:setup:puppeteer
- name: Restore jco build output
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: build
path: packages/jco/obj
- name: Restore artifacts for JS tests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: js-generated-tests
path: packages/jco/test/output
- name: Test LTS Node.js
if: matrix.node != 'latest'
working-directory: packages/jco
run: |
pnpm --filter '@bytecodealliance/jco' run test:lts -- --maxWorkers 4 --minWorkers 2 --maxConcurrency 2
- name: Test Latest Node.js
if: matrix.node == 'latest'
working-directory: packages/jco
env:
WEVAL_BIN_PATH: ${{ matrix.weval-bin-path }}
run: |
pnpm --filter '@bytecodealliance/jco' run test -- --maxWorkers 4 --minWorkers 2 --maxConcurrency 2
test-wasi-deno:
runs-on: "ubuntu-latest"
needs:
- build
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: recursive
- name: Install Rust deps
run: |
rustup update stable --no-self-update && rustup default stable
rustup target add wasm32-unknown-unknown
rustup target add wasm32-wasip1
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "latest"
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
with:
version: 11
- uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282 # v2.0.4
with:
deno-version: v1.x
- name: Cache node modules
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
- name: Install node modules
run: pnpm install
- name: Restore jco build output
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: build
path: packages/jco/obj
- name: Restore artifacts for JS tests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: js-generated-tests
path: packages/jco/test/output
- name: Generate tests
run: |
cargo xtask generate tests preview2
- name: WASI Preview 2 Conformance
run: cargo test deno_
test-wasi-node:
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
node:
- 20.x
- 22.x
- 24.x
- latest
fail-fast: false
runs-on: ${{ matrix.os }}
needs:
- build
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: recursive
- name: Install Rust deps
run: |
rustup update stable --no-self-update && rustup default stable
rustup target add wasm32-unknown-unknown
rustup target add wasm32-wasip1
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ matrix.node }}
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
with:
version: 11
- name: Cache node modules
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
- name: Restore jco build output
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: build
path: packages/jco/obj
- name: Restore artifacts for JS tests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: js-generated-tests
path: packages/jco/test/output
- name: Install node modules
run: pnpm install
- name: Generate tests
run: |
cargo xtask generate tests preview2
- name: WASI Preview 2 Conformance
run: |
cargo test node_
test-shims:
runs-on: ubuntu-latest
strategy:
matrix:
workspace:
- preview2-shim
- preview3-shim
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust
run: rustup update stable --no-self-update
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
shared-key: jco-${{ hashFiles('Cargo.lock') }}
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
with:
version: 11
- name: Cache node modules
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
- name: Install node modules
run: pnpm install
- name: Cache puppeteer install
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: puppeteer-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
/home/runner/.cache/puppeteer
- name: Install puppeteer
run: |
pnpm run test:setup:puppeteer
- name: Build jco
run: pnpm run build
- name: Test Workspaces
env:
TEST_PUPPETEER_LAUNCH_ARGS: |
--no-sandbox
run: pnpm --filter 'packages/${{ matrix.workspace }}' run test
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
with:
version: 11
- name: Cache node modules
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
- name: Install node modules
run: pnpm install
- name: Lint
run: pnpm run lint
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
with:
version: 11
- name: Cache node modules
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
- name: Install node modules
run: pnpm install
- name: Format
run: pnpm run fmt:check
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add rustfmt
- name: Remove tests mod
run: rm -r crates/jco/tests/mod.rs
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Format source code
run: cargo fmt -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Rust
run: rustup update stable && rustup default stable
- name: Remove tests mod
run: rm -r crates/jco/tests/mod.rs
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
- name: Run clippy
run: cargo clippy --workspace --all-features --all-targets --keep-going -- -D warnings
test-jco-std:
runs-on: ubuntu-latest
strategy:
matrix:
workspace:
- jco-std
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install Rust
run: rustup update stable --no-self-update
- uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
shared-key: jco-${{ hashFiles('Cargo.lock') }}
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
with:
version: 11
- name: Cache node modules
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
- uses: taiki-e/cache-cargo-install-action@417450f3c33ee20393705369577571770643d4c7 # v3.0.7
with:
tool: wasmtime-cli@40.0.2
- name: Install node modules
working-directory: packages/${{ matrix.workspace }}
run: |
pnpm install
- name: Build jco-transpile, jco-std
run: |
pnpm --filter "packages/jco-transpile" run build
pnpm --filter "packages/${{ matrix.workspace }}" run build
- name: run test on workspace
run: |
pnpm --filter "packages/${{ matrix.workspace }}" run test
examples:
needs:
- build
runs-on: ubuntu-latest
strategy:
matrix:
wac:
- version: 0.6.0
node:
- version: 24.x
project:
- name: add
workspace: examples/components/add
- name: adder
workspace: examples/components/adder
- name: string-reverse
workspace: examples/components/string-reverse
- name: string-reverse-upper
workspace: examples/components/string-reverse-upper
is-composed: true
- name: webidl-book-library
workspace: examples/components/webidl-book-library
requires-crates:
- webidl2wit-cli
- name: node-fetch
workspace: examples/components/node-fetch
- name: http-hello-world
workspace: examples/components/http-hello-world
- name: http-server-fetch-handler
workspace: examples/components/http-server-fetch-handler
- name: http-server-hono
workspace: examples/components/http-server-hono
setup-transpile: true
setup-std: true
- name: host-logging
workspace: examples/components/host-logging
- name: ts-resource-import
workspace: examples/components/ts-resource-import
- name: ts-resource-export
workspace: examples/components/ts-resource-export
- name: typegen-async-export
workspace: examples/components/typegen-async-export
- name: node-compat
workspace: examples/components/node-compat
- name: fs-write-file
workspace: examples/components/fs-write-file
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ matrix.node.version }}
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
with:
version: 11
- name: Restore jco build output
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: build
path: packages/jco/obj
- name: Restore artifacts for JS tests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: js-generated-tests
path: packages/jco/test/output
- name: Restore jco-transpile vendor
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: jco-transpile-vendor
path: |
packages/jco-transpile/vendor
- name: Install Rust
if: ${{ toJSON(matrix.project.requires-crates) != '[]' }}
run: rustup update stable --no-self-update && rustup default stable
- name: Install required rust crates
if: ${{ toJSON(matrix.project.requires-crates) != '[]' }}
uses: taiki-e/install-action@e49978b799e49ff429d162b7a30601a569ab6538 # v2
with:
tool: ${{ join(matrix.project.requires-crates, ',') }}
- name: Install wac
if: ${{ matrix.project.is-composed }}
uses: jaxxstorm/action-install-gh-release@25e24d2d23ae098373794ef1d6faecb48ee52da8 # v3.0.0
with:
repo: bytecodealliance/wac
tag: v${{ matrix.wac.version }}
extension-matching: disable
rename-to: wac
chmod: 0755
- uses: bytecodealliance/actions/wasmtime/setup@9152e710e9f7182e4c29ad218e4f335a7b203613 # v1.1.3
- name: Cache node modules
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml') }}
path: |
node_modules
- run: pnpm install
- name: Build required deps
run: |
if [ "true" == "${{ matrix.setup-transpile }}" ]; then
pnpm run --filter '@bytecodealliance/jco-transpile' build
fi
if [ "true" == "${{ matrix.setup-std }}" ]; then
pnpm run --filter '@bytecodealliance/jco-std' build
fi
- name: Run all script for (${{ matrix.project.name }})
run: |
pnpm --filter '${{ matrix.project.workspace }}' run all
test-extended:
runs-on: ${{ matrix.os }}
needs:
- build
permissions:
contents: read
strategy:
matrix:
os:
- ubuntu-latest
node:
- latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ matrix.node }}
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
with:
version: 11
- uses: taiki-e/cache-cargo-install-action@417450f3c33ee20393705369577571770643d4c7 # v3.0.7
with:
tool: wasm-tools
- uses: taiki-e/cache-cargo-install-action@417450f3c33ee20393705369577571770643d4c7 # v3.0.7
with:
tool: wit-bindgen-cli
- uses: taiki-e/cache-cargo-install-action@417450f3c33ee20393705369577571770643d4c7 # v3.0.7
with:
tool: wac-cli
- uses: taiki-e/cache-cargo-install-action@417450f3c33ee20393705369577571770643d4c7 # v3.0.7
with:
tool: just
- uses: taiki-e/cache-cargo-install-action@417450f3c33ee20393705369577571770643d4c7 # v3.0.7
with:
tool: wkg
- uses: bytecodealliance/setup-wasi-sdk-action@b2de090b44eb70013ee96b393727d473b35e1728
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- run: pnpm install
- name: Restore jco build output
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: build
path: packages/jco/obj
- name: Build extended component tree
working-directory: test/components
run: just build
- name: Run extended component tests
run: |
pnpm --filter '@bytecodealliance/jco' run test:extended