| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- # GitLab CI/CD Pipeline for Test Execution
- # Generated by BMad TEA Agent - Test Architect Module
- # Optimized for: Parallel Sharding, Burn-In Loop
- # Stack: {test_stack_type} | Framework: {test_framework}
- #
- # Variables to customize per project:
- # INSTALL_CMD - dependency install command (e.g., npm ci, pnpm install --frozen-lockfile)
- # TEST_CMD - main test command (e.g., npm run test:e2e, npm test, npx vitest)
- # LINT_CMD - lint command (e.g., npm run lint)
- # BROWSER_INSTALL - browser install command (frontend/fullstack only; omit for backend)
- # BROWSER_CACHE_PATH - browser cache path (frontend/fullstack only; omit for backend)
-
- stages:
- - lint
- - test
- - burn-in
- - report
-
- variables:
- # Disable git depth for accurate change detection
- GIT_DEPTH: 0
- # Use npm ci for faster, deterministic installs
- npm_config_cache: "$CI_PROJECT_DIR/.npm"
- # Playwright browser cache
- PLAYWRIGHT_BROWSERS_PATH: "$CI_PROJECT_DIR/.cache/ms-playwright"
- # Default Node version when .nvmrc is missing
- DEFAULT_NODE_VERSION: "24"
-
- # Caching configuration
- cache:
- key:
- files:
- - package-lock.json
- paths:
- - .npm/
- - .cache/ms-playwright/
- - node_modules/
-
- # Lint stage - Code quality checks
- lint:
- stage: lint
- image: node:$DEFAULT_NODE_VERSION
- before_script:
- - |
- NODE_VERSION=$(cat .nvmrc 2>/dev/null || echo "$DEFAULT_NODE_VERSION")
- echo "Using Node $NODE_VERSION"
- npm install -g n
- n "$NODE_VERSION"
- node -v
- - npm ci # Replace with INSTALL_CMD
- script:
- - npm run lint # Replace with LINT_CMD
- timeout: 5 minutes
-
- # Test stage - Parallel execution with sharding
- .test-template: &test-template
- stage: test
- image: node:$DEFAULT_NODE_VERSION
- needs:
- - lint
- before_script:
- - |
- NODE_VERSION=$(cat .nvmrc 2>/dev/null || echo "$DEFAULT_NODE_VERSION")
- echo "Using Node $NODE_VERSION"
- npm install -g n
- n "$NODE_VERSION"
- node -v
- - npm ci # Replace with INSTALL_CMD
- - npx playwright install --with-deps chromium # Replace with BROWSER_INSTALL; remove for backend-only
- artifacts:
- when: on_failure
- paths:
- - test-results/
- - playwright-report/
- expire_in: 30 days
- timeout: 30 minutes
-
- test:shard-1:
- <<: *test-template
- script:
- - npm run test:e2e -- --shard=1/4 # Replace with TEST_CMD + shard args
-
- test:shard-2:
- <<: *test-template
- script:
- - npm run test:e2e -- --shard=2/4 # Replace with TEST_CMD + shard args
-
- test:shard-3:
- <<: *test-template
- script:
- - npm run test:e2e -- --shard=3/4 # Replace with TEST_CMD + shard args
-
- test:shard-4:
- <<: *test-template
- script:
- - npm run test:e2e -- --shard=4/4 # Replace with TEST_CMD + shard args
-
- # Burn-in stage - Flaky test detection
- burn-in:
- stage: burn-in
- image: node:$DEFAULT_NODE_VERSION
- needs:
- - test:shard-1
- - test:shard-2
- - test:shard-3
- - test:shard-4
- # Only run burn-in on merge requests to main/develop or on schedule
- rules:
- - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- - if: '$CI_PIPELINE_SOURCE == "schedule"'
- before_script:
- - |
- NODE_VERSION=$(cat .nvmrc 2>/dev/null || echo "$DEFAULT_NODE_VERSION")
- echo "Using Node $NODE_VERSION"
- npm install -g n
- n "$NODE_VERSION"
- node -v
- - npm ci # Replace with INSTALL_CMD
- - npx playwright install --with-deps chromium # Replace with BROWSER_INSTALL; remove for backend-only
- # Note: Burn-in targets UI flakiness. For backend-only stacks, remove this job entirely.
- script:
- - |
- echo "🔥 Starting burn-in loop - detecting flaky tests"
- for i in {1..10}; do
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
- echo "🔥 Burn-in iteration $i/10"
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
- npm run test:e2e || exit 1 # Replace with TEST_CMD
- done
- echo "✅ Burn-in complete - no flaky tests detected"
- artifacts:
- when: on_failure
- paths:
- - test-results/
- - playwright-report/
- expire_in: 30 days
- timeout: 60 minutes
-
- # Report stage - Aggregate results
- report:
- stage: report
- image: alpine:latest
- needs:
- - test:shard-1
- - test:shard-2
- - test:shard-3
- - test:shard-4
- - burn-in
- when: always
- script:
- - |
- echo "## Test Execution Summary"
- echo ""
- echo "- Pipeline: $CI_PIPELINE_ID"
- echo "- Shards: 4"
- echo "- Branch: $CI_COMMIT_REF_NAME"
- echo ""
- echo "View detailed results in job artifacts"
|