test: make the TypeScript and Rust client-gen tests run on Windows #582
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Main | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| permissions: | |
| contents: read | |
| jobs: | |
| quality: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v6 | |
| - uses: actions/cache@v5 | |
| with: | |
| path: ~/.cache/pre-commit | |
| key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} | |
| - name: Set up the environment | |
| uses: ./.github/actions/setup-python-env | |
| - name: Run checks | |
| run: make check | |
| rust-core-unit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v6 | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Set up the Python environment | |
| uses: ./.github/actions/setup-python-env | |
| - name: Check public Rust SDK crate | |
| run: cargo check -p mcp-compressor | |
| - name: Check Rust core library | |
| run: cargo check -p mcp-compressor-core | |
| - name: Check Rust-backed Python extension crate | |
| run: cargo check -p mcp-compressor-python | |
| - name: Check Rust-backed Node extension crate | |
| run: cargo check -p mcp-compressor-node | |
| - name: Run public Rust SDK import smoke test | |
| env: | |
| PYTHON: ${{ github.workspace }}/.venv/bin/python | |
| run: | | |
| cargo test -p mcp-compressor --test public_api -- --nocapture | |
| cargo test -p mcp-compressor --test public_workflow -- --nocapture | |
| - name: Run Rust core library tests | |
| env: | |
| PYTHON: ${{ github.workspace }}/.venv/bin/python | |
| run: cargo test -p mcp-compressor-core --lib -- --nocapture | |
| rust-core-integration: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v6 | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Set up the Python environment | |
| uses: ./.github/actions/setup-python-env | |
| - name: Set up Bun for generated TypeScript client e2e | |
| uses: oven-sh/setup-bun@v2 | |
| - name: Run Rust core integration tests | |
| env: | |
| PYTHON: ${{ github.workspace }}/.venv/bin/python | |
| run: | | |
| timeout 180 cargo test -p mcp-compressor-core --test compressed_server_stdio -- --nocapture | |
| timeout 180 cargo test -p mcp-compressor-core --test compression_levels -- --nocapture | |
| timeout 180 cargo test -p mcp-compressor-core --test config_sources -- --nocapture | |
| timeout 180 cargo test -p mcp-compressor-core --test multi_server -- --nocapture | |
| timeout 180 cargo test -p mcp-compressor-core --test proxy_http -- --nocapture | |
| timeout 180 cargo test -p mcp-compressor-core --test generated_clients -- --nocapture | |
| timeout 180 cargo test -p mcp-compressor-core --test cli_binary -- --nocapture | |
| timeout 180 cargo test -p mcp-compressor-core --test transform_modes -- --nocapture | |
| rust-binary-e2e: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v6 | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Set up the Python environment | |
| uses: ./.github/actions/setup-python-env | |
| - name: Run Rust binary normal-mode FastMCP e2e | |
| env: | |
| PYTHON: ${{ github.workspace }}/.venv/bin/python | |
| run: | | |
| uv run pytest -q tests/test_rust_core_normal_mode.py | |
| uv run pytest -q tests/test_public_cli_workflows.py | |
| rust-contract-compile: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v6 | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Compile all Rust core integration targets | |
| run: cargo test -p mcp-compressor-core --tests --no-run | |
| python-rust-package: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v6 | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Set up root Python environment for fixture servers | |
| uses: ./.github/actions/setup-python-env | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v6 | |
| - name: Build native extension in editable mode | |
| working-directory: python/mcp-compressor | |
| run: | | |
| uv sync --frozen --group dev | |
| uv run maturin develop | |
| - name: Run rust-backed Python package tests | |
| working-directory: python/mcp-compressor | |
| env: | |
| PYTHON: ${{ github.workspace }}/.venv/bin/python | |
| run: uv run pytest -q tests | |
| - name: Run rust-backed Python package lint and type checks | |
| working-directory: python/mcp-compressor | |
| run: | | |
| uv run ruff check mcp_compressor tests | |
| uv run ty check --project . --python .venv mcp_compressor tests | |
| rust-binary-package: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v6 | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Set up Python environment for fixture server | |
| uses: ./.github/actions/setup-python-env | |
| - name: Build Rust CLI binary | |
| run: cargo build -p mcp-compressor-core --release | |
| - name: Smoke-test Rust CLI binary | |
| env: | |
| PYTHON: ${{ github.workspace }}/.venv/bin/python | |
| run: | | |
| BIN=target/release/mcp-compressor | |
| "$BIN" --help | |
| if "$BIN" --compression invalid -- "$PYTHON" crates/mcp-compressor-core/tests/fixtures/alpha_server.py; then | |
| echo "Expected invalid compression level to fail" >&2 | |
| exit 1 | |
| fi | |
| MCP_COMPRESSOR_EXIT_AFTER_READY=1 "$BIN" \ | |
| --cli-mode \ | |
| --server-name alpha \ | |
| --output-dir /tmp/mcp-compressor-bin-smoke \ | |
| -- "$PYTHON" crates/mcp-compressor-core/tests/fixtures/alpha_server.py | |
| test -x /tmp/mcp-compressor-bin-smoke/alpha | |
| - name: Upload Rust CLI binary artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: mcp-compressor-linux-x86_64 | |
| path: target/release/mcp-compressor | |
| python-rust-wheel: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v6 | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v6 | |
| - name: Build Rust-backed Python wheel | |
| working-directory: python/mcp-compressor | |
| run: uvx maturin build --release --out dist | |
| - name: Install wheel into clean venv and smoke test | |
| run: | | |
| python -m venv /tmp/mcp-compressor-wheel-test | |
| /tmp/mcp-compressor-wheel-test/bin/python -m pip install --upgrade pip | |
| /tmp/mcp-compressor-wheel-test/bin/python -m pip install "${{ github.workspace }}"/python/mcp-compressor/dist/*.whl | |
| cd /tmp | |
| /tmp/mcp-compressor-wheel-test/bin/python - <<'PY' | |
| from mcp_compressor import ToolSpec, compress_tool_listing | |
| listing = compress_tool_listing( | |
| "high", | |
| [ | |
| ToolSpec( | |
| name="echo", | |
| description="Echo a message.", | |
| input_schema={ | |
| "type": "object", | |
| "properties": {"message": {"type": "string"}}, | |
| "required": ["message"], | |
| }, | |
| ) | |
| ], | |
| ) | |
| assert "echo" in listing | |
| assert "message" in listing | |
| print("Rust-backed Python wheel import smoke test passed") | |
| PY | |
| - name: Upload wheel artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: mcp-compressor-python-wheel | |
| path: python/mcp-compressor/dist/*.whl | |
| typescript-native-package: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: typescript | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v6 | |
| - name: Set up Bun | |
| uses: oven-sh/setup-bun@v2 | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Build TypeScript package and native addon | |
| run: | | |
| bun run build | |
| bun run build:native | |
| - name: Pack and smoke-test package in clean project | |
| run: | | |
| PACKAGE_TGZ=$(bun pm pack --filename /tmp/mcp-compressor-ts-package.tgz) | |
| mkdir -p /tmp/mcp-compressor-ts-package-test | |
| cd /tmp/mcp-compressor-ts-package-test | |
| printf '{"type":"module"}\n' > package.json | |
| npm install --registry https://registry.npmjs.org /tmp/mcp-compressor-ts-package.tgz | |
| node --input-type=module -e 'import { CompressorClient, compressToolListing } from "@atlassian/mcp-compressor"; if (typeof CompressorClient !== "function") throw new Error("CompressorClient missing"); const listing = compressToolListing("high", [{ name: "echo", description: "Echo", inputSchema: { type: "object", properties: { message: { type: "string" } }, required: ["message"] } }]); if (!listing.includes("echo") || !listing.includes("message")) throw new Error(`bad listing: ${listing}`); console.log("Rust-backed TypeScript package smoke test passed");' | |
| - name: Upload npm package artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: mcp-compressor-typescript-package | |
| path: /tmp/mcp-compressor-ts-package.tgz | |
| check-docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v6 | |
| - name: Set up the environment | |
| uses: ./.github/actions/setup-python-env | |
| - name: Check if documentation can be built | |
| run: uv run mkdocs build -s | |
| typescript: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: typescript | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v6 | |
| - name: Set up Bun | |
| uses: oven-sh/setup-bun@v2 | |
| - name: Set up Python environment (needed for e2e tests that launch Python fixture servers) | |
| uses: ./.github/actions/setup-python-env | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Build Rust core binary | |
| run: bun run build:core | |
| - name: Build Rust native addon | |
| run: bun run build:native | |
| - name: Run TypeScript package checks | |
| env: | |
| PYTHON: ${{ github.workspace }}/.venv/bin/python | |
| run: bun run check |