test-agents.yml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. name: Test Agents
  2. on:
  3. pull_request:
  4. branches: [ main, dev ]
  5. paths:
  6. - '.opencode/agent/**'
  7. - 'evals/**'
  8. - '.github/workflows/test-agents.yml'
  9. push:
  10. branches: [ main ]
  11. workflow_dispatch:
  12. jobs:
  13. test-openagent:
  14. name: Test OpenAgent
  15. runs-on: ubuntu-latest
  16. timeout-minutes: 10
  17. steps:
  18. - name: Checkout code
  19. uses: actions/checkout@v4
  20. - name: Debug - List files
  21. run: |
  22. echo "=== Root directory ==="
  23. ls -la
  24. echo "=== Evals directory ==="
  25. ls -la evals/ || echo "evals/ not found"
  26. echo "=== Framework directory ==="
  27. ls -la evals/framework/ || echo "evals/framework/ not found"
  28. - name: Setup Node.js
  29. uses: actions/setup-node@v4
  30. with:
  31. node-version: '20'
  32. cache: 'npm'
  33. cache-dependency-path: 'evals/framework/package-lock.json'
  34. - name: Install dependencies
  35. working-directory: evals/framework
  36. run: npm ci
  37. - name: Build framework
  38. working-directory: evals/framework
  39. run: npm run build
  40. - name: Run OpenAgent smoke test
  41. run: npm run test:ci:openagent
  42. env:
  43. CI: true
  44. - name: Upload test results
  45. if: always()
  46. uses: actions/upload-artifact@v4
  47. with:
  48. name: openagent-results
  49. path: evals/results/
  50. retention-days: 30
  51. test-opencoder:
  52. name: Test OpenCoder
  53. runs-on: ubuntu-latest
  54. timeout-minutes: 10
  55. steps:
  56. - name: Checkout code
  57. uses: actions/checkout@v4
  58. - name: Debug - List files
  59. run: |
  60. echo "=== Root directory ==="
  61. ls -la
  62. echo "=== Evals directory ==="
  63. ls -la evals/ || echo "evals/ not found"
  64. echo "=== Framework directory ==="
  65. ls -la evals/framework/ || echo "evals/framework/ not found"
  66. - name: Setup Node.js
  67. uses: actions/setup-node@v4
  68. with:
  69. node-version: '20'
  70. cache: 'npm'
  71. cache-dependency-path: 'evals/framework/package-lock.json'
  72. - name: Install dependencies
  73. working-directory: evals/framework
  74. run: npm ci
  75. - name: Build framework
  76. working-directory: evals/framework
  77. run: npm run build
  78. - name: Run OpenCoder smoke test
  79. run: npm run test:ci:opencoder
  80. env:
  81. CI: true
  82. - name: Upload test results
  83. if: always()
  84. uses: actions/upload-artifact@v4
  85. with:
  86. name: opencoder-results
  87. path: evals/results/
  88. retention-days: 30
  89. report-results:
  90. name: Report Test Results
  91. runs-on: ubuntu-latest
  92. needs: [test-openagent, test-opencoder]
  93. if: always()
  94. steps:
  95. - name: Download OpenAgent results
  96. uses: actions/download-artifact@v4
  97. with:
  98. name: openagent-results
  99. path: results/openagent
  100. continue-on-error: true
  101. - name: Download OpenCoder results
  102. uses: actions/download-artifact@v4
  103. with:
  104. name: opencoder-results
  105. path: results/opencoder
  106. continue-on-error: true
  107. - name: Display results summary
  108. run: |
  109. echo "## Test Results Summary" >> $GITHUB_STEP_SUMMARY
  110. echo "" >> $GITHUB_STEP_SUMMARY
  111. if [ -f results/openagent/latest.json ]; then
  112. echo "### OpenAgent" >> $GITHUB_STEP_SUMMARY
  113. cat results/openagent/latest.json | jq -r '"- Passed: \(.passed)\n- Failed: \(.failed)\n- Total: \(.total)"' >> $GITHUB_STEP_SUMMARY
  114. fi
  115. if [ -f results/opencoder/latest.json ]; then
  116. echo "" >> $GITHUB_STEP_SUMMARY
  117. echo "### OpenCoder" >> $GITHUB_STEP_SUMMARY
  118. cat results/opencoder/latest.json | jq -r '"- Passed: \(.passed)\n- Failed: \(.failed)\n- Total: \(.total)"' >> $GITHUB_STEP_SUMMARY
  119. fi
  120. auto-version-bump:
  121. name: Auto Version Bump
  122. runs-on: ubuntu-latest
  123. needs: [test-openagent, test-opencoder]
  124. if: github.event_name == 'push' && github.ref == 'refs/heads/main'
  125. steps:
  126. - name: Checkout code
  127. uses: actions/checkout@v4
  128. with:
  129. fetch-depth: 0
  130. token: ${{ secrets.GITHUB_TOKEN }}
  131. - name: Setup Node.js
  132. uses: actions/setup-node@v4
  133. with:
  134. node-version: '20'
  135. - name: Configure Git
  136. run: |
  137. git config user.name "github-actions[bot]"
  138. git config user.email "github-actions[bot]@users.noreply.github.com"
  139. - name: Determine version bump type
  140. id: bump-type
  141. run: |
  142. # Get the last commit message
  143. COMMIT_MSG=$(git log -1 --pretty=%B)
  144. # Determine bump type from commit message
  145. if echo "$COMMIT_MSG" | grep -qiE "^(feat|feature)\(.*\)!:|^BREAKING CHANGE:|^[a-z]+!:"; then
  146. echo "type=major" >> $GITHUB_OUTPUT
  147. echo "Detected BREAKING CHANGE - bumping major version"
  148. elif echo "$COMMIT_MSG" | grep -qiE "^(feat|feature)(\(.*\))?:"; then
  149. echo "type=minor" >> $GITHUB_OUTPUT
  150. echo "Detected feature - bumping minor version"
  151. elif echo "$COMMIT_MSG" | grep -qiE "^(fix|bugfix)(\(.*\))?:"; then
  152. echo "type=patch" >> $GITHUB_OUTPUT
  153. echo "Detected fix - bumping patch version"
  154. elif echo "$COMMIT_MSG" | grep -qiE "^\[alpha\]"; then
  155. echo "type=alpha" >> $GITHUB_OUTPUT
  156. echo "Detected [alpha] tag - bumping alpha version"
  157. elif echo "$COMMIT_MSG" | grep -qiE "^\[beta\]"; then
  158. echo "type=beta" >> $GITHUB_OUTPUT
  159. echo "Detected [beta] tag - bumping beta version"
  160. elif echo "$COMMIT_MSG" | grep -qiE "^\[rc\]"; then
  161. echo "type=rc" >> $GITHUB_OUTPUT
  162. echo "Detected [rc] tag - bumping rc version"
  163. else
  164. echo "type=minor" >> $GITHUB_OUTPUT
  165. echo "No specific type detected - defaulting to minor version bump"
  166. fi
  167. - name: Bump version
  168. run: |
  169. BUMP_TYPE="${{ steps.bump-type.outputs.type }}"
  170. # Get current version
  171. CURRENT_VERSION=$(cat VERSION)
  172. echo "Current version: $CURRENT_VERSION"
  173. # Bump version in package.json
  174. npm run version:bump:$BUMP_TYPE
  175. # Get new version
  176. NEW_VERSION=$(cat VERSION)
  177. echo "New version: $NEW_VERSION"
  178. # Update CHANGELOG.md
  179. DATE=$(date +%Y-%m-%d)
  180. COMMIT_MSG=$(git log -1 --pretty=%B)
  181. # Create changelog entry
  182. cat > /tmp/changelog_entry.md << EOF
  183. ## [$NEW_VERSION] - $DATE
  184. ### Changes
  185. - $COMMIT_MSG
  186. EOF
  187. # Prepend to CHANGELOG.md (after the header)
  188. if [ -f CHANGELOG.md ]; then
  189. # Insert after the first occurrence of "## ["
  190. awk '/^## \[/ && !found {print; system("cat /tmp/changelog_entry.md"); found=1; next} 1' CHANGELOG.md > /tmp/changelog_new.md
  191. mv /tmp/changelog_new.md CHANGELOG.md
  192. fi
  193. - name: Commit version bump
  194. run: |
  195. NEW_VERSION=$(cat VERSION)
  196. git add VERSION package.json CHANGELOG.md
  197. git commit -m "chore: bump version to v$NEW_VERSION [skip ci]"
  198. git tag "v$NEW_VERSION"
  199. - name: Push changes
  200. run: |
  201. git push origin main --tags
  202. env:
  203. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}