name: Test Pipeline on: push: branches: - main - develop - 'feature/**' pull_request: branches: - main - develop env: CARGO_TERM_COLOR: always RUST_BACKTRACE: 1 SQLX_OFFLINE: "true" jobs: test: name: Test Suite runs-on: ubuntu-latest timeout-minutes: 30 services: postgres: image: timescale/timescaledb:latest-pg16 env: POSTGRES_USER: foxhunt POSTGRES_PASSWORD: foxhunt_dev_password POSTGRES_DB: foxhunt ports: - 5432:5432 options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 redis: image: redis:7-alpine ports: - 6379:6379 options: >- --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 env: DATABASE_URL: postgresql://foxhunt:foxhunt_dev_password@localhost:5432/foxhunt REDIS_URL: redis://localhost:6379 JWT_SECRET: test_jwt_secret_key_minimum_32chars_long RUST_LOG: info steps: - name: Checkout Code uses: actions/checkout@v4 - name: Setup Rust Toolchain uses: dtolnay/rust-toolchain@stable with: components: rustfmt, clippy - name: Cache Cargo Registry uses: actions/cache@v4 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-cargo- - name: Check Formatting run: cargo fmt --all -- --check - name: Run Clippy run: cargo clippy --workspace --all-targets - name: Run Unit Tests run: cargo test --workspace --lib env: RUST_LOG: debug - name: Run Integration Tests run: cargo test --workspace --tests -- --test-threads=1 timeout-minutes: 15 - name: Upload Test Results uses: actions/upload-artifact@v4 if: always() with: name: test-results path: target/nextest/ retention-days: 30 security-audit: name: Security Audit runs-on: ubuntu-latest timeout-minutes: 10 steps: - name: Checkout Code uses: actions/checkout@v4 - name: Setup Rust Toolchain uses: dtolnay/rust-toolchain@stable - name: Install Cargo Audit run: cargo install --locked cargo-audit - name: Run Security Audit run: cargo audit build-check: name: Build Check runs-on: ubuntu-latest timeout-minutes: 20 steps: - name: Checkout Code uses: actions/checkout@v4 - name: Setup Rust Toolchain uses: dtolnay/rust-toolchain@stable - name: Cache Cargo Registry uses: actions/cache@v4 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Check Compilation run: cargo check --workspace --all-targets - name: Build Release run: cargo build --workspace --release summary: name: Test Summary runs-on: ubuntu-latest needs: [test, security-audit, build-check] if: always() steps: - name: Generate Summary run: | echo "## Test Pipeline Summary" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY echo "| Test Suite | ${{ needs.test.result }} |" >> $GITHUB_STEP_SUMMARY echo "| Security Audit | ${{ needs.security-audit.result }} |" >> $GITHUB_STEP_SUMMARY echo "| Build Check | ${{ needs.build-check.result }} |" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY - name: Check Overall Status if: contains(needs.*.result, 'failure') run: | echo "::error::Pipeline failed - check job results above" exit 1