name: Optimized Test Suite on: push: branches: [ main, develop, consolidate-side-enum ] pull_request: branches: [ main, develop ] env: CARGO_TERM_COLOR: always RUST_BACKTRACE: 1 CI_MODE: true FAST_MODE: true jobs: fast-tests: name: Fast Unit Tests runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@v4 - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable with: components: rustfmt, clippy - name: Cache Cargo registry uses: actions/cache@v3 with: path: | ~/.cargo/registry ~/.cargo/git key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Cache Cargo build uses: actions/cache@v3 with: path: target/ key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} - name: Run optimized fast tests run: ./scripts/optimized_test_runner.sh fast 300 timeout-minutes: 10 integration-tests: name: Integration Tests runs-on: ubuntu-latest timeout-minutes: 30 needs: fast-tests services: postgres: image: postgres:15 env: POSTGRES_PASSWORD: test POSTGRES_DB: foxhunt_test options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 5432:5432 redis: image: redis:7 options: >- --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 6379:6379 steps: - uses: actions/checkout@v4 - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - name: Cache dependencies uses: actions/cache@v3 with: path: | ~/.cargo/registry ~/.cargo/git target/ key: ${{ runner.os }}-cargo-integration-${{ hashFiles('**/Cargo.lock') }} - name: Setup test database run: | export DATABASE_URL=postgres://postgres:test@localhost:5432/foxhunt_test export REDIS_URL=redis://localhost:6379 export TEST_DATABASE_URL=$DATABASE_URL export TEST_REDIS_URL=$REDIS_URL - name: Run integration tests with optimizations run: ./scripts/optimized_test_runner.sh integration 600 timeout-minutes: 25 env: DATABASE_URL: postgres://postgres:test@localhost:5432/foxhunt_test REDIS_URL: redis://localhost:6379 performance-tests: name: Performance Tests runs-on: ubuntu-latest timeout-minutes: 20 needs: fast-tests steps: - uses: actions/checkout@v4 - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - name: Cache dependencies uses: actions/cache@v3 with: path: | ~/.cargo/registry ~/.cargo/git target/ key: ${{ runner.os }}-cargo-perf-${{ hashFiles('**/Cargo.lock') }} - name: Run performance tests run: ./scripts/optimized_test_runner.sh performance 600 timeout-minutes: 15 chaos-tests: name: Chaos Engineering Tests runs-on: ubuntu-latest timeout-minutes: 25 needs: [fast-tests, integration-tests] # Only run chaos tests on main branch or when specifically requested if: github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'chaos-tests') steps: - uses: actions/checkout@v4 - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - name: Cache dependencies uses: actions/cache@v3 with: path: | ~/.cargo/registry ~/.cargo/git target/ key: ${{ runner.os }}-cargo-chaos-${{ hashFiles('**/Cargo.lock') }} - name: Run chaos engineering tests with reduced timeouts run: ./scripts/optimized_test_runner.sh chaos 900 timeout-minutes: 20 env: CHAOS_REDUCED_TIMEOUTS: true full-test-suite: name: Full Test Suite (Nightly) runs-on: ubuntu-latest timeout-minutes: 60 # Only run full suite on schedule or manual trigger if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' services: postgres: image: postgres:15 env: POSTGRES_PASSWORD: test POSTGRES_DB: foxhunt_test options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 5432:5432 redis: image: redis:7 options: >- --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 6379:6379 steps: - uses: actions/checkout@v4 - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - name: Cache dependencies uses: actions/cache@v3 with: path: | ~/.cargo/registry ~/.cargo/git target/ key: ${{ runner.os }}-cargo-full-${{ hashFiles('**/Cargo.lock') }} - name: Setup test environment run: | export DATABASE_URL=postgres://postgres:test@localhost:5432/foxhunt_test export REDIS_URL=redis://localhost:6379 - name: Run full test suite run: ./scripts/optimized_test_runner.sh full 1800 timeout-minutes: 50 env: DATABASE_URL: postgres://postgres:test@localhost:5432/foxhunt_test REDIS_URL: redis://localhost:6379 FAST_MODE: false CI_MODE: true test-report: name: Test Report runs-on: ubuntu-latest needs: [fast-tests, integration-tests, performance-tests] if: always() steps: - name: Report test results run: | echo "## Test Execution Summary" >> $GITHUB_STEP_SUMMARY echo "| Test Suite | Status |" >> $GITHUB_STEP_SUMMARY echo "|------------|--------|" >> $GITHUB_STEP_SUMMARY echo "| Fast Tests | ${{ needs.fast-tests.result }} |" >> $GITHUB_STEP_SUMMARY echo "| Integration Tests | ${{ needs.integration-tests.result }} |" >> $GITHUB_STEP_SUMMARY echo "| Performance Tests | ${{ needs.performance-tests.result }} |" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "**Optimization Features Used:**" >> $GITHUB_STEP_SUMMARY echo "- โšก Parallel test execution" >> $GITHUB_STEP_SUMMARY echo "- ๐Ÿš€ Release mode compilation for faster execution" >> $GITHUB_STEP_SUMMARY echo "- ๐ŸŽฏ Targeted timeouts (5min unit, 10min integration, 15min performance)" >> $GITHUB_STEP_SUMMARY echo "- ๐Ÿงช Test doubles and mocks instead of real I/O" >> $GITHUB_STEP_SUMMARY echo "- ๐Ÿ“Š Smart test categorization and selective execution" >> $GITHUB_STEP_SUMMARY echo "- ๐Ÿ’พ Aggressive caching of dependencies and build artifacts" >> $GITHUB_STEP_SUMMARY if [ "${{ needs.fast-tests.result }}" = "success" ] && [ "${{ needs.integration-tests.result }}" = "success" ] && [ "${{ needs.performance-tests.result }}" = "success" ]; then echo "๐ŸŽ‰ **All core test suites passed successfully!**" >> $GITHUB_STEP_SUMMARY echo "โœ… System ready for deployment" >> $GITHUB_STEP_SUMMARY else echo "โŒ **Some test suites failed**" >> $GITHUB_STEP_SUMMARY echo "๐Ÿ” Check individual job logs for details" >> $GITHUB_STEP_SUMMARY fi # Schedule for nightly full test runs on: schedule: - cron: '0 2 * * *' # Run at 2 AM UTC daily # Allow manual triggering workflow_dispatch: inputs: test_suite: description: 'Test suite to run' required: true default: 'fast' type: choice options: - fast - integration - performance - chaos - full