Skip to content

Commit f4fa064

Browse files
committed
Initial commit: Complete MCP Development with Rust Tutorial - Technical reference and international teaching guides with 20+ examples
0 parents  commit f4fa064

38 files changed

+18819
-0
lines changed

.github/dependabot.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Configuration file for Dependabot
2+
#
3+
# This file configures Dependabot to automatically check for and update
4+
# dependencies in the project. It helps keep the project secure by
5+
# updating to newer versions of dependencies that fix security vulnerabilities.
6+
7+
version: 2
8+
9+
updates:
10+
# Configuration for Rust/Cargo dependencies
11+
- package-ecosystem: "cargo"
12+
directory: "/"
13+
schedule:
14+
interval: "weekly"
15+
day: "monday"
16+
time: "09:00"
17+
timezone: "Etc/UTC"
18+
19+
versioning-strategy: "auto"
20+
open-pull-requests-limit: 10
21+
22+
commit-message:
23+
prefix: "cargo"
24+
prefix-development: "cargo-dev"
25+
include: "scope"
26+
27+
groups:
28+
async-runtime:
29+
patterns:
30+
- "tokio*"
31+
- "futures*"
32+
- "async-*"
33+
34+
serialization:
35+
patterns:
36+
- "serde*"
37+
- "serde_json"
38+
39+
http-web:
40+
patterns:
41+
- "reqwest"
42+
- "hyper*"
43+
- "http*"
44+
45+
database:
46+
patterns:
47+
- "sqlx*"
48+
49+
logging:
50+
patterns:
51+
- "tracing*"
52+
- "log"
53+
54+
allow:
55+
- dependency-type: "all"
56+
57+
target-branch: "main"
58+
59+
# Configuration for GitHub Actions dependencies
60+
- package-ecosystem: "github-actions"
61+
directory: "/"
62+
schedule:
63+
interval: "weekly"
64+
day: "sunday"
65+
time: "09:00"
66+
timezone: "Etc/UTC"
67+
68+
open-pull-requests-limit: 5
69+
70+
commit-message:
71+
prefix: "github-actions"
72+
include: "scope"
73+
74+
allow:
75+
- dependency-type: "all"
76+
77+
target-branch: "main"

.github/workflows/ci.yml

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
# Workflow: Continuous Integration (CI)
2+
#
3+
# This workflow runs on every push and pull request to ensure code quality
4+
# and compatibility across different platforms and Rust versions.
5+
# It performs comprehensive testing, linting, formatting checks, and builds.
6+
7+
name: CI
8+
9+
# Trigger conditions: run on pushes to main branch and all pull requests
10+
on:
11+
push:
12+
branches: [ "main", "master" ]
13+
pull_request:
14+
branches: [ "main", "master" ]
15+
16+
# Define environment variables used across all jobs
17+
env:
18+
CARGO_TERM_COLOR: always
19+
RUST_BACKTRACE: 1
20+
21+
# Define the jobs that make up the CI pipeline
22+
jobs:
23+
# Job 1: Run comprehensive tests across multiple platforms and Rust versions
24+
test:
25+
name: Test Suite
26+
runs-on: ${{ matrix.os }}
27+
28+
# Strategy matrix: test on multiple operating systems and Rust versions
29+
# This ensures our code works across different environments
30+
strategy:
31+
matrix:
32+
os: [ubuntu-latest, windows-latest, macos-latest]
33+
rust: [stable, beta]
34+
include:
35+
# Add MSRV (Minimum Supported Rust Version) check on Ubuntu
36+
- os: ubuntu-latest
37+
rust: 1.70.0 # Adjust based on your actual MSRV
38+
39+
steps:
40+
# Step 1: Check out the source code from the repository
41+
- name: Checkout source code
42+
uses: actions/checkout@v4
43+
44+
# Step 2: Install the specified Rust toolchain
45+
# This ensures we're testing with the exact Rust version from our matrix
46+
- name: Install Rust toolchain
47+
uses: dtolnay/rust-toolchain@master
48+
with:
49+
toolchain: ${{ matrix.rust }}
50+
components: rustfmt, clippy
51+
52+
# Step 3: Configure Rust cargo caching to speed up builds
53+
# This caches dependencies and build artifacts between runs
54+
- name: Setup Rust cache
55+
uses: Swatinem/rust-cache@v2
56+
with:
57+
# Cache key includes OS and Rust version for proper isolation
58+
key: ${{ matrix.os }}-${{ matrix.rust }}
59+
60+
# Step 4: Build all targets to ensure compilation succeeds
61+
# We build all binary examples defined in Cargo.toml
62+
- name: Build all examples
63+
run: cargo build --all-targets --verbose
64+
65+
# Step 5: Run all unit and integration tests
66+
# The --all-targets flag ensures we test all our binary examples
67+
- name: Run tests
68+
run: cargo test --all-targets --verbose
69+
70+
# Step 6: Build and run each example individually to verify they work
71+
# This is important since we have multiple binary targets
72+
- name: Test individual examples
73+
run: |
74+
# Get list of all binary examples from Cargo.toml
75+
for example in $(cargo read-manifest | jq -r '.targets[] | select(.kind[] == "bin") | .name'); do
76+
echo "Testing example: $example"
77+
cargo run --bin "$example" --help || true # Run with --help to test basic functionality
78+
done
79+
shell: bash
80+
81+
# Step 7: Run tests with all features enabled (if any)
82+
- name: Run tests with all features
83+
run: cargo test --all-features --verbose
84+
85+
# Job 2: Code quality checks (formatting and linting)
86+
quality:
87+
name: Code Quality
88+
runs-on: ubuntu-latest
89+
90+
steps:
91+
# Step 1: Check out the source code
92+
- name: Checkout source code
93+
uses: actions/checkout@v4
94+
95+
# Step 2: Install stable Rust with required components
96+
- name: Install Rust toolchain
97+
uses: dtolnay/rust-toolchain@stable
98+
with:
99+
components: rustfmt, clippy
100+
101+
# Step 3: Setup caching for faster subsequent runs
102+
- name: Setup Rust cache
103+
uses: Swatinem/rust-cache@v2
104+
105+
# Step 4: Check code formatting with rustfmt
106+
# This ensures all code follows consistent formatting standards
107+
- name: Check formatting
108+
run: cargo fmt --all -- --check
109+
110+
# Step 5: Run Clippy linter for code quality and style issues
111+
# Clippy catches common mistakes and suggests improvements
112+
- name: Run Clippy linting
113+
run: cargo clippy --all-targets --all-features -- -D warnings
114+
115+
# Step 6: Check for unused dependencies
116+
# This helps keep our dependency tree clean and reduces build times
117+
- name: Install cargo-udeps
118+
run: cargo install cargo-udeps --locked
119+
120+
- name: Check for unused dependencies
121+
run: cargo +nightly udeps --all-targets
122+
123+
# Job 3: Security audit to check for known vulnerabilities
124+
security:
125+
name: Security Audit
126+
runs-on: ubuntu-latest
127+
128+
steps:
129+
# Step 1: Check out the source code
130+
- name: Checkout source code
131+
uses: actions/checkout@v4
132+
133+
# Step 2: Install cargo-audit for security scanning
134+
- name: Install cargo-audit
135+
run: cargo install cargo-audit --locked
136+
137+
# Step 3: Run security audit on dependencies
138+
# This checks for known security vulnerabilities in our dependencies
139+
- name: Run security audit
140+
run: cargo audit
141+
142+
# Step 4: Check for vulnerabilities in our Cargo.lock file
143+
- name: Check advisories
144+
run: cargo audit --json | jq '.vulnerabilities'
145+
146+
# Job 4: Documentation checks
147+
docs:
148+
name: Documentation
149+
runs-on: ubuntu-latest
150+
151+
steps:
152+
# Step 1: Check out the source code
153+
- name: Checkout source code
154+
uses: actions/checkout@v4
155+
156+
# Step 2: Install stable Rust toolchain
157+
- name: Install Rust toolchain
158+
uses: dtolnay/rust-toolchain@stable
159+
160+
# Step 3: Setup caching
161+
- name: Setup Rust cache
162+
uses: Swatinem/rust-cache@v2
163+
164+
# Step 4: Build documentation to ensure it compiles without errors
165+
# This catches documentation issues early
166+
- name: Build documentation
167+
run: cargo doc --all --no-deps --document-private-items
168+
env:
169+
RUSTDOCFLAGS: "-D warnings"
170+
171+
# Step 5: Check that all public items have documentation
172+
- name: Check documentation coverage
173+
run: cargo doc --all --no-deps
174+
env:
175+
RUSTDOCFLAGS: "-D missing-docs"
176+
177+
# Job 5: Dependency review for supply chain security
178+
dependency-review:
179+
name: Dependency Review
180+
runs-on: ubuntu-latest
181+
if: github.event_name == 'pull_request'
182+
183+
steps:
184+
# Step 1: Check out the source code
185+
- name: Checkout source code
186+
uses: actions/checkout@v4
187+
188+
# Step 2: Run GitHub's dependency review action
189+
# This checks for security issues in dependency changes
190+
- name: Dependency Review
191+
uses: actions/dependency-review-action@v4

0 commit comments

Comments
 (0)