Skip to content

Commit 5bbfccc

Browse files
Z9RTMGCOV Github Badge
andauthored
ci: add example-test workflow for testing and building examples (#211)
This workflow sets up a new CI job to handle testing and building of example projects in the repository. It includes setting up Node.js, Rust, Python, and necessary caching to ensure proper environment preparation. Example directories are iterated to run tests and builds for each valid Cargo project. Co-authored-by: GCOV Github Badge <build@github.com>
1 parent c8ea0f6 commit 5bbfccc

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

.github/workflows/ci.yml

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,63 @@ jobs:
134134

135135
- name: Run tests with coverage
136136
run: cargo llvm-cov --all-features
137-
137+
138+
example-test:
139+
name: Example test
140+
runs-on: ubuntu-latest
141+
steps:
142+
- uses: actions/checkout@v4
143+
144+
# install nodejs
145+
- name: Setup Node.js
146+
uses: actions/setup-node@v4
147+
with:
148+
node-version: '20'
149+
150+
- name: Install uv
151+
uses: astral-sh/setup-uv@v6
152+
153+
- name: Install Rust
154+
uses: dtolnay/rust-toolchain@stable
155+
156+
- name: Set up Python
157+
run: uv python install
158+
159+
- name: Create venv for python
160+
run: uv venv
161+
162+
- uses: Swatinem/rust-cache@v2
163+
164+
- name: Add target WASI preview 2
165+
run: |
166+
rustup target add wasm32-wasip2
167+
168+
- name: Build examples
169+
run: |
170+
for dir in examples/*/ ; do
171+
if [ -f "$dir/Cargo.toml" ]; then
172+
echo "Building $dir"
173+
174+
if [[ "$dir" == *"wasi"* ]]; then
175+
cargo build --manifest-path "$dir/Cargo.toml" --target wasm32-wasip2
176+
else
177+
cargo build --manifest-path "$dir/Cargo.toml" --all-features --tests
178+
fi
179+
fi
180+
done
181+
182+
- name: Run tests in examples
183+
run: |
184+
# Tests are run for each subdirectory in the example directory.
185+
for dir in examples/*/ ; do
186+
if [ -f "$dir/Cargo.toml" ]; then
187+
if [[ "$dir" != *"wasi"* ]]; then
188+
echo "Testing $dir"
189+
cargo test --manifest-path "$dir/Cargo.toml" --all-features
190+
fi
191+
fi
192+
done
193+
138194
security_audit:
139195
name: Security Audit
140196
runs-on: ubuntu-latest

examples/rig-integration/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ rig-core = "0.10.0"
1616
tokio = { version = "1", features = ["full"] }
1717
rmcp = { path = "../../crates/rmcp", features = [
1818
"client",
19+
"reqwest",
1920
"transport-child-process",
2021
"transport-sse-client",
2122
] }

0 commit comments

Comments
 (0)