Skip to content

Commit

Permalink
add wasm ci
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed Nov 5, 2023
1 parent b0d4625 commit 26ce845
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,31 @@ permissions:
contents: read

jobs:
test-wasm:
name: Test WASM
runs-on: ubuntu-20.04

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
targets: wasm32-unknown-unknown

- name: Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "rust-stable-test"

- name: Build xtask
run: cargo build --manifest-path ./xtask/Cargo.toml

- name: Run tests
run: cargo x test --wasm

test:
name: Test
runs-on: ${{ matrix.os }}
Expand Down
15 changes: 14 additions & 1 deletion xtask/src/task/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ pub struct Test {
targets: Vec<Target>,
#[argp(switch, description = "Run insta with --review")]
review: bool,
#[argp(
switch,
description = "Run the tests for the `wasm32-unknown-unknown` platform"
)]
wasm: bool,
}

#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
Expand Down Expand Up @@ -57,7 +62,9 @@ impl argp::FromArgValue for Target {
impl Test {
pub fn run(mut self) -> Result {
let review = self.review;
let commands = if self.targets.is_empty() {
let mut commands = if self.targets.is_empty() && self.wasm {
vec![unit(), ui(review), rules(review)]
} else if self.targets.is_empty() {
vec![unit(), ui(review), rules(review), axum()]
} else {
self.targets.sort();
Expand All @@ -73,6 +80,12 @@ impl Test {
.collect()
};

if self.wasm {
commands.iter_mut().for_each(|cmd| {
cmd.args(["--target", "wasm32-unknown-unknown"]);
});
}

for command in commands {
command.run()?;
}
Expand Down

0 comments on commit 26ce845

Please sign in to comment.