|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + |
| 6 | +env: |
| 7 | + CARGO_TERM_COLOR: always |
| 8 | + RUST_BACKTRACE: 1 |
| 9 | + DATABASE_URL: sqlite:flashy.db |
| 10 | + |
| 11 | +jobs: |
| 12 | + lint: |
| 13 | + name: Format & Lint |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v6 |
| 17 | + |
| 18 | + - name: Install Rust toolchain |
| 19 | + uses: dtolnay/rust-toolchain@stable |
| 20 | + with: |
| 21 | + components: rustfmt, clippy |
| 22 | + targets: wasm32-unknown-unknown |
| 23 | + |
| 24 | + - name: Setup Rust cache |
| 25 | + uses: Swatinem/rust-cache@v2 |
| 26 | + with: |
| 27 | + cache-on-failure: true |
| 28 | + |
| 29 | + - name: Check formatting |
| 30 | + run: cargo fmt --all -- --check |
| 31 | + |
| 32 | + - name: Install SQLx CLI |
| 33 | + run: cargo install sqlx-cli --no-default-features --features sqlite --locked |
| 34 | + env: |
| 35 | + CARGO_TARGET_DIR: /tmp/sqlx-build |
| 36 | + |
| 37 | + - name: Create database and run migrations |
| 38 | + run: | |
| 39 | + sqlx database create |
| 40 | + sqlx migrate run |
| 41 | +
|
| 42 | + - name: Run Clippy |
| 43 | + run: cargo clippy --all-targets --all-features -- -D warnings |
| 44 | + |
| 45 | + test: |
| 46 | + name: Test Suite |
| 47 | + runs-on: ubuntu-latest |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v6 |
| 50 | + |
| 51 | + - name: Install Rust toolchain |
| 52 | + uses: dtolnay/rust-toolchain@stable |
| 53 | + with: |
| 54 | + targets: wasm32-unknown-unknown |
| 55 | + |
| 56 | + - name: Setup Rust cache |
| 57 | + uses: Swatinem/rust-cache@v2 |
| 58 | + with: |
| 59 | + cache-on-failure: true |
| 60 | + |
| 61 | + - name: Install SQLx CLI |
| 62 | + run: cargo install sqlx-cli --no-default-features --features sqlite --locked |
| 63 | + env: |
| 64 | + CARGO_TARGET_DIR: /tmp/sqlx-build |
| 65 | + |
| 66 | + - name: Create database and run migrations |
| 67 | + run: | |
| 68 | + sqlx database create |
| 69 | + sqlx migrate run |
| 70 | +
|
| 71 | + - name: Run tests |
| 72 | + run: cargo test --all-features |
| 73 | + |
| 74 | + build: |
| 75 | + name: Build (Leptos SSR) |
| 76 | + runs-on: ubuntu-latest |
| 77 | + steps: |
| 78 | + - uses: actions/checkout@v6 |
| 79 | + |
| 80 | + - name: Install Rust toolchain |
| 81 | + uses: dtolnay/rust-toolchain@stable |
| 82 | + with: |
| 83 | + targets: wasm32-unknown-unknown |
| 84 | + |
| 85 | + - name: Setup Rust cache |
| 86 | + uses: Swatinem/rust-cache@v2 |
| 87 | + with: |
| 88 | + cache-on-failure: true |
| 89 | + |
| 90 | + - name: Install cargo-leptos |
| 91 | + run: cargo install cargo-leptos --locked |
| 92 | + |
| 93 | + - name: Install SQLx CLI |
| 94 | + run: cargo install sqlx-cli --no-default-features --features sqlite --locked |
| 95 | + env: |
| 96 | + CARGO_TARGET_DIR: /tmp/sqlx-build |
| 97 | + |
| 98 | + - name: Create database and run migrations |
| 99 | + run: | |
| 100 | + sqlx database create |
| 101 | + sqlx migrate run |
| 102 | +
|
| 103 | + - name: Build with cargo-leptos |
| 104 | + run: cargo leptos build --release |
| 105 | + |
| 106 | + - name: Upload build artifacts |
| 107 | + uses: actions/upload-artifact@v7 |
| 108 | + with: |
| 109 | + name: leptos-build |
| 110 | + path: | |
| 111 | + target/release/flashy |
| 112 | + target/site/ |
| 113 | + retention-days: 3 |
| 114 | + |
| 115 | + security-audit: |
| 116 | + name: Security Audit |
| 117 | + runs-on: ubuntu-latest |
| 118 | + steps: |
| 119 | + - uses: actions/checkout@v6 |
| 120 | + |
| 121 | + - name: Install Rust toolchain |
| 122 | + uses: dtolnay/rust-toolchain@stable |
| 123 | + |
| 124 | + - name: Setup Rust cache |
| 125 | + uses: Swatinem/rust-cache@v2 |
| 126 | + with: |
| 127 | + cache-on-failure: true |
| 128 | + |
| 129 | + - name: Install cargo-audit |
| 130 | + run: cargo install cargo-audit --locked |
| 131 | + |
| 132 | + - name: Run security audit |
| 133 | + run: cargo audit |
| 134 | + |
| 135 | + all-checks-passed: |
| 136 | + name: All Checks Passed |
| 137 | + runs-on: ubuntu-latest |
| 138 | + needs: [lint, test, build, security-audit] |
| 139 | + if: always() |
| 140 | + steps: |
| 141 | + - name: Check if all jobs passed |
| 142 | + run: | |
| 143 | + if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then |
| 144 | + echo "One or more checks failed" |
| 145 | + exit 1 |
| 146 | + fi |
| 147 | + echo "All checks passed successfully!" |
0 commit comments