From 5bbfcccfba2c4f38701ac428734afb37802d818e Mon Sep 17 00:00:00 2001 From: z9rtm Date: Thu, 22 May 2025 12:35:29 +0900 Subject: [PATCH] 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 --- .github/workflows/ci.yml | 58 ++++++++++++++++++++++++++++- examples/rig-integration/Cargo.toml | 1 + 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 38d69eb..f428a4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/examples/rig-integration/Cargo.toml b/examples/rig-integration/Cargo.toml index a8af25a..dc52da3 100644 --- a/examples/rig-integration/Cargo.toml +++ b/examples/rig-integration/Cargo.toml @@ -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", ] }