fix: platform transition now correctly selects wasm32-wasip2 #39
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: CI | |
on: | |
push: | |
branches: [ main, develop ] | |
pull_request: | |
branches: [ main ] | |
env: | |
BAZEL_VERSION: 8.3.1 | |
jobs: | |
lint: | |
name: Lint and Format Check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Bazelisk | |
run: | | |
curl -LO https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 | |
chmod +x bazelisk-linux-amd64 | |
sudo mv bazelisk-linux-amd64 /usr/local/bin/bazel | |
- name: Check Buildifier Formatting | |
run: | | |
echo "Checking Bazel file formatting..." | |
# Check only formatting, not lint warnings | |
bazel run //:buildifier -- --lint=off --mode=check -r . | |
- name: Show Lint Warnings (Informational) | |
run: | | |
echo "Showing lint warnings (informational only - won't fail the build)..." | |
# Show warnings but don't fail the CI | |
bazel run //:buildifier -- --lint=warn --mode=check -r . || true | |
test: | |
name: Test on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
needs: lint # Run tests only after lint passes | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: false | |
- name: Cache Bazel | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/bazel | |
~/.cache/bazelisk | |
key: ${{ runner.os }}-bazel-${{ hashFiles('MODULE.bazel', 'WORKSPACE.bazel', '**/*.bzl') }} | |
restore-keys: | | |
${{ runner.os }}-bazel- | |
- name: Install Bazelisk | |
run: | | |
if [[ "$RUNNER_OS" == "Linux" ]]; then | |
curl -LO https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 | |
chmod +x bazelisk-linux-amd64 | |
sudo mv bazelisk-linux-amd64 /usr/local/bin/bazel | |
elif [[ "$RUNNER_OS" == "macOS" ]]; then | |
curl -LO https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-darwin-amd64 | |
chmod +x bazelisk-darwin-amd64 | |
sudo mv bazelisk-darwin-amd64 /usr/local/bin/bazel | |
fi | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: wasm32-wasip1,wasm32-wasip2,wasm32-unknown-unknown | |
components: clippy | |
- name: Install WASM tools | |
run: | | |
cargo install wasm-tools wac-cli wit-bindgen-cli | |
- name: Verify Bazel Installation | |
run: bazel version | |
- name: Build All Targets | |
run: bazel build //... | |
- name: Run Tests | |
run: bazel test //... --test_output=errors | |
- name: Run Clippy | |
run: bazel build --config=clippy //... | |
- name: Validate Toolchain Download Fix | |
run: bazel test //test/toolchain:validate_download_fix --test_output=errors | |
- name: Build Examples | |
run: | | |
bazel build //examples/basic:hello_component | |
bazel build //examples/multi_profile:camera_sensor | |
bazel build //examples/multi_profile:object_detection | |
- name: Validate Generated Files | |
run: | | |
# Check that WASM files are valid | |
bazel build //examples/basic:hello_component | |
wasm-tools validate bazel-bin/examples/basic/hello_component.wasm || true | |
integration: | |
name: Integration Tests | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: false | |
- name: Install Dependencies | |
run: | | |
curl -LO https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 | |
chmod +x bazelisk-linux-amd64 | |
sudo mv bazelisk-linux-amd64 /usr/local/bin/bazel | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
source ~/.cargo/env | |
rustup target add wasm32-wasip2 wasm32-wasip1 | |
cargo install wasm-tools wac-cli wit-bindgen-cli | |
- name: Test Multi-Profile Builds | |
run: | | |
bazel build //examples/multi_profile:camera_sensor | |
bazel build //examples/multi_profile:object_detection | |
# Get bazel-bin path and verify multiple profiles were created | |
BAZEL_BIN=$(bazel info bazel-bin) | |
ls -la "$BAZEL_BIN/examples/multi_profile/" | |
- name: Test Component Variants | |
run: | | |
bazel build //examples/multi_profile:camera_sensor_debug | |
bazel build //examples/multi_profile:camera_sensor_release | |
bazel build //examples/multi_profile:object_detection_debug | |
bazel build //examples/multi_profile:object_detection_release | |
# Get bazel-bin path | |
BAZEL_BIN=$(bazel info bazel-bin) | |
# Verify individual components are valid WASM | |
wasm-tools validate "$BAZEL_BIN/examples/multi_profile/camera_sensor_debug.component.wasm" | |
wasm-tools validate "$BAZEL_BIN/examples/multi_profile/camera_sensor_release.component.wasm" | |
wasm-tools validate "$BAZEL_BIN/examples/multi_profile/object_detection_debug.component.wasm" | |
wasm-tools validate "$BAZEL_BIN/examples/multi_profile/object_detection_release.component.wasm" | |
- name: Test Component Output Structure | |
run: | | |
# Get bazel-bin path | |
BAZEL_BIN=$(bazel info bazel-bin) | |
# Check that multiple profiles created separate outputs | |
echo "Camera sensor variants:" | |
ls -la "$BAZEL_BIN/examples/multi_profile/camera_sensor"*.wasm | |
echo "Object detection variants:" | |
ls -la "$BAZEL_BIN/examples/multi_profile/object_detection"*.wasm | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
needs: [test, integration] | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: false | |
- name: Install git-cliff | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: git-cliff | |
- name: Generate Release Notes | |
run: | | |
# Generate changelog for the latest changes | |
git-cliff --latest --strip header -o release_notes.md | |
echo "Generated release notes:" | |
cat release_notes.md | |
- name: Create Release Archive | |
run: | | |
# Create a clean directory for the release | |
mkdir -p release_tmp | |
# Copy files excluding Bazel and git directories | |
rsync -av \ | |
--exclude='.git*' \ | |
--exclude='bazel-*' \ | |
--exclude='*.tar.gz' \ | |
--exclude='.bazel*' \ | |
--exclude='release_tmp' \ | |
. release_tmp/ | |
# Create the archive from the clean directory | |
tar -czf rules_wasm_component.tar.gz -C release_tmp . | |
- name: Upload Release Asset | |
uses: actions/upload-artifact@v4 | |
with: | |
name: rules_wasm_component | |
path: rules_wasm_component.tar.gz |