Skip to content

Commit

Permalink
Add CI (wasmerio#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arshia001 authored Jun 19, 2024
1 parent a65dc45 commit 17ab559
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 114 deletions.
116 changes: 116 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Build

on:
workflow_call:
pull_request:
push:
branches:
- main

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
with:
submodules: "recursive"

- name: OS Setup (Ubuntu)
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
- 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/[email protected]

- name: Download wasix-libc
uses: dsaltares/[email protected]
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/[email protected]
with:
repo: wasix-org/rust
file: rust-toolchain-x86_64-unknown-linux-gnu.tar.gz
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/x86_64-unknown-linux-gnu/bin/*
chmod +x lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld/*
rustup toolchain link wasix .
- name: Build
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 output
uses: actions/upload-artifact@v3
with:
name: winterjs-wasm
path: target/wasm32-wasmer-wasi/release/winterjs.wasm
50 changes: 50 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release

on:
push:
tags:
- "v*"

jobs:
build-and-test:
uses: "./.github/workflows/build-and-test.yml"

release:
runs-on: ubuntu-latest
needs: build-and-test
steps:
- name: Setup Wasmer
uses: wasmerio/[email protected]

- name: Check out
uses: actions/checkout@v3
with:
submodules: "recursive"

- name: Download build artifacts
uses: actions/download-artifact@v3
with:
path: build-artifacts

- name: Publish
run: |
TAG_NAME=${{github.ref_name}}
VERSION_NUMBER=${TAG_NAME#v}
echo Publishing version $VERSION_NUMBER
if ! grep -q "version = ['\"]$VERSION_NUMBER['\"]" wasmer.toml; then
echo Tagged version must match version in wasmer.toml
exit -1
fi
if ! grep -q "version = ['\"]$VERSION_NUMBER['\"]" Cargo.toml; then
echo Tagged version must match version in Cargo.toml
exit -1
fi
mkdir -p target/wasm32-wasmer-wasi/release
mv build-artifacts/winterjs-wasm/winterjs.wasm target/wasm32-wasmer-wasi/release/winterjs.wasm
wasmer publish --registry="wasmer.io" --token=${{ secrets.WAPM_PROD_TOKEN }} --non-interactive
echo WinterJS version $VERSION_NUMBER was published successfully 🎉
106 changes: 0 additions & 106 deletions .github/workflows/rust.yml

This file was deleted.

12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "winterjs"
description = "The JavaScript runtime that brings JavaScript to Wasmer Edge."
version = "1.2.0"
version = "1.1.5"
repository = "https://github.com/wasmerio/winterjs/"
license = "MIT"
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion wasmer.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'wasmer/winterjs'
version = '1.2.0'
version = '1.1.5'
description = 'The JavaScript runtime that brings JavaScript to Wasmer Edge.'
license = 'MIT'
readme = 'README.md'
Expand Down

0 comments on commit 17ab559

Please sign in to comment.