選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

azure-pipelines-template.yaml 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. # Azure DevOps 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. # DEFAULT_NODE_VERSION - Node.js version (read from .nvmrc or default to 24)
  12. trigger:
  13. branches:
  14. include:
  15. - main
  16. - develop
  17. pr:
  18. branches:
  19. include:
  20. - main
  21. - develop
  22. variables:
  23. DEFAULT_NODE_VERSION: "24"
  24. npm_config_cache: $(Pipeline.Workspace)/.npm
  25. # Set TEST_STACK_TYPE to 'backend' to skip Playwright browser installs
  26. TEST_STACK_TYPE: "" # Values: frontend, backend, fullstack (leave empty for auto)
  27. stages:
  28. # Lint stage - Code quality checks
  29. - stage: Lint
  30. displayName: "Lint"
  31. jobs:
  32. - job: LintJob
  33. displayName: "Code Quality"
  34. pool:
  35. vmImage: "ubuntu-latest"
  36. timeoutInMinutes: 5
  37. steps:
  38. - task: NodeTool@0
  39. inputs:
  40. versionSpec: $(DEFAULT_NODE_VERSION)
  41. displayName: "Setup Node.js"
  42. - task: Cache@2
  43. inputs:
  44. key: 'npm | "$(Agent.OS)" | package-lock.json'
  45. restoreKeys: 'npm | "$(Agent.OS)"'
  46. path: $(npm_config_cache)
  47. displayName: "Cache npm"
  48. - script: npm ci
  49. displayName: "Install dependencies" # Replace with INSTALL_CMD
  50. - script: npm run lint
  51. displayName: "Run linter" # Replace with LINT_CMD
  52. # Test stage - Parallel execution with sharding
  53. - stage: Test
  54. displayName: "Test"
  55. dependsOn: Lint
  56. jobs:
  57. - job: TestShard
  58. displayName: "Test Shard"
  59. pool:
  60. vmImage: "ubuntu-latest"
  61. timeoutInMinutes: 30
  62. strategy:
  63. matrix:
  64. Shard1:
  65. SHARD_INDEX: 1
  66. Shard2:
  67. SHARD_INDEX: 2
  68. Shard3:
  69. SHARD_INDEX: 3
  70. Shard4:
  71. SHARD_INDEX: 4
  72. steps:
  73. - task: NodeTool@0
  74. inputs:
  75. versionSpec: $(DEFAULT_NODE_VERSION)
  76. displayName: "Setup Node.js"
  77. - task: Cache@2
  78. inputs:
  79. key: 'npm | "$(Agent.OS)" | package-lock.json'
  80. restoreKeys: 'npm | "$(Agent.OS)"'
  81. path: $(npm_config_cache)
  82. displayName: "Cache npm"
  83. - script: npm ci
  84. displayName: "Install dependencies" # Replace with INSTALL_CMD
  85. # Frontend/Fullstack only — skipped for backend-only stacks
  86. - script: npx playwright install --with-deps chromium
  87. condition: ne(variables['TEST_STACK_TYPE'], 'backend')
  88. displayName: "Install Playwright browsers" # Replace with BROWSER_INSTALL
  89. - script: npm run test:e2e -- --shard=$(SHARD_INDEX)/4
  90. displayName: "Run tests (shard $(SHARD_INDEX)/4)" # Replace with TEST_CMD + shard args
  91. - task: PublishTestResults@2
  92. condition: always()
  93. inputs:
  94. testResultsFormat: "JUnit"
  95. testResultsFiles: "test-results/**/*.xml"
  96. mergeTestResults: true
  97. displayName: "Publish test results"
  98. - publish: test-results/
  99. artifact: test-results-$(SHARD_INDEX)
  100. condition: failed()
  101. displayName: "Upload failure artifacts"
  102. # Burn-in stage - Flaky test detection
  103. # Note: Burn-in targets UI flakiness. For backend-only stacks, remove this stage entirely.
  104. - stage: BurnIn
  105. displayName: "Burn-In (Flaky Detection)"
  106. dependsOn: Test
  107. condition: and(succeeded(), or(eq(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.CronSchedule.DisplayName'], 'Weekly burn-in')))
  108. jobs:
  109. - job: BurnInJob
  110. displayName: "Burn-In Loop"
  111. pool:
  112. vmImage: "ubuntu-latest"
  113. timeoutInMinutes: 60
  114. steps:
  115. - task: NodeTool@0
  116. inputs:
  117. versionSpec: $(DEFAULT_NODE_VERSION)
  118. displayName: "Setup Node.js"
  119. - script: npm ci
  120. displayName: "Install dependencies" # Replace with INSTALL_CMD
  121. # Frontend/Fullstack only — skipped for backend-only stacks
  122. - script: npx playwright install --with-deps chromium
  123. condition: ne(variables['TEST_STACK_TYPE'], 'backend')
  124. displayName: "Install Playwright browsers" # Replace with BROWSER_INSTALL
  125. - script: |
  126. echo "Starting burn-in loop - detecting flaky tests"
  127. for i in $(seq 1 10); do
  128. echo "Burn-in iteration $i/10"
  129. npm run test:e2e || exit 1
  130. done
  131. echo "Burn-in complete - no flaky tests detected"
  132. displayName: "Run burn-in loop (10 iterations)" # Replace npm run test:e2e with TEST_CMD
  133. - publish: test-results/
  134. artifact: burn-in-failures
  135. condition: failed()
  136. displayName: "Upload burn-in failure artifacts"