|
| 1 | +name: Gevals MCP Evaluation |
| 2 | + |
| 3 | +on: |
| 4 | + # Weekly schedule - runs every Monday at 9 AM UTC |
| 5 | + schedule: |
| 6 | + - cron: '0 9 * * 1' |
| 7 | + |
| 8 | + # Manual trigger via PR comments |
| 9 | + issue_comment: |
| 10 | + types: [created] |
| 11 | + |
| 12 | + # Allow manual workflow dispatch for testing |
| 13 | + workflow_dispatch: |
| 14 | + inputs: |
| 15 | + task-filter: |
| 16 | + description: 'Regular expression to filter tasks (optional)' |
| 17 | + required: false |
| 18 | + default: '' |
| 19 | + verbose: |
| 20 | + description: 'Enable verbose output' |
| 21 | + required: false |
| 22 | + type: boolean |
| 23 | + default: false |
| 24 | + |
| 25 | +concurrency: |
| 26 | + # Only run once for latest commit per ref and cancel other (previous) runs. |
| 27 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 28 | + cancel-in-progress: true |
| 29 | + |
| 30 | +env: |
| 31 | + GO_VERSION: 1.25 |
| 32 | + |
| 33 | +defaults: |
| 34 | + run: |
| 35 | + shell: bash |
| 36 | + |
| 37 | +jobs: |
| 38 | + # Check if workflow should run based on trigger |
| 39 | + check-trigger: |
| 40 | + name: Check if evaluation should run |
| 41 | + runs-on: ubuntu-latest |
| 42 | + # Only run on PR comments in the main repository |
| 43 | + if: | |
| 44 | + github.event_name == 'schedule' || |
| 45 | + github.event_name == 'workflow_dispatch' || |
| 46 | + (github.event_name == 'issue_comment' && |
| 47 | + github.event.issue.pull_request && |
| 48 | + contains(github.event.comment.body, '/run-gevals')) |
| 49 | + outputs: |
| 50 | + should-run: ${{ steps.check.outputs.should-run }} |
| 51 | + pr-number: ${{ steps.check.outputs.pr-number }} |
| 52 | + steps: |
| 53 | + - name: Check trigger conditions |
| 54 | + id: check |
| 55 | + run: | |
| 56 | + if [[ "${{ github.event_name }}" == "issue_comment" ]]; then |
| 57 | + # Check if commenter is a maintainer (has write access) |
| 58 | + PERMISSION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 59 | + "https://api.github.com/repos/${{ github.repository }}/collaborators/${{ github.event.comment.user.login }}/permission" \ |
| 60 | + | jq -r '.permission') |
| 61 | +
|
| 62 | + if [[ "$PERMISSION" == "admin" || "$PERMISSION" == "write" ]]; then |
| 63 | + echo "should-run=true" >> $GITHUB_OUTPUT |
| 64 | + echo "pr-number=${{ github.event.issue.number }}" >> $GITHUB_OUTPUT |
| 65 | + else |
| 66 | + echo "should-run=false" >> $GITHUB_OUTPUT |
| 67 | + echo "User ${{ github.event.comment.user.login }} does not have permission to trigger evaluations" |
| 68 | + fi |
| 69 | + else |
| 70 | + echo "should-run=true" >> $GITHUB_OUTPUT |
| 71 | + fi |
| 72 | +
|
| 73 | + # Setup local Kind cluster for testing |
| 74 | + setup-cluster: |
| 75 | + name: Setup Kind cluster |
| 76 | + needs: check-trigger |
| 77 | + if: needs.check-trigger.outputs.should-run == 'true' |
| 78 | + runs-on: ubuntu-latest |
| 79 | + steps: |
| 80 | + - name: Checkout |
| 81 | + uses: actions/checkout@v4 |
| 82 | + with: |
| 83 | + # Checkout PR branch if triggered by comment |
| 84 | + ref: ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', needs.check-trigger.outputs.pr-number) || github.ref }} |
| 85 | + |
| 86 | + - name: Setup Kind |
| 87 | + run: | |
| 88 | + # Install Kind if not already available |
| 89 | + if ! command -v kind &> /dev/null; then |
| 90 | + curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64 |
| 91 | + chmod +x ./kind |
| 92 | + sudo mv ./kind /usr/local/bin/kind |
| 93 | + fi |
| 94 | +
|
| 95 | + # Create Kind cluster |
| 96 | + kind create cluster --name mcp-eval-cluster --wait 5m |
| 97 | +
|
| 98 | + - name: Verify cluster |
| 99 | + run: | |
| 100 | + kubectl cluster-info |
| 101 | + kubectl get nodes |
| 102 | +
|
| 103 | + # Keep cluster info for next job |
| 104 | + - name: Save kubeconfig |
| 105 | + run: | |
| 106 | + mkdir -p ${{ runner.temp }}/kubeconfig |
| 107 | + kind get kubeconfig --name mcp-eval-cluster > ${{ runner.temp }}/kubeconfig/config |
| 108 | +
|
| 109 | + - name: Upload kubeconfig |
| 110 | + uses: actions/upload-artifact@v4 |
| 111 | + with: |
| 112 | + name: kubeconfig |
| 113 | + path: ${{ runner.temp }}/kubeconfig/config |
| 114 | + retention-days: 1 |
| 115 | + |
| 116 | + # Run gevals evaluation |
| 117 | + run-evaluation: |
| 118 | + name: Run MCP Evaluation |
| 119 | + needs: [check-trigger, setup-cluster] |
| 120 | + if: needs.check-trigger.outputs.should-run == 'true' |
| 121 | + runs-on: ubuntu-latest |
| 122 | + steps: |
| 123 | + - name: Checkout |
| 124 | + uses: actions/checkout@v4 |
| 125 | + with: |
| 126 | + # Checkout PR branch if triggered by comment |
| 127 | + ref: ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', needs.check-trigger.outputs.pr-number) || github.ref }} |
| 128 | + |
| 129 | + - name: Download kubeconfig |
| 130 | + uses: actions/download-artifact@v4 |
| 131 | + with: |
| 132 | + name: kubeconfig |
| 133 | + path: ${{ runner.temp }}/kubeconfig |
| 134 | + |
| 135 | + - name: Setup Go |
| 136 | + uses: actions/setup-go@v5 |
| 137 | + with: |
| 138 | + go-version: ${{ env.GO_VERSION }} |
| 139 | + |
| 140 | + - name: Build MCP server |
| 141 | + run: make build |
| 142 | + |
| 143 | + - name: Start MCP server |
| 144 | + run: | |
| 145 | + export KUBECONFIG=${{ runner.temp }}/kubeconfig/config |
| 146 | + # Start MCP server in background |
| 147 | + ./kubernetes-mcp-server --http --port 8080 & |
| 148 | + MCP_PID=$! |
| 149 | + echo "MCP_PID=$MCP_PID" >> $GITHUB_ENV |
| 150 | +
|
| 151 | + # Wait for server to be ready |
| 152 | + for i in {1..30}; do |
| 153 | + if curl -s http://localhost:8080/health > /dev/null 2>&1; then |
| 154 | + echo "MCP server is ready" |
| 155 | + break |
| 156 | + fi |
| 157 | + echo "Waiting for MCP server to start... ($i/30)" |
| 158 | + sleep 2 |
| 159 | + done |
| 160 | +
|
| 161 | + - name: Run gevals evaluation |
| 162 | + uses: genmcp/gevals/.github/actions/gevals-action@main |
| 163 | + with: |
| 164 | + eval-config: 'evals/claude-code/eval.yaml' |
| 165 | + gevals-version: 'latest' |
| 166 | + task-filter: ${{ github.event.inputs.task-filter || '' }} |
| 167 | + output-format: 'json' |
| 168 | + verbose: ${{ github.event.inputs.verbose || 'false' }} |
| 169 | + upload-artifacts: 'true' |
| 170 | + artifact-name: 'gevals-results' |
| 171 | + fail-on-error: 'false' |
| 172 | + task-pass-threshold: '0.8' |
| 173 | + assertion-pass-threshold: '0.8' |
| 174 | + working-directory: '.' |
| 175 | + env: |
| 176 | + KUBECONFIG: ${{ runner.temp }}/kubeconfig/config |
| 177 | + # LLM Judge configuration |
| 178 | + JUDGE_BASE_URL: ${{ secrets.JUDGE_BASE_URL }} |
| 179 | + JUDGE_API_KEY: ${{ secrets.JUDGE_API_KEY }} |
| 180 | + JUDGE_MODEL_NAME: ${{ secrets.JUDGE_MODEL_NAME }} |
| 181 | + |
| 182 | + - name: Stop MCP server |
| 183 | + if: always() |
| 184 | + run: | |
| 185 | + if [ -n "$MCP_PID" ]; then |
| 186 | + kill $MCP_PID || true |
| 187 | + fi |
| 188 | +
|
| 189 | + - name: Post results comment on PR |
| 190 | + if: github.event_name == 'issue_comment' && always() |
| 191 | + uses: actions/github-script@v7 |
| 192 | + with: |
| 193 | + script: | |
| 194 | + const fs = require('fs'); |
| 195 | + const path = require('path'); |
| 196 | +
|
| 197 | + // Find the results file |
| 198 | + const resultsPattern = /gevals-.*-out\.json/; |
| 199 | + const files = fs.readdirSync('.'); |
| 200 | + const resultsFile = files.find(f => resultsPattern.test(f)); |
| 201 | +
|
| 202 | + if (!resultsFile) { |
| 203 | + await github.rest.issues.createComment({ |
| 204 | + owner: context.repo.owner, |
| 205 | + repo: context.repo.repo, |
| 206 | + issue_number: ${{ needs.check-trigger.outputs.pr-number }}, |
| 207 | + body: '❌ Gevals evaluation completed but no results file was found.' |
| 208 | + }); |
| 209 | + return; |
| 210 | + } |
| 211 | +
|
| 212 | + // Read and parse results |
| 213 | + const results = JSON.parse(fs.readFileSync(resultsFile, 'utf8')); |
| 214 | +
|
| 215 | + // Calculate summary stats |
| 216 | + const totalTasks = results.length; |
| 217 | + const passedTasks = results.filter(r => r.taskPassed && r.allAssertionsPassed).length; |
| 218 | + const failedTasks = totalTasks - passedTasks; |
| 219 | +
|
| 220 | + // Build comment body |
| 221 | + let comment = '## 🤖 Gevals MCP Evaluation Results\n\n'; |
| 222 | + comment += `**Summary:** ${passedTasks}/${totalTasks} tasks passed\n\n`; |
| 223 | +
|
| 224 | + if (failedTasks > 0) { |
| 225 | + comment += '### ❌ Failed Tasks\n\n'; |
| 226 | + results.filter(r => !r.taskPassed || !r.allAssertionsPassed).forEach(task => { |
| 227 | + comment += `- **${task.taskName}**\n`; |
| 228 | + comment += ` - Task Passed: ${task.taskPassed ? '✅' : '❌'}\n`; |
| 229 | + comment += ` - Assertions Passed: ${task.allAssertionsPassed ? '✅' : '❌'}\n`; |
| 230 | + }); |
| 231 | + comment += '\n'; |
| 232 | + } |
| 233 | +
|
| 234 | + comment += '### ✅ Passed Tasks\n\n'; |
| 235 | + results.filter(r => r.taskPassed && r.allAssertionsPassed).forEach(task => { |
| 236 | + comment += `- ${task.taskName}\n`; |
| 237 | + }); |
| 238 | +
|
| 239 | + comment += `\n[View full results](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})`; |
| 240 | +
|
| 241 | + await github.rest.issues.createComment({ |
| 242 | + owner: context.repo.owner, |
| 243 | + repo: context.repo.repo, |
| 244 | + issue_number: ${{ needs.check-trigger.outputs.pr-number }}, |
| 245 | + body: comment |
| 246 | + }); |
| 247 | +
|
| 248 | + # Cleanup |
| 249 | + cleanup: |
| 250 | + name: Cleanup Kind cluster |
| 251 | + needs: [setup-cluster, run-evaluation] |
| 252 | + if: always() |
| 253 | + runs-on: ubuntu-latest |
| 254 | + steps: |
| 255 | + - name: Delete Kind cluster |
| 256 | + run: | |
| 257 | + if command -v kind &> /dev/null; then |
| 258 | + kind delete cluster --name mcp-eval-cluster || true |
| 259 | + fi |
0 commit comments