Skip to content

Commit edc482e

Browse files
committed
refactor: add scaffholding for mcpgatway_rust initial components
Signed-off-by: lucarlig <luca.carlig@ibm.com> Signed-off-by: Luca <lucarlig@protonmail.com>
1 parent 897ccaa commit edc482e

File tree

15 files changed

+3079
-5
lines changed

15 files changed

+3079
-5
lines changed
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
name: MCP Gateway Rust CI/CD
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
paths:
7+
- "mcpgateway_rust/**"
8+
- ".github/workflows/mcpgateway-rust.yml"
9+
pull_request:
10+
branches: [main, develop]
11+
paths:
12+
- "mcpgateway_rust/**"
13+
workflow_dispatch:
14+
15+
env:
16+
CARGO_TERM_COLOR: always
17+
RUST_BACKTRACE: 1
18+
19+
jobs:
20+
# Rust unit tests and linting
21+
rust-tests:
22+
name: Rust Tests (${{ matrix.os }})
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
os: [ubuntu-latest, macos-latest, windows-latest]
28+
rust: [stable]
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Install Rust components
34+
run: |
35+
rustup toolchain install stable
36+
rustup component add rustfmt clippy
37+
rustup default stable
38+
39+
- name: Cache Cargo registry
40+
uses: actions/cache@v4
41+
with:
42+
path: ~/.cargo/registry
43+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
44+
45+
- name: Cache Cargo index
46+
uses: actions/cache@v4
47+
with:
48+
path: ~/.cargo/git
49+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
50+
51+
- name: Cache Cargo build
52+
uses: actions/cache@v4
53+
with:
54+
path: mcpgateway_rust/target
55+
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
56+
57+
- name: Check formatting
58+
run: make rust-gateway-fmt-check
59+
60+
- name: Run Clippy
61+
run: make rust-gateway-clippy
62+
63+
- name: Run Rust tests
64+
run: make rust-gateway-test-verbose
65+
66+
67+
# Build wheels for multiple platforms (native builds)
68+
build-wheels:
69+
name: Build wheels on ${{ matrix.os }}
70+
runs-on: ${{ matrix.os }}
71+
strategy:
72+
fail-fast: false
73+
matrix:
74+
os: [ubuntu-latest, macos-latest, windows-latest]
75+
76+
steps:
77+
- uses: actions/checkout@v4
78+
79+
- name: Set up Python
80+
uses: actions/setup-python@v5
81+
with:
82+
python-version: "3.11"
83+
84+
- name: Install Rust stable
85+
run: rustup default stable
86+
87+
- name: Install maturin
88+
run: pip install maturin
89+
90+
- name: Build wheels
91+
working-directory: mcpgateway_rust
92+
run: maturin build --release --out dist
93+
94+
- name: Upload wheels as artifacts
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: wheels-${{ matrix.os }}
98+
path: mcpgateway_rust/dist/*.whl
99+
100+
# Security audit
101+
security-audit:
102+
name: Security Audit
103+
runs-on: ubuntu-latest
104+
105+
steps:
106+
- uses: actions/checkout@v4
107+
108+
- name: Install Rust stable
109+
run: rustup default stable
110+
111+
- name: Install cargo-audit
112+
run: cargo install cargo-audit
113+
114+
- name: Run security audit
115+
run: make rust-gateway-audit
116+
117+
# Coverage report
118+
coverage:
119+
name: Code Coverage
120+
runs-on: ubuntu-latest
121+
122+
steps:
123+
- uses: actions/checkout@v4
124+
125+
- name: Set up Python
126+
uses: actions/setup-python@v5
127+
with:
128+
python-version: "3.11"
129+
130+
- name: Install Rust stable and components
131+
run: |
132+
rustup default stable
133+
rustup component add llvm-tools-preview
134+
135+
- name: Install uv
136+
uses: astral-sh/setup-uv@v5
137+
with:
138+
version: "0.9.2"
139+
140+
- name: Install maturin as CLI tool
141+
run: uv tool install maturin
142+
143+
- name: Create virtual environment
144+
run: uv venv
145+
146+
- name: Install coverage tools
147+
run: |
148+
uv pip install -e ".[dev]"
149+
cargo install cargo-tarpaulin
150+
151+
- name: Build Rust extension
152+
run: make rust-gateway-install-debug
153+
154+
- name: Run Rust tests with coverage
155+
working-directory: mcpgateway_rust
156+
run: cargo tarpaulin --workspace --out Xml --output-dir coverage
157+
158+
- name: Upload coverage to Codecov
159+
uses: codecov/codecov-action@v4
160+
with:
161+
files: ./mcpgateway_rust/coverage/cobertura.xml
162+
flags: mcpgateway-rust
163+
name: mcpgateway-rust-coverage
164+
165+
# Build documentation
166+
documentation:
167+
name: Build Documentation
168+
runs-on: ubuntu-latest
169+
170+
steps:
171+
- uses: actions/checkout@v4
172+
173+
- name: Install Rust stable
174+
run: rustup default stable
175+
176+
- name: Build Rust docs
177+
run: make rust-gateway-doc
178+
179+
- name: Upload documentation
180+
uses: actions/upload-artifact@v4
181+
with:
182+
name: mcpgateway-rust-docs
183+
path: mcpgateway_rust/target/doc
184+
185+
# Release build (only on tags)
186+
release:
187+
name: Release Build
188+
runs-on: ${{ matrix.os }}
189+
if: startsWith(github.ref, 'refs/tags/')
190+
needs: [rust-tests, python-integration]
191+
strategy:
192+
matrix:
193+
os: [ubuntu-latest, macos-latest, windows-latest]
194+
195+
steps:
196+
- uses: actions/checkout@v4
197+
198+
- name: Set up Python
199+
uses: actions/setup-python@v5
200+
with:
201+
python-version: "3.11"
202+
203+
- name: Install Rust stable
204+
run: rustup default stable
205+
206+
- name: Install maturin
207+
run: pip install maturin
208+
209+
- name: Build release wheels
210+
working-directory: mcpgateway_rust
211+
run: maturin build --release --out dist
212+
213+
- name: Upload release artifacts
214+
uses: actions/upload-artifact@v4
215+
with:
216+
name: release-wheels-${{ matrix.os }}
217+
path: mcpgateway_rust/dist/*.whl
218+
219+
- name: Publish to PyPI (if tag)
220+
if: startsWith(github.ref, 'refs/tags/')
221+
env:
222+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
223+
working-directory: mcpgateway_rust
224+
run: maturin publish --username __token__ --password $MATURIN_PYPI_TOKEN

.pre-commit-config.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,6 @@ repos:
304304
description: Checks XML files for parseable syntax.
305305
types: [xml]
306306

307-
- id: fix-byte-order-marker
308-
name: ✅ Fix Byte Order Marker
309-
description: Removes UTF-8 byte-order marker.
310-
types: [text]
311-
312307
- repo: https://github.com/adrienverge/yamllint
313308
rev: v1.38.0
314309
hooks:

MANIFEST.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ recursive-include plugins_rust *.py
103103
include plugins_rust/Makefile
104104
prune plugins_rust/target
105105

106+
# Rust service components (mcpgateway_rust)
107+
recursive-include mcpgateway_rust *.rs
108+
recursive-include mcpgateway_rust *.toml
109+
recursive-include mcpgateway_rust *.lock
110+
recursive-include mcpgateway_rust *.md
111+
recursive-include mcpgateway_rust *.py
112+
include mcpgateway_rust/Makefile
113+
prune mcpgateway_rust/target
114+
106115
# 5️⃣ (Optional) include MKDocs-based docs in the sdist
107116
# graft docs
108117

Makefile

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7505,6 +7505,8 @@ upgrade-validate: ## Validate fresh + upgrade DB startup
75057505
.PHONY: rust-check-maturin rust-install-deps rust-install-targets
75067506
.PHONY: rust-build-x86_64 rust-build-aarch64 rust-build-armv7 rust-build-s390x rust-build-ppc64le
75077507
.PHONY: rust-build-all-linux rust-build-all-platforms rust-cross rust-cross-install-build
7508+
.PHONY: rust-gateway-build rust-gateway-install rust-gateway-test rust-gateway-check rust-gateway-fmt rust-gateway-clippy rust-gateway-clean rust-gateway-verify rust-gateway-info
7509+
.PHONY: rust-ensure-deps
75087510

75097511
rust-build: rust-check-maturin ## Build Rust plugins (release)
75107512
@echo "🦀 Building Rust plugins (release mode)..."
@@ -7614,6 +7616,62 @@ rust-cross: rust-install-targets rust-build-all-linux ## Install targets + buil
76147616
rust-cross-install-build: rust-install-deps rust-install-targets rust-build-all-platforms ## Install targets + build all platforms (one command)
76157617
@echo "✅ Full cross-compilation setup and build complete"
76167618

7619+
# -----------------------------------------------------------------------------
7620+
# 🦀 Rust Gateway Workspace (mcpgateway_rust)
7621+
# -----------------------------------------------------------------------------
7622+
7623+
rust-ensure-deps: ## Ensure Rust toolchain and maturin are installed
7624+
@if ! command -v rustup > /dev/null 2>&1; then \
7625+
echo "🦀 Rust not found. Installing Rust toolchain..."; \
7626+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --component rustfmt clippy; \
7627+
echo "🦀 Rust installed. Sourcing environment..."; \
7628+
. "$$HOME/.cargo/env"; \
7629+
fi
7630+
@if ! command -v cargo > /dev/null 2>&1; then \
7631+
echo "⚠️ cargo not in PATH. Sourcing $$HOME/.cargo/env..."; \
7632+
. "$$HOME/.cargo/env"; \
7633+
fi
7634+
@rustup component add rustfmt clippy 2>/dev/null || true
7635+
@if ! command -v maturin > /dev/null 2>&1; then \
7636+
if [ -f "$(VENV_DIR)/bin/activate" ]; then \
7637+
echo "📦 Installing maturin into venv..."; \
7638+
/bin/bash -c "source $(VENV_DIR)/bin/activate && uv pip install maturin"; \
7639+
elif command -v pip > /dev/null 2>&1; then \
7640+
echo "📦 Installing maturin globally (venv not found)..."; \
7641+
pip install maturin; \
7642+
else \
7643+
echo "⚠️ maturin not found and cannot be installed (no venv or pip available)"; \
7644+
echo " For building wheels, install maturin: pip install maturin"; \
7645+
fi; \
7646+
fi
7647+
7648+
rust-gateway-build: rust-ensure-deps ## Build Rust gateway workspace (release)
7649+
@$(MAKE) -C mcpgateway_rust build
7650+
7651+
rust-gateway-install: rust-ensure-deps ## Build and install all PyO3 gateway modules
7652+
@$(MAKE) -C mcpgateway_rust install
7653+
7654+
rust-gateway-test: rust-ensure-deps ## Run all Rust gateway tests
7655+
@$(MAKE) -C mcpgateway_rust test
7656+
7657+
rust-gateway-check: rust-ensure-deps ## Run cargo check on gateway workspace
7658+
@$(MAKE) -C mcpgateway_rust check
7659+
7660+
rust-gateway-fmt: rust-ensure-deps ## Format Rust gateway code
7661+
@$(MAKE) -C mcpgateway_rust fmt
7662+
7663+
rust-gateway-clippy: rust-ensure-deps ## Run clippy on gateway workspace
7664+
@$(MAKE) -C mcpgateway_rust clippy
7665+
7666+
rust-gateway-clean: rust-ensure-deps ## Clean Rust gateway build artifacts
7667+
@$(MAKE) -C mcpgateway_rust clean
7668+
7669+
rust-gateway-verify: rust-ensure-deps ## Run all gateway verification checks
7670+
@$(MAKE) -C mcpgateway_rust verify
7671+
7672+
rust-gateway-info: rust-ensure-deps ## Show Rust gateway workspace information
7673+
@$(MAKE) -C mcpgateway_rust info
7674+
76177675
# -----------------------------------------------------------------------------
76187676
# Temporary CI toggle for Conventional Commit message linting
76197677
# -----------------------------------------------------------------------------

docs/docs/architecture/adr/.pages

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ nav:
4343
- 38b Multi-Worker Session Affinity: 038-multi-worker-session-affinity.md
4444
- 39 Adopt Fully Independent Plugin Crates Architecture: 039-adopt-fully-independent-plugin-crates-architecture.md
4545
- 40 Flexible Admin UI Section Visibility: 040-flexible-admin-ui-sections.md
46+
- 41 Rust Service Components & PyO3 Data Types: 041-rust-service-components-pyo3-data-types.md

0 commit comments

Comments
 (0)