2
0

gitlab-ci-template.yaml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. # GitLab CI/CD Pipeline for Test Execution
  2. # Generated by BMad TEA Agent - Test Architect Module
  3. # Optimized for: Playwright/Cypress, Parallel Sharding, Burn-In Loop
  4. stages:
  5. - lint
  6. - test
  7. - burn-in
  8. - report
  9. variables:
  10. # Disable git depth for accurate change detection
  11. GIT_DEPTH: 0
  12. # Use npm ci for faster, deterministic installs
  13. npm_config_cache: "$CI_PROJECT_DIR/.npm"
  14. # Playwright browser cache
  15. PLAYWRIGHT_BROWSERS_PATH: "$CI_PROJECT_DIR/.cache/ms-playwright"
  16. # Default Node version when .nvmrc is missing
  17. DEFAULT_NODE_VERSION: "24"
  18. # Caching configuration
  19. cache:
  20. key:
  21. files:
  22. - package-lock.json
  23. paths:
  24. - .npm/
  25. - .cache/ms-playwright/
  26. - node_modules/
  27. # Lint stage - Code quality checks
  28. lint:
  29. stage: lint
  30. image: node:$DEFAULT_NODE_VERSION
  31. before_script:
  32. - |
  33. NODE_VERSION=$(cat .nvmrc 2>/dev/null || echo "$DEFAULT_NODE_VERSION")
  34. echo "Using Node $NODE_VERSION"
  35. npm install -g n
  36. n "$NODE_VERSION"
  37. node -v
  38. - npm ci
  39. script:
  40. - npm run lint
  41. timeout: 5 minutes
  42. # Test stage - Parallel execution with sharding
  43. .test-template: &test-template
  44. stage: test
  45. image: node:$DEFAULT_NODE_VERSION
  46. needs:
  47. - lint
  48. before_script:
  49. - |
  50. NODE_VERSION=$(cat .nvmrc 2>/dev/null || echo "$DEFAULT_NODE_VERSION")
  51. echo "Using Node $NODE_VERSION"
  52. npm install -g n
  53. n "$NODE_VERSION"
  54. node -v
  55. - npm ci
  56. - npx playwright install --with-deps chromium
  57. artifacts:
  58. when: on_failure
  59. paths:
  60. - test-results/
  61. - playwright-report/
  62. expire_in: 30 days
  63. timeout: 30 minutes
  64. test:shard-1:
  65. <<: *test-template
  66. script:
  67. - npm run test:e2e -- --shard=1/4
  68. test:shard-2:
  69. <<: *test-template
  70. script:
  71. - npm run test:e2e -- --shard=2/4
  72. test:shard-3:
  73. <<: *test-template
  74. script:
  75. - npm run test:e2e -- --shard=3/4
  76. test:shard-4:
  77. <<: *test-template
  78. script:
  79. - npm run test:e2e -- --shard=4/4
  80. # Burn-in stage - Flaky test detection
  81. burn-in:
  82. stage: burn-in
  83. image: node:$DEFAULT_NODE_VERSION
  84. needs:
  85. - test:shard-1
  86. - test:shard-2
  87. - test:shard-3
  88. - test:shard-4
  89. # Only run burn-in on merge requests to main/develop or on schedule
  90. rules:
  91. - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
  92. - if: '$CI_PIPELINE_SOURCE == "schedule"'
  93. before_script:
  94. - |
  95. NODE_VERSION=$(cat .nvmrc 2>/dev/null || echo "$DEFAULT_NODE_VERSION")
  96. echo "Using Node $NODE_VERSION"
  97. npm install -g n
  98. n "$NODE_VERSION"
  99. node -v
  100. - npm ci
  101. - npx playwright install --with-deps chromium
  102. script:
  103. - |
  104. echo "🔥 Starting burn-in loop - detecting flaky tests"
  105. for i in {1..10}; do
  106. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  107. echo "🔥 Burn-in iteration $i/10"
  108. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  109. npm run test:e2e || exit 1
  110. done
  111. echo "✅ Burn-in complete - no flaky tests detected"
  112. artifacts:
  113. when: on_failure
  114. paths:
  115. - test-results/
  116. - playwright-report/
  117. expire_in: 30 days
  118. timeout: 60 minutes
  119. # Report stage - Aggregate results
  120. report:
  121. stage: report
  122. image: alpine:latest
  123. needs:
  124. - test:shard-1
  125. - test:shard-2
  126. - test:shard-3
  127. - test:shard-4
  128. - burn-in
  129. when: always
  130. script:
  131. - |
  132. echo "## Test Execution Summary"
  133. echo ""
  134. echo "- Pipeline: $CI_PIPELINE_ID"
  135. echo "- Shards: 4"
  136. echo "- Branch: $CI_COMMIT_REF_NAME"
  137. echo ""
  138. echo "View detailed results in job artifacts"