Skip to content

Optimize size tool

Optimize size tool #93

name: namui-linux-host-wasm32-wasi-web
on:
pull_request:
concurrency:
group: ${{ github.ref }}-namui-linux-host-wasm32-wasi-web
cancel-in-progress: true
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -D warnings
jobs:
list-projects:
runs-on: ubuntu-latest
outputs:
project-dirs: ${{ steps.project-dirs.outputs.dirs }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Output list of project directories
id: project-dirs
run: cargo run --manifest-path ./github-actions-tools/matrix-output/Cargo.toml wasm32-wasi-web $GITHUB_OUTPUT dirs
run-commands:
runs-on: ubuntu-latest
needs:
- list-projects
strategy:
matrix:
dir: ${{ fromJSON(needs.list-projects.outputs.project-dirs) }}
env:
CARGO_LOCK_PATH: ${{ matrix.dir }}/Cargo.lock
CARGO_VERSION: "" # Should be set in the job
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up cargo
run: |
rustup update
rustup target add wasm32-wasip1-threads
- run: CARGO_VERSION=$(cargo --version | cut -d ' ' -f 2) && echo "CARGO_VERSION=$CARGO_VERSION" >> $GITHUB_ENV
- uses: actions/cache@v3
with:
path: |
~/.cargo/
${{ matrix.dir }}/target/
key: ${{ runner.os }}-${{ env.CARGO_VERSION }}-linux-wasm32-wasi-web-${{ matrix.dir }}-${{ hashFiles(env.CARGO_LOCK_PATH) }}
restore-keys: |
${{ runner.os }}-${{ env.CARGO_VERSION }}-linux-wasm32-wasi-web-${{ matrix.dir }}-
${{ runner.os }}-${{ env.CARGO_VERSION }}-linux-wasm32-wasi-web-
- uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/namui/namui-cli/wasi-sdk/
${{ github.workspace }}/namui/namui-cli/emscripten/
${{ github.workspace }}/namui/namui-cli/target/
key: ${{ runner.os }}-${{ env.CARGO_VERSION }}-linux-wasm32-wasi-web-namui-cli-${{ hashFiles('namui/namui-cli/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.CARGO_VERSION }}-linux-wasm32-wasi-web-namui-cli-
- name: Install wasi-sdk
run: |
cd namui/namui-cli
cargo build
- name: Run commands
working-directory: ${{ matrix.dir }}
env:
CLANGCC: ${{ github.workspace }}/namui/namui-cli/wasi-sdk/bin/clang
CLANGCXX: ${{ github.workspace }}/namui/namui-cli/wasi-sdk/bin/clang++
CC: ${{ github.workspace }}/namui/namui-cli/wasi-sdk/bin/clang
CXX: ${{ github.workspace }}/namui/namui-cli/wasi-sdk/bin/clang++
WASI_SDK: ${{ github.workspace }}/namui/namui-cli/wasi-sdk
WASI_SYSROOT: ${{ github.workspace }}/namui/namui-cli/wasi-sdk/share/wasi-sysroot
EMSDK_SYSTEM_INCLUDE: ${{ github.workspace }}/namui/namui-cli/emscripten/system/include
CLANG_PATH: ${{ github.workspace }}/namui/namui-cli/wasi-sdk/bin/clang
CARGO_TARGET_WASM32_WASIP1_THREADS_LINKER: ${{ github.workspace }}/namui/namui-cli/wasi-sdk/bin/wasm-ld
CARGO_BUILD_TARGET: wasm32-wasip1-threads
run: |
echo "Running commands in ${{ matrix.dir }}"
# Print the environment variables to verify
echo "CLANGCC=$CLANGCC"
echo "CLANGCXX=$CLANGCXX"
echo "CC=$CC"
echo "CXX=$CXX"
echo "WASI_SDK=$WASI_SDK"
echo "WASI_SYSROOT=$WASI_SYSROOT"
echo "EMSDK_SYSTEM_INCLUDE=$EMSDK_SYSTEM_INCLUDE"
echo "CLANG_PATH=$CLANG_PATH"
echo "CARGO_TARGET_WASM32_WASIP1_THREADS_LINKER=$CARGO_TARGET_WASM32_WASIP1_THREADS_LINKER"
echo "cargo check --tests"
cargo check --tests
echo "cargo fmt"
cargo fmt
echo "cargo clippy --tests"
cargo clippy --tests
# Cannot run test on wasi yet.
# echo "cargo test"
# cargo test
post-namui-linux-host-wasm32-wasi-web:
if: always()
runs-on: ubuntu-latest
needs:
- run-commands
steps:
- run: |
echo ${{ join(needs.*.result, ',') }}
any_test_failed=${{ contains(join(needs.*.result, ','), 'failure') }}
echo $any_test_failed
if [[ $any_test_failed == "true" ]]; then
echo "::error::There are failed job"
exit 1
else
echo "Good. No test failed"
fi