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>
This commit is contained in:
z9rtm 2025-05-22 12:35:29 +09:00 committed by GitHub
parent c8ea0f6051
commit 5bbfcccfba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 58 additions and 1 deletions

View file

@ -134,7 +134,63 @@ jobs:
- name: Run tests with coverage
run: cargo llvm-cov --all-features
example-test:
name: Example test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# install nodejs
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Set up Python
run: uv python install
- name: Create venv for python
run: uv venv
- uses: Swatinem/rust-cache@v2
- name: Add target WASI preview 2
run: |
rustup target add wasm32-wasip2
- name: Build examples
run: |
for dir in examples/*/ ; do
if [ -f "$dir/Cargo.toml" ]; then
echo "Building $dir"
if [[ "$dir" == *"wasi"* ]]; then
cargo build --manifest-path "$dir/Cargo.toml" --target wasm32-wasip2
else
cargo build --manifest-path "$dir/Cargo.toml" --all-features --tests
fi
fi
done
- name: Run tests in examples
run: |
# Tests are run for each subdirectory in the example directory.
for dir in examples/*/ ; do
if [ -f "$dir/Cargo.toml" ]; then
if [[ "$dir" != *"wasi"* ]]; then
echo "Testing $dir"
cargo test --manifest-path "$dir/Cargo.toml" --all-features
fi
fi
done
security_audit:
name: Security Audit
runs-on: ubuntu-latest

View file

@ -16,6 +16,7 @@ rig-core = "0.10.0"
tokio = { version = "1", features = ["full"] }
rmcp = { path = "../../crates/rmcp", features = [
"client",
"reqwest",
"transport-child-process",
"transport-sse-client",
] }