test-agents.yml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. # Install the OpenCode CLI (from opencode.ai, NOT our install.sh)
  27. # Our install.sh only installs agents/commands/tools, not the CLI binary
  28. # The @opencode-ai/sdk spawns `opencode serve` internally, so CLI is required
  29. - name: Install OpenCode CLI
  30. run: |
  31. npm install -g opencode-ai
  32. which opencode
  33. opencode --version
  34. # Install our OpenAgents components (agents, commands, tools)
  35. - name: Install OpenAgents Components
  36. run: bash install.sh essential --install-dir .opencode
  37. - name: Install dependencies
  38. working-directory: evals/framework
  39. run: npm install
  40. - name: Build framework
  41. working-directory: evals/framework
  42. run: npm run build
  43. - name: Run OpenAgent smoke test
  44. run: 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. # Install the OpenCode CLI (from opencode.ai, NOT our install.sh)
  68. # Our install.sh only installs agents/commands/tools, not the CLI binary
  69. # The @opencode-ai/sdk spawns `opencode serve` internally, so CLI is required
  70. - name: Install OpenCode CLI
  71. run: |
  72. npm install -g opencode-ai
  73. which opencode
  74. opencode --version
  75. # Install our OpenAgents components (agents, commands, tools)
  76. - name: Install OpenAgents Components
  77. run: bash install.sh essential --install-dir .opencode
  78. - name: Install dependencies
  79. working-directory: evals/framework
  80. run: npm install
  81. - name: Build framework
  82. working-directory: evals/framework
  83. run: npm run build
  84. - name: Run OpenCoder smoke test
  85. run: 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. permissions:
  132. contents: write
  133. steps:
  134. - name: Checkout code
  135. uses: actions/checkout@v4
  136. with:
  137. fetch-depth: 0
  138. token: ${{ secrets.GITHUB_TOKEN }}
  139. - name: Setup Node.js
  140. uses: actions/setup-node@v4
  141. with:
  142. node-version: '20'
  143. - name: Configure Git
  144. run: |
  145. git config user.name "github-actions[bot]"
  146. git config user.email "github-actions[bot]@users.noreply.github.com"
  147. - name: Determine version bump type
  148. id: bump-type
  149. run: |
  150. # Get the last commit message
  151. COMMIT_MSG=$(git log -1 --pretty=%B)
  152. # Determine bump type from commit message
  153. if echo "$COMMIT_MSG" | grep -qiE "^(feat|feature)\(.*\)!:|^BREAKING CHANGE:|^[a-z]+!:"; then
  154. echo "type=major" >> $GITHUB_OUTPUT
  155. echo "Detected BREAKING CHANGE - bumping major version"
  156. elif echo "$COMMIT_MSG" | grep -qiE "^(feat|feature)(\(.*\))?:"; then
  157. echo "type=minor" >> $GITHUB_OUTPUT
  158. echo "Detected feature - bumping minor version"
  159. elif echo "$COMMIT_MSG" | grep -qiE "^(fix|bugfix)(\(.*\))?:"; then
  160. echo "type=patch" >> $GITHUB_OUTPUT
  161. echo "Detected fix - bumping patch version"
  162. elif echo "$COMMIT_MSG" | grep -qiE "^\[alpha\]"; then
  163. echo "type=alpha" >> $GITHUB_OUTPUT
  164. echo "Detected [alpha] tag - bumping alpha version"
  165. elif echo "$COMMIT_MSG" | grep -qiE "^\[beta\]"; then
  166. echo "type=beta" >> $GITHUB_OUTPUT
  167. echo "Detected [beta] tag - bumping beta version"
  168. elif echo "$COMMIT_MSG" | grep -qiE "^\[rc\]"; then
  169. echo "type=rc" >> $GITHUB_OUTPUT
  170. echo "Detected [rc] tag - bumping rc version"
  171. else
  172. echo "type=minor" >> $GITHUB_OUTPUT
  173. echo "No specific type detected - defaulting to minor version bump"
  174. fi
  175. - name: Bump version
  176. run: |
  177. BUMP_TYPE="${{ steps.bump-type.outputs.type }}"
  178. # Get current version
  179. CURRENT_VERSION=$(cat VERSION)
  180. echo "Current version: $CURRENT_VERSION"
  181. # Bump version in package.json
  182. npm run version:bump:$BUMP_TYPE
  183. # Get new version
  184. NEW_VERSION=$(cat VERSION)
  185. echo "New version: $NEW_VERSION"
  186. # Update CHANGELOG.md
  187. DATE=$(date +%Y-%m-%d)
  188. COMMIT_MSG=$(git log -1 --pretty=%B)
  189. # Create changelog entry
  190. cat > /tmp/changelog_entry.md << EOF
  191. ## [$NEW_VERSION] - $DATE
  192. ### Changes
  193. - $COMMIT_MSG
  194. EOF
  195. # Prepend to CHANGELOG.md (after the header)
  196. if [ -f CHANGELOG.md ]; then
  197. # Insert after the first occurrence of "## ["
  198. awk '/^## \[/ && !found {print; system("cat /tmp/changelog_entry.md"); found=1; next} 1' CHANGELOG.md > /tmp/changelog_new.md
  199. mv /tmp/changelog_new.md CHANGELOG.md
  200. fi
  201. - name: Commit version bump
  202. run: |
  203. NEW_VERSION=$(cat VERSION)
  204. git add VERSION package.json CHANGELOG.md
  205. git commit -m "chore: bump version to v$NEW_VERSION [skip ci]"
  206. git tag "v$NEW_VERSION"
  207. - name: Push changes
  208. run: |
  209. git push origin main --tags
  210. env:
  211. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}