cargo(deps): bump the logging group with 2 updates #22
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
# Workflow: Test crates.io Publishing | |
# | |
# This workflow tests that the package can be prepared for crates.io publishing | |
# without actually publishing it. Useful for validating the package before release. | |
name: Test Publishing | |
# Trigger conditions | |
on: | |
# Run on pushes to main to ensure package stays publishable | |
push: | |
branches: [ "main", "master" ] | |
# Run on pull requests to validate changes | |
pull_request: | |
branches: [ "main", "master" ] | |
# Allow manual triggering | |
workflow_dispatch: | |
# Environment variables | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: 1 | |
# Define jobs | |
jobs: | |
test-package: | |
name: Test Package for Publishing | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the source code | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
# Step 2: Install Rust toolchain | |
- name: Install Rust toolchain | |
uses: dtolnay/[email protected] | |
# Step 3: Setup Rust cache | |
- name: Setup Rust cache | |
uses: Swatinem/rust-cache@v2 | |
# Step 4: Validate Cargo.toml metadata | |
- name: Validate package metadata | |
run: | | |
echo "Validating Cargo.toml metadata for crates.io..." | |
# Check required fields are present using a temporary file | |
cargo metadata --format-version 1 --no-deps | jq -r '.packages[0]' > /tmp/package.json | |
# Verify required fields | |
required_fields=("description" "license" "repository" "authors") | |
for field in "${required_fields[@]}"; do | |
value=$(jq -r ".$field" /tmp/package.json) | |
if [ "$value" == "null" ] || [ -z "$value" ]; then | |
echo "❌ Missing required field: $field" | |
exit 1 | |
else | |
echo "✅ $field: $value" | |
fi | |
done | |
# Clean up temporary file | |
rm -f /tmp/package.json | |
echo "✅ All required metadata fields are present" | |
# Step 5: Test packaging (all examples without git dependencies) | |
- name: Test package | |
run: | | |
echo "Testing package for crates.io publishing..." | |
cargo package --verbose --allow-dirty | |
echo "✅ Package builds successfully and is ready for crates.io" | |
# Step 6: Verify example binaries can build | |
- name: Test example compilation | |
run: | | |
echo "Testing example binary compilation..." | |
# Test a few key examples to ensure they build correctly | |
cargo build --bin example_01_hello_world | |
cargo build --bin example_02_calculator | |
cargo build --bin example_09_database | |
cargo build --bin example_13_auth_service | |
cargo build --bin example_20_enterprise_server | |
echo "✅ All key examples compile successfully" | |
# Step 8: Generate package information | |
- name: Generate package info | |
run: | | |
echo "# Package Information" > package-info.md | |
echo "" >> package-info.md | |
echo "**Name:** $(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].name')" >> package-info.md | |
echo "**Version:** $(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version')" >> package-info.md | |
echo "**Description:** $(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].description')" >> package-info.md | |
echo "" >> package-info.md | |
echo "## Features" >> package-info.md | |
echo "- Educational Rust examples for MCP development" >> package-info.md | |
echo "- 20 comprehensive examples from basic to enterprise level" >> package-info.md | |
echo "- No external git dependencies for easy installation" >> package-info.md | |
echo "" >> package-info.md | |
echo "## Binaries" >> package-info.md | |
cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].targets[] | select(.kind[] == "bin") | "- " + .name' >> package-info.md | |
cat package-info.md | |
# Step 9: Upload package info | |
- name: Upload package information | |
uses: actions/upload-artifact@v4 | |
with: | |
name: package-info | |
path: package-info.md | |
retention-days: 30 |