test-agents.yml 7.7 KB

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