Skip to content

Commit db01059

Browse files
committed
ci: test without protoc and ONNX support
1 parent d5e547b commit db01059

2 files changed

Lines changed: 33 additions & 24 deletions

File tree

.github/workflows/ci.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ env:
1212

1313
jobs:
1414
test:
15-
name: Test on ${{ matrix.os }}
15+
name: Test (${{ matrix.os }}, minimal=${{ matrix.minimal }})
1616
runs-on: ${{ matrix.os }}
1717
strategy:
1818
fail-fast: false
1919
matrix:
2020
os: [ubuntu-latest, windows-latest, macos-latest]
21+
minimal: [true, false]
22+
env:
23+
CARGO_FLAGS: ${{ matrix.minimal && '--no-default-features' || '' }}
2124

2225
steps:
2326
- name: Checkout code
@@ -29,42 +32,42 @@ jobs:
2932
components: rustfmt, clippy
3033

3134
- name: Install protoc (Linux)
32-
if: runner.os == 'Linux'
35+
if: ${{ runner.os == 'Linux' && !matrix.minimal }}
3336
run: |
3437
sudo apt-get update
3538
sudo apt-get install -y protobuf-compiler
3639
3740
- name: Install protoc (macOS)
38-
if: runner.os == 'macOS'
41+
if: ${{ runner.os == 'macOS' && !matrix.minimal }}
3942
run: brew install protobuf
4043

4144
- name: Install protoc (Windows)
42-
if: runner.os == 'Windows'
45+
if: ${{ runner.os == 'Windows' && !matrix.minimal }}
4346
run: choco install protoc
4447

4548
- name: Cache cargo registry
4649
uses: actions/cache@v4
4750
with:
4851
path: ~/.cargo/registry
49-
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
52+
key: ${{ runner.os }}-${{ matrix.minimal }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
5053
restore-keys: |
51-
${{ runner.os }}-cargo-registry-
54+
${{ runner.os }}-${{ matrix.minimal }}-cargo-registry-
5255
5356
- name: Cache cargo index
5457
uses: actions/cache@v4
5558
with:
5659
path: ~/.cargo/git
57-
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
60+
key: ${{ runner.os }}-${{ matrix.minimal }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
5861
restore-keys: |
59-
${{ runner.os }}-cargo-git-
62+
${{ runner.os }}-${{ matrix.minimal }}-cargo-git-
6063
6164
- name: Cache target directory
6265
uses: actions/cache@v4
6366
with:
6467
path: target
65-
key: ${{ runner.os }}-target-${{ hashFiles('**/Cargo.lock') }}
68+
key: ${{ runner.os }}-${{ matrix.minimal }}-target-${{ hashFiles('**/Cargo.lock') }}
6669
restore-keys: |
67-
${{ runner.os }}-target-
70+
${{ runner.os }}-${{ matrix.minimal }}-target-
6871
6972
- name: Check formatting
7073
run: make fmt-check

Makefile

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
1-
.PHONY: all build test fmt clean run check lint help parse validate emit-js emit-html coverage
1+
.PHONY: all build test fmt clean run check lint help parse validate emit-js emit-html coverage minimal
2+
3+
CARGO_FLAGS ?=
24

35
# Default target
46
all: build
57

68
# Build the project
79
build:
8-
cargo build
10+
cargo build $(CARGO_FLAGS)
11+
12+
# Build the project
13+
minimal:
14+
cargo build --no-default-features
915

1016
# Build with release optimizations
1117
release:
12-
cargo build --release
18+
cargo build --release $(CARGO_FLAGS)
1319

1420
# Run all tests
1521
test:
16-
cargo test
22+
cargo test $(CARGO_FLAGS)
1723

1824
# Run tests with output
1925
test-verbose:
20-
cargo test -- --nocapture
26+
cargo test $(CARGO_FLAGS) -- --nocapture
2127

2228
# Format code
2329
fmt:
@@ -29,37 +35,37 @@ fmt-check:
2935

3036
# Run clippy linter
3137
lint:
32-
cargo clippy -- -D warnings
38+
cargo clippy $(CARGO_FLAGS) -- -D warnings
3339

3440
# Quick compile check without building
3541
check:
36-
cargo check
42+
cargo check $(CARGO_FLAGS)
3743

3844
# Clean build artifacts
3945
clean:
4046
cargo clean
4147

4248
# Run the CLI tool (parse example)
4349
run:
44-
cargo run --bin webnn-graph -- parse examples/resnet_head.webnn
50+
cargo run $(CARGO_FLAGS) --bin webnn-graph -- parse examples/resnet_head.webnn
4551

4652
# Parse example graph
4753
parse:
48-
cargo run --bin webnn-graph -- parse examples/resnet_head.webnn
54+
cargo run $(CARGO_FLAGS) --bin webnn-graph -- parse examples/resnet_head.webnn
4955

5056
# Validate example graph
5157
validate:
52-
cargo run --bin webnn-graph -- parse examples/resnet_head.webnn > /tmp/graph.json && \
53-
cargo run --bin webnn-graph -- validate /tmp/graph.json --weights-manifest examples/weights.manifest.json
58+
cargo run $(CARGO_FLAGS) --bin webnn-graph -- parse examples/resnet_head.webnn > /tmp/graph.json && \
59+
cargo run $(CARGO_FLAGS) --bin webnn-graph -- validate /tmp/graph.json --weights-manifest examples/weights.manifest.json
5460

5561
# Emit JavaScript for example graph
5662
emit-js:
57-
cargo run --bin webnn-graph -- parse examples/resnet_head.webnn > /tmp/graph.json && \
58-
cargo run --bin webnn-graph -- emit-js /tmp/graph.json
63+
cargo run $(CARGO_FLAGS) --bin webnn-graph -- parse examples/resnet_head.webnn > /tmp/graph.json && \
64+
cargo run $(CARGO_FLAGS) --bin webnn-graph -- emit-js /tmp/graph.json
5965

6066
# Generate HTML visualizer for example graph
6167
emit-html:
62-
cargo run --bin webnn-graph -- emit-html examples/resnet_head.webnn > /tmp/webnn_viz.html
68+
cargo run $(CARGO_FLAGS) --bin webnn-graph -- emit-html examples/resnet_head.webnn > /tmp/webnn_viz.html
6369
@echo "Visualizer generated: /tmp/webnn_viz.html"
6470
@echo "Open it with: open /tmp/webnn_viz.html"
6571

0 commit comments

Comments
 (0)