test-agents.yml 6.9 KB

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