Skip to content

Commit 53c5a61

Browse files
authored
fix: Cover local-only and wasm feature matrix in CI (MinishLab#38)
1 parent a33e77c commit 53c5a61

2 files changed

Lines changed: 29 additions & 17 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
backend: # Different backends for Tokenizers
16-
- default
17-
- fancy-regex
15+
include:
16+
- name: default
17+
build: cargo build --verbose
18+
test: cargo test --verbose
19+
- name: fancy-regex
20+
build: cargo build --no-default-features --features fancy-regex --verbose
21+
test: cargo test --no-default-features --features fancy-regex --verbose
22+
- name: local-only
23+
build: cargo build --no-default-features --features onig,local-only --verbose
24+
test: cargo test --no-default-features --features onig,local-only --verbose
1825

1926
steps:
2027
- name: Checkout
@@ -26,23 +33,28 @@ jobs:
2633
components: clippy, rustfmt
2734

2835
- name: Build
29-
run: |
30-
if [ "${{ matrix.backend }}" = "default" ]; then
31-
cargo build --verbose
32-
else
33-
cargo build --no-default-features --features fancy-regex --verbose
34-
fi
36+
run: ${{ matrix.build }}
3537

3638
- name: Test
37-
run: |
38-
if [ "${{ matrix.backend }}" = "default" ]; then
39-
cargo test --verbose
40-
else
41-
cargo test --no-default-features --features fancy-regex --verbose
42-
fi
39+
run: ${{ matrix.test }}
4340

4441
- name: Lint (clippy)
4542
run: cargo clippy --all-targets --all-features -- -D warnings
4643

4744
- name: Format check
4845
run: cargo fmt -- --check
46+
47+
wasm-check:
48+
runs-on: ubuntu-latest
49+
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
54+
- name: Set up Rust
55+
uses: dtolnay/rust-toolchain@stable
56+
with:
57+
target: wasm32-unknown-unknown
58+
59+
- name: Check wasm feature set
60+
run: RUSTFLAGS='--cfg getrandom_backend="wasm_js"' cargo check --no-default-features --features wasm --target wasm32-unknown-unknown

tests/test_model.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ fn test_from_bytes_matches_from_pretrained_for_local_model() {
123123
}
124124
}
125125

126-
#[cfg(not(feature = "hf-hub"))]
126+
#[cfg(all(not(feature = "hf-hub"), not(feature = "local-only")))]
127127
#[test]
128128
fn test_from_pretrained_remote_requires_hf_hub_feature() {
129129
let err = StaticModel::from_pretrained("minishlab/potion-base-2M", None, None, None).unwrap_err();
@@ -133,7 +133,7 @@ fn test_from_pretrained_remote_requires_hf_hub_feature() {
133133
);
134134
}
135135

136-
#[cfg(all(feature = "hf-hub", feature = "local-only"))]
136+
#[cfg(feature = "local-only")]
137137
#[test]
138138
fn test_from_pretrained_remote_disallowed_by_local_only_feature() {
139139
let err = StaticModel::from_pretrained("minishlab/potion-base-2M", None, None, None).unwrap_err();

0 commit comments

Comments
 (0)