From 8df8758570ae94d98866db4cebc2449ed0d7b64a Mon Sep 17 00:00:00 2001 From: white-axe Date: Fri, 13 Oct 2023 18:46:17 -0400 Subject: [PATCH] Add CI checks for web builds (#50) This adds a check for `wasm32-unknown-unknown` and a Trunk build to the checks workflow and to check.sh. The `-Z build-std=std,panic_abort` is required because the precompiled standard library for this target doesn't ship with multithreading support yet so we need to get Cargo to build it from source. We don't need to do this for Trunk because I set up Trunk hooks to edit .cargo/config.toml to enable these flags since Trunk doesn't support passing custom flags to Cargo. --- .github/workflows/checks.yml | 44 +++++++++++++++++++++++++++++++++++- check.sh | 4 ++-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 12a6c753..03593de7 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -21,6 +21,26 @@ jobs: uses: Swatinem/rust-cache@v2 - run: cargo check --all-features --jobs 1 + check-wasm32: + name: Check wasm32 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Install libraries + run: | + sudo apt update + sudo apt install libgtk-3-dev libatk1.0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev libasound2-dev clang mold -y + - uses: dtolnay/rust-toolchain@nightly + with: + toolchain: nightly-2023-09-12 + targets: wasm32-unknown-unknown + components: rust-src + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + - run: cargo check --jobs 1 --target wasm32-unknown-unknown -Z build-std=std,panic_abort + test: name: Test Suite runs-on: ubuntu-latest @@ -38,6 +58,28 @@ jobs: uses: Swatinem/rust-cache@v2 - run: cargo test --lib --jobs 1 + trunk: + name: Trunk + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Install libraries + run: | + sudo apt update + sudo apt install libgtk-3-dev libatk1.0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev libasound2-dev clang mold -y + - uses: dtolnay/rust-toolchain@nightly + with: + toolchain: nightly-2023-09-12 + targets: wasm32-unknown-unknown + components: rust-src + - name: Download and install Trunk binary + run: wget -qO- https://github.com/thedodd/trunk/releases/download/v0.17.5/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf- + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + - run: ./trunk build + fmt: name: Rustfmt runs-on: ubuntu-latest @@ -74,4 +116,4 @@ jobs: components: clippy - name: Rust Cache uses: Swatinem/rust-cache@v2 - - run: cargo clippy --jobs 1 -- # -D warnings \ No newline at end of file + - run: cargo clippy --jobs 1 -- # -D warnings diff --git a/check.sh b/check.sh index 5db076c4..06b5fb52 100755 --- a/check.sh +++ b/check.sh @@ -3,9 +3,9 @@ set -eux cargo check --workspace --all-targets -# cargo check --workspace --all-features --lib --target wasm32-unknown-unknown +cargo check --workspace --target wasm32-unknown-unknown -Z build-std=std,panic_abort cargo fmt --all -- --check cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::all cargo test --workspace --all-targets --all-features cargo test --workspace --doc -# trunk build +trunk build