Add macOS into the CI build #19
This file contains 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: Build | |
on: | |
workflow_call: | |
pull_request: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-test: | |
strategy: | |
fail-fast: false | |
matrix: | |
metadata: [ | |
{ | |
os: ubuntu-latest, | |
wasix-toolchain-release-asset: rust-toolchain-x86_64-unknown-linux-gnu.tar.gz | |
} | |
] | |
runs-on: ${{ matrix.metadata.os }} | |
steps: | |
- name: Check out | |
uses: actions/checkout@v3 | |
with: | |
submodules: "recursive" | |
- name: OS Setup (Ubuntu) | |
if: ${{ matrix.metadata.os == 'ubuntu-latest' }} | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y build-essential python3.11 python3-distutils llvm-15 libclang-dev clang-15 wabt | |
npm i -g wasm-opt pnpm concurrently | |
sudo rm /usr/bin/clang | |
sudo rm /usr/bin/clang++ | |
sudo ln -s /usr/bin/clang-15 /usr/bin/clang | |
sudo ln -s /usr/bin/clang++-15 /usr/bin/clang++ | |
sudo ln -s /usr/bin/llvm-ar-15 /usr/bin/llvm-ar | |
sudo ln -s /usr/bin/llvm-nm-15 /usr/bin/llvm-nm | |
sudo ln -s /usr/bin/llvm-ranlib-15 /usr/bin/llvm-ranlib | |
sudo ln -s /usr/bin/llvm-objdump-15 /usr/bin/llvm-objdump | |
- name: Tool Versions | |
run: | | |
echo clang | |
clang -v | |
echo '####################' | |
echo llvm-ar | |
llvm-ar -V | |
echo '####################' | |
echo llvm-nm | |
llvm-nm -V | |
echo '####################' | |
echo llvm-ranlib | |
llvm-ranlib -v | |
echo '####################' | |
echo wasm-opt | |
wasm-opt --version | |
echo '####################' | |
echo wasm-strip | |
wasm-strip --version | |
echo '####################' | |
echo python | |
python3.11 -V | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: "1.76" | |
components: "clippy,rustfmt" | |
- name: Setup Wasmer | |
uses: wasmerio/setup-wasmer@v3.1 | |
- name: Download wasix-libc | |
uses: dsaltares/fetch-gh-release-asset@1.1.2 | |
with: | |
repo: wasix-org/rust | |
file: wasix-libc.tar.gz | |
target: sysroot/wasix-libc.tar.gz | |
- name: Unpack wasix-libc | |
run: | | |
cd sysroot | |
tar xzf wasix-libc.tar.gz | |
- name: Download wasix toolchain | |
uses: dsaltares/fetch-gh-release-asset@1.1.2 | |
with: | |
repo: wasix-org/rust | |
file: ${{ matrix.metadata.wasix-toolchain-release-asset }} | |
target: wasix-rust-toolchain/toolchain.tar.gz | |
- name: Install wasix toolchain | |
run: | | |
cd wasix-rust-toolchain | |
tar xzf toolchain.tar.gz | |
chmod +x bin/* | |
chmod +x lib/rustlib/*/bin/* | |
chmod +x lib/rustlib/*/bin/gcc-ld/* | |
rustup toolchain link wasix . | |
- name: Build native | |
run: cargo build --profile release-compact | |
- name: Archive build native output | |
uses: actions/upload-artifact@v3 | |
with: | |
name: winterjs-linux | |
path: target/release-compact/winterjs | |
- name: Build wasm | |
run: | | |
export WASI_SYSROOT=$(pwd)/sysroot/wasix-libc/sysroot32 | |
bash build.sh | |
- name: build test suite JS app | |
run: | | |
cd test-suite/js-test-app | |
pnpm i | |
pnpm run build | |
- name: Run API test suite | |
# note: we're counting on wasmer compiling and running WinterJS faster | |
# that cargo builds the test-suite app. This may not be the case forever. | |
run: | | |
conc --kill-others --success "command-1" \ | |
"wasmer run target/wasm32-wasmer-wasi/release/winterjs.wasm --net --mapdir /app:./test-suite/js-test-app/dist -- serve /app/bundle.js" \ | |
"sleep 10 && cd test-suite && cargo run" | |
echo All tests are passing! 🎉 | |
- name: Archive build wasm output | |
uses: actions/upload-artifact@v3 | |
with: | |
name: winterjs-wasm | |
path: target/wasm32-wasmer-wasi/release/winterjs.wasm |