name: ๐Ÿงช Comprehensive Testing Suite on: push: branches: [main, develop] pull_request: branches: [main] env: CARGO_TERM_COLOR: always RUST_BACKTRACE: 1 # Performance testing thresholds MAX_BUNDLE_SIZE_KB: 500 MAX_RENDER_TIME_MS: 16 MIN_TEST_COVERAGE: 98 jobs: # ======================================== # Phase 1: Unit Testing Matrix # ======================================== unit-tests: name: ๐Ÿฆ€ Unit Tests (${{ matrix.rust }} on ${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: rust: [stable, beta, nightly] os: [ubuntu-latest, macos-latest, windows-latest] exclude: # Reduce matrix size for faster CI - rust: beta os: windows-latest - rust: nightly os: windows-latest steps: - name: ๐Ÿ“ฅ Checkout Repository uses: actions/checkout@v4 - name: ๐Ÿฆ€ Install Rust Toolchain uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust }} components: rustfmt, clippy - name: ๐Ÿ“ฆ Cache Dependencies uses: actions/cache@v4 with: path: | ~/.cargo/registry ~/.cargo/git target key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: | ${{ runner.os }}-cargo-${{ matrix.rust }}- ${{ runner.os }}-cargo- - name: ๐Ÿ” Check Code Format run: cargo fmt -- --check if: matrix.rust == 'stable' - name: ๐Ÿ“Ž Run Clippy run: cargo clippy --all-targets --all-features -- -D warnings if: matrix.rust == 'stable' - name: ๐Ÿงช Run Unit Tests run: cargo test --workspace --lib --bins --all-features --verbose - name: ๐Ÿ“Š Generate Coverage Report if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' run: | cargo install cargo-tarpaulin cargo tarpaulin --out xml --output-dir coverage/ - name: ๐Ÿ“ˆ Upload Coverage if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' uses: codecov/codecov-action@v4 with: file: coverage/cobertura.xml flags: unit-tests name: unit-tests-coverage # ======================================== # Phase 2: Component-Specific Testing # ======================================== component-tests: name: ๐ŸŽจ Component Tests runs-on: ubuntu-latest needs: unit-tests strategy: fail-fast: false matrix: component: - button - input - card - dialog - tooltip - accordion - table - form # Add more components as needed steps: - name: ๐Ÿ“ฅ Checkout Repository uses: actions/checkout@v4 - name: ๐Ÿฆ€ Install Rust Toolchain uses: dtolnay/rust-toolchain@stable - name: ๐Ÿ“ฆ Cache Dependencies uses: actions/cache@v4 with: path: | ~/.cargo/registry ~/.cargo/git target key: ubuntu-cargo-stable-${{ hashFiles('**/Cargo.lock') }} - name: ๐Ÿงช Test Component run: | echo "Testing ${{ matrix.component }} component..." cargo test --package leptos-shadcn-${{ matrix.component }} --lib --verbose - name: ๐Ÿ“Š Component Performance Test run: | echo "Running performance tests for ${{ matrix.component }}..." cargo test --package leptos-shadcn-${{ matrix.component }} --bench --verbose || true # ======================================== # Phase 3: E2E Testing with Playwright # ======================================== e2e-tests: name: ๐ŸŽญ E2E Tests (${{ matrix.browser }}) runs-on: ubuntu-latest needs: unit-tests strategy: fail-fast: false matrix: browser: [chromium, firefox, webkit] steps: - name: ๐Ÿ“ฅ Checkout Repository uses: actions/checkout@v4 - name: ๐Ÿ“ฆ Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' - name: ๐Ÿฆ€ Install Rust Toolchain uses: dtolnay/rust-toolchain@stable with: targets: wasm32-unknown-unknown - name: ๐Ÿ“ฆ Install Dependencies run: | npm install cargo install trunk - name: ๐ŸŽญ Install Playwright run: | npm install @playwright/test npx playwright install ${{ matrix.browser }} - name: ๐Ÿ—๏ธ Build Example App run: | cd examples/leptos trunk build --release - name: ๐ŸŽญ Run E2E Tests run: | npx playwright test --project=${{ matrix.browser }} --reporter=html env: PLAYWRIGHT_BROWSER: ${{ matrix.browser }} - name: ๐Ÿ“Š Upload E2E Results if: failure() uses: actions/upload-artifact@v4 with: name: e2e-results-${{ matrix.browser }} path: | test-results/ playwright-report/ # ======================================== # Phase 4: Performance Testing # ======================================== performance-tests: name: โšก Performance Tests runs-on: ubuntu-latest needs: [unit-tests, e2e-tests] steps: - name: ๐Ÿ“ฅ Checkout Repository uses: actions/checkout@v4 - name: ๐Ÿฆ€ Install Rust Toolchain uses: dtolnay/rust-toolchain@stable with: targets: wasm32-unknown-unknown - name: ๐Ÿ“ฆ Cache Dependencies uses: actions/cache@v4 with: path: | ~/.cargo/registry ~/.cargo/git target key: ubuntu-cargo-stable-perf-${{ hashFiles('**/Cargo.lock') }} - name: โšก Install Performance Tools run: | cargo install cargo-criterion cargo install trunk - name: ๐Ÿ“Š Run Performance Audit run: | cd performance-audit cargo test --release --verbose cargo run --release --bin performance-audit -- audit --output results.json - name: ๐Ÿ—๏ธ Bundle Size Analysis run: | cd examples/leptos trunk build --release du -sh dist/ > bundle-size.txt echo "Bundle size:" && cat bundle-size.txt - name: โšก Run Benchmarks run: | cargo bench --workspace || true - name: ๐Ÿ“ˆ Upload Performance Results uses: actions/upload-artifact@v4 with: name: performance-results path: | performance-audit/results.json bundle-size.txt target/criterion/ # ======================================== # Phase 5: Security & Quality Checks # ======================================== security-audit: name: ๐Ÿ›ก๏ธ Security Audit runs-on: ubuntu-latest needs: unit-tests steps: - name: ๐Ÿ“ฅ Checkout Repository uses: actions/checkout@v4 - name: ๐Ÿฆ€ Install Rust Toolchain uses: dtolnay/rust-toolchain@stable - name: ๐Ÿ›ก๏ธ Install Security Tools run: | cargo install cargo-audit cargo install cargo-deny - name: ๐Ÿ” Dependency Audit run: cargo audit - name: ๐Ÿšซ License Check run: cargo deny check - name: ๐Ÿ”’ Security Scan run: cargo audit --deny warnings # ======================================== # Phase 6: Accessibility Testing # ======================================== accessibility-tests: name: โ™ฟ Accessibility Tests runs-on: ubuntu-latest needs: e2e-tests steps: - name: ๐Ÿ“ฅ Checkout Repository uses: actions/checkout@v4 - name: ๐Ÿ“ฆ Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' - name: ๐Ÿฆ€ Install Rust Toolchain uses: dtolnay/rust-toolchain@stable with: targets: wasm32-unknown-unknown - name: โ™ฟ Install Accessibility Tools run: | npm install @axe-core/playwright cargo install trunk - name: ๐Ÿ—๏ธ Build Example App run: | cd examples/leptos trunk build --release - name: โ™ฟ Run Accessibility Tests run: | npx playwright test tests/e2e/accessibility.spec.ts --reporter=html - name: ๐Ÿ“Š Upload Accessibility Results if: always() uses: actions/upload-artifact@v4 with: name: accessibility-results path: playwright-report/ # ======================================== # Phase 7: Integration Summary # ======================================== integration-summary: name: ๐Ÿ“‹ Test Summary runs-on: ubuntu-latest needs: [unit-tests, component-tests, e2e-tests, performance-tests, security-audit, accessibility-tests] if: always() steps: - name: ๐Ÿ“Š Generate Test Report run: | echo "## ๐Ÿงช Comprehensive Test Results" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "| Test Suite | Status |" >> $GITHUB_STEP_SUMMARY echo "|------------|--------|" >> $GITHUB_STEP_SUMMARY echo "| Unit Tests | ${{ needs.unit-tests.result == 'success' && 'โœ… PASSED' || 'โŒ FAILED' }} |" >> $GITHUB_STEP_SUMMARY echo "| Component Tests | ${{ needs.component-tests.result == 'success' && 'โœ… PASSED' || 'โŒ FAILED' }} |" >> $GITHUB_STEP_SUMMARY echo "| E2E Tests | ${{ needs.e2e-tests.result == 'success' && 'โœ… PASSED' || 'โŒ FAILED' }} |" >> $GITHUB_STEP_SUMMARY echo "| Performance Tests | ${{ needs.performance-tests.result == 'success' && 'โœ… PASSED' || 'โŒ FAILED' }} |" >> $GITHUB_STEP_SUMMARY echo "| Security Audit | ${{ needs.security-audit.result == 'success' && 'โœ… PASSED' || 'โŒ FAILED' }} |" >> $GITHUB_STEP_SUMMARY echo "| Accessibility Tests | ${{ needs.accessibility-tests.result == 'success' && 'โœ… PASSED' || 'โŒ FAILED' }} |" >> $GITHUB_STEP_SUMMARY - name: ๐ŸŽฏ Check Quality Gates run: | echo "Quality gates validation completed" # Add specific quality gate checks here if [ "${{ needs.unit-tests.result }}" != "success" ]; then echo "โŒ Unit tests failed - blocking merge" exit 1 fi if [ "${{ needs.security-audit.result }}" != "success" ]; then echo "โŒ Security audit failed - blocking merge" exit 1 fi echo "โœ… All critical quality gates passed"