MCP Tools Test Suite #46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: MCP Tools Test Suite | |
on: | |
push: | |
branches: [main, develop] | |
pull_request: | |
branches: [main, develop] | |
workflow_dispatch: | |
schedule: | |
# Run tests daily at 2 AM UTC | |
- cron: "0 2 * * *" | |
jobs: | |
test-mcp-tools: | |
name: Test MCP Tools (${{ matrix.go-version }}, ${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
go-version: ["1.24.x"] | |
os: [ubuntu-latest, macos-latest] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
# Python setup removed (no Python tests) | |
- name: Cache Go modules | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/*.go') }} | |
restore-keys: | | |
${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}- | |
${{ runner.os }}-go- | |
- name: Install dependencies | |
run: | | |
go mod tidy | |
go mod download | |
go mod verify | |
go list -m all | |
- name: Install golangci-lint | |
run: | | |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.4.0 | |
- name: Debug module info | |
run: | | |
echo "=== Go Environment ===" | |
go env | |
echo "=== Module info ===" | |
go list -m | |
echo "=== All dependencies ===" | |
go list -m -f '{{.Path}} {{.Version}}' all | grep -E "(validator|yaml)" | |
echo "=== Current directory ===" | |
pwd | |
ls -la | |
- name: Run linting | |
run: make lint | |
- name: Build TaskWing | |
run: make build | |
- name: Run unit tests | |
run: make test-unit | |
- name: Run integration tests | |
run: make test-integration | |
- name: Run MCP protocol tests (Go) | |
run: make test-mcp | |
- name: Generate test coverage | |
run: make coverage | |
- name: Upload test results | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: test-results-${{ matrix.os }}-go${{ matrix.go-version }} | |
path: | | |
test-results/ | |
retention-days: 30 | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
file: ./test-results/coverage.out | |
flags: unittests | |
name: codecov-umbrella | |
fail_ci_if_error: false | |
- name: Comment test results on PR | |
if: github.event_name == 'pull_request' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const path = 'test-results/'; | |
if (fs.existsSync(path + 'coverage-summary.txt')) { | |
const coverage = fs.readFileSync(path + 'coverage-summary.txt', 'utf8'); | |
const coverageMatch = coverage.match(/total:.*?(\d+\.\d+)%/); | |
const coveragePercent = coverageMatch ? coverageMatch[1] : 'Unknown'; | |
let comment = `## 🧪 Test Results (${{ matrix.os }}, Go ${{ matrix.go-version }})\n\n`; | |
comment += `- **Coverage**: ${coveragePercent}%\n`; | |
comment += `- **OS**: ${{ matrix.os }}\n`; | |
comment += `- **Go Version**: ${{ matrix.go-version }}\n\n`; | |
// MCP protocol tests are covered by Go test logs in test-results | |
comment += `\n---\n*Automated test results from GitHub Actions*`; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: comment | |
}); | |
} | |
test-mcp-comprehensive: | |
name: Comprehensive MCP Test Suite | |
runs-on: ubuntu-latest | |
needs: test-mcp-tools | |
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.24.x" | |
- name: Install dependencies | |
run: | | |
go mod tidy | |
go mod download | |
- name: Run comprehensive test suite | |
run: make test-all | |
- name: Generate comprehensive report | |
run: | | |
echo "## 🎯 Comprehensive MCP Tools Test Report" > comprehensive-report.md | |
echo "" >> comprehensive-report.md | |
echo "**Date**: $(date)" >> comprehensive-report.md | |
echo "**Commit**: ${{ github.sha }}" >> comprehensive-report.md | |
echo "" >> comprehensive-report.md | |
if [ -f test-results/coverage-summary.txt ]; then | |
echo "### Test Coverage" >> comprehensive-report.md | |
cat test-results/coverage-summary.txt >> comprehensive-report.md | |
echo "" >> comprehensive-report.md | |
fi | |
echo "### MCP Protocol Tests" >> comprehensive-report.md | |
echo "See test-results/mcp-protocol.log for details." >> comprehensive-report.md | |
- name: Upload comprehensive report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: comprehensive-mcp-test-report | |
path: | | |
comprehensive-report.md | |
test-results/ | |
retention-days: 90 | |
- name: Create release on successful comprehensive test | |
if: github.ref == 'refs/heads/main' && success() | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
// Create a pre-release tag if comprehensive tests pass | |
const tag = `test-validated-${new Date().toISOString().split('T')[0]}-${context.sha.substring(0, 7)}`; | |
try { | |
await github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: `refs/tags/${tag}`, | |
sha: context.sha | |
}); | |
console.log(`Created tag: ${tag}`); | |
} catch (error) { | |
console.log(`Tag creation failed: ${error.message}`); | |
} | |
notification: | |
name: Test Results Notification | |
runs-on: ubuntu-latest | |
needs: [test-mcp-tools, test-mcp-comprehensive] | |
if: always() && (failure() || success()) | |
steps: | |
- name: Notify on test completion | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const testResults = '${{ needs.test-mcp-tools.result }}'; | |
const comprehensiveResults = '${{ needs.test-mcp-comprehensive.result }}'; | |
let status = '✅ All tests passed'; | |
let color = 'success'; | |
if (testResults === 'failure' || comprehensiveResults === 'failure') { | |
status = '❌ Some tests failed'; | |
color = 'failure'; | |
} else if (testResults === 'cancelled' || comprehensiveResults === 'cancelled') { | |
status = '⏹️ Tests cancelled'; | |
color = 'cancelled'; | |
} | |
console.log(`Test Status: ${status}`); | |
console.log(`Color: ${color}`); | |
// You can add Slack/Discord/Email notifications here if needed |