|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, master] |
| 6 | + pull_request: |
| 7 | + branches: [main, master] |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + RUSTFLAGS: -Dwarnings |
| 12 | + |
| 13 | +jobs: |
| 14 | + check: |
| 15 | + name: Check Examples |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Install Rust toolchain |
| 21 | + uses: dtolnay/rust-action@stable |
| 22 | + with: |
| 23 | + components: clippy, rustfmt |
| 24 | + |
| 25 | + - name: Cache cargo registry |
| 26 | + uses: actions/cache@v4 |
| 27 | + with: |
| 28 | + path: | |
| 29 | + ~/.cargo/registry |
| 30 | + ~/.cargo/git |
| 31 | + target |
| 32 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }} |
| 33 | + restore-keys: | |
| 34 | + ${{ runner.os }}-cargo- |
| 35 | +
|
| 36 | + - name: Check all examples compile |
| 37 | + run: | |
| 38 | + echo "🔍 Checking all examples..." |
| 39 | + |
| 40 | + EXAMPLES=( |
| 41 | + "hello-world" |
| 42 | + "crud-api" |
| 43 | + "auth-api" |
| 44 | + "cors-test" |
| 45 | + "sqlx-crud" |
| 46 | + "event-sourcing" |
| 47 | + "graphql-api" |
| 48 | + "mcp-server" |
| 49 | + "microservices" |
| 50 | + "microservices-advanced" |
| 51 | + "middleware-chain" |
| 52 | + "phase11-demo" |
| 53 | + "rate-limit-demo" |
| 54 | + "templates" |
| 55 | + "toon-api" |
| 56 | + "websocket" |
| 57 | + "proof-of-concept" |
| 58 | + ) |
| 59 | + |
| 60 | + FAILED=() |
| 61 | + |
| 62 | + for example in "${EXAMPLES[@]}"; do |
| 63 | + echo "" |
| 64 | + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 65 | + echo "📦 Checking: $example" |
| 66 | + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 67 | + |
| 68 | + if cd "$example" && cargo check --quiet 2>&1; then |
| 69 | + echo "✅ $example: OK" |
| 70 | + else |
| 71 | + echo "❌ $example: FAILED" |
| 72 | + FAILED+=("$example") |
| 73 | + fi |
| 74 | + cd .. |
| 75 | + done |
| 76 | + |
| 77 | + echo "" |
| 78 | + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 79 | + echo "📊 Summary" |
| 80 | + echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" |
| 81 | + |
| 82 | + if [ ${#FAILED[@]} -eq 0 ]; then |
| 83 | + echo "✅ All ${#EXAMPLES[@]} examples passed!" |
| 84 | + exit 0 |
| 85 | + else |
| 86 | + echo "❌ ${#FAILED[@]} example(s) failed:" |
| 87 | + for f in "${FAILED[@]}"; do |
| 88 | + echo " - $f" |
| 89 | + done |
| 90 | + exit 1 |
| 91 | + fi |
| 92 | +
|
| 93 | + # Serverless Lambda uses different runtime, check separately |
| 94 | + - name: Check serverless-lambda |
| 95 | + run: | |
| 96 | + echo "📦 Checking: serverless-lambda (AWS Lambda runtime)" |
| 97 | + cd serverless-lambda && cargo check --quiet |
| 98 | + echo "✅ serverless-lambda: OK" |
| 99 | +
|
| 100 | + fmt: |
| 101 | + name: Format Check |
| 102 | + runs-on: ubuntu-latest |
| 103 | + steps: |
| 104 | + - uses: actions/checkout@v4 |
| 105 | + |
| 106 | + - name: Install Rust toolchain |
| 107 | + uses: dtolnay/rust-action@stable |
| 108 | + with: |
| 109 | + components: rustfmt |
| 110 | + |
| 111 | + - name: Check formatting |
| 112 | + run: | |
| 113 | + echo "🎨 Checking code formatting..." |
| 114 | + |
| 115 | + EXAMPLES=( |
| 116 | + "hello-world" |
| 117 | + "crud-api" |
| 118 | + "auth-api" |
| 119 | + "cors-test" |
| 120 | + "sqlx-crud" |
| 121 | + "event-sourcing" |
| 122 | + "graphql-api" |
| 123 | + "mcp-server" |
| 124 | + "microservices" |
| 125 | + "microservices-advanced" |
| 126 | + "middleware-chain" |
| 127 | + "phase11-demo" |
| 128 | + "rate-limit-demo" |
| 129 | + "serverless-lambda" |
| 130 | + "templates" |
| 131 | + "toon-api" |
| 132 | + "websocket" |
| 133 | + "proof-of-concept" |
| 134 | + ) |
| 135 | + |
| 136 | + for example in "${EXAMPLES[@]}"; do |
| 137 | + echo "Checking format: $example" |
| 138 | + cd "$example" && cargo fmt -- --check && cd .. |
| 139 | + done |
| 140 | + |
| 141 | + echo "✅ All formatting checks passed!" |
| 142 | +
|
| 143 | + clippy: |
| 144 | + name: Clippy Lint |
| 145 | + runs-on: ubuntu-latest |
| 146 | + steps: |
| 147 | + - uses: actions/checkout@v4 |
| 148 | + |
| 149 | + - name: Install Rust toolchain |
| 150 | + uses: dtolnay/rust-action@stable |
| 151 | + with: |
| 152 | + components: clippy |
| 153 | + |
| 154 | + - name: Cache cargo registry |
| 155 | + uses: actions/cache@v4 |
| 156 | + with: |
| 157 | + path: | |
| 158 | + ~/.cargo/registry |
| 159 | + ~/.cargo/git |
| 160 | + target |
| 161 | + key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.toml') }} |
| 162 | + restore-keys: | |
| 163 | + ${{ runner.os }}-cargo-clippy- |
| 164 | +
|
| 165 | + - name: Run Clippy on examples |
| 166 | + run: | |
| 167 | + echo "🔎 Running Clippy lints..." |
| 168 | + |
| 169 | + # Quick clippy check on a few key examples |
| 170 | + for example in hello-world crud-api auth-api middleware-chain; do |
| 171 | + echo "Linting: $example" |
| 172 | + cd "$example" && cargo clippy --quiet -- -D warnings && cd .. |
| 173 | + done |
| 174 | + |
| 175 | + echo "✅ Clippy checks passed!" |
0 commit comments