Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

gitlab-ci-template.yaml 4.6KB

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