name: API Integration Tests
on:
schedule:
# Run daily at 6:00 AM UTC
- cron: '0 6 * * *'
workflow_dispatch:
inputs:
test_all_providers:
description: 'Test all AI providers'
type: boolean
default: true
provider:
description: 'Specific provider to test'
type: choice
options:
- 'all'
- 'deepseek'
- 'openai'
- 'anthropic'
- 'o3'
default: 'all'
env:
NODE_VERSION: '18'
PNPM_VERSION: '8'
jobs:
# DeepSeek API Test
test-deepseek:
name: Test DeepSeek API
runs-on: ubuntu-latest
if: github.event.inputs.provider == 'deepseek' || github.event.inputs.provider == 'all' || github.event_name == 'schedule'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build project
run: pnpm run build
- name: Test DeepSeek API
run: node scripts/test-deepseek-api.js
env:
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
- name: Verify DeepSeek MCP Integration
run: DEEPSEEK_API_KEY=${{ secrets.DEEPSEEK_API_KEY }} timeout 60s pnpm run verify-deepseek || true
continue-on-error: true
# OpenAI API Test
test-openai:
name: Test OpenAI API
runs-on: ubuntu-latest
if: (github.event.inputs.provider == 'openai' || github.event.inputs.provider == 'all' || github.event_name == 'schedule') && github.event.inputs.test_all_providers
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build project
run: pnpm run build
- name: Test OpenAI API
run: |
cat > scripts/test-openai-api.js << 'EOF'
import axios from 'axios';
const API_KEY = process.env.OPENAI_API_KEY;
const API_URL = 'https://api.openai.com/v1/chat/completions';
async function testOpenAI() {
try {
const response = await axios.post(API_URL, {
model: 'gpt-3.5-turbo',
messages: [{ role: 'user', content: 'Say "OpenAI API is working!"' }],
max_tokens: 20
}, {
headers: { 'Authorization': `Bearer ${API_KEY}` }
});
console.log('✅ OpenAI API is working');
console.log('Response:', response.data.choices[0].message.content);
} catch (error) {
console.log('❌ OpenAI API test failed:', error.message);
process.exit(1);
}
}
testOpenAI();
EOF
node scripts/test-openai-api.js
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# Anthropic API Test
test-anthropic:
name: Test Anthropic API
runs-on: ubuntu-latest
if: (github.event.inputs.provider == 'anthropic' || github.event.inputs.provider == 'all' || github.event_name == 'schedule') && github.event.inputs.test_all_providers
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build project
run: pnpm run build
- name: Test Anthropic API
run: |
cat > scripts/test-anthropic-api.js << 'EOF'
import axios from 'axios';
const API_KEY = process.env.ANTHROPIC_API_KEY;
const API_URL = 'https://api.anthropic.com/v1/messages';
async function testAnthropic() {
try {
const response = await axios.post(API_URL, {
model: 'claude-3-haiku-20240307',
max_tokens: 20,
messages: [{ role: 'user', content: 'Say "Anthropic API is working!"' }]
}, {
headers: {
'x-api-key': API_KEY,
'anthropic-version': '2023-06-01'
}
});
console.log('✅ Anthropic API is working');
console.log('Response:', response.data.content[0].text);
} catch (error) {
console.log('❌ Anthropic API test failed:', error.message);
process.exit(1);
}
}
testAnthropic();
EOF
node scripts/test-anthropic-api.js
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
# Comprehensive Integration Test
integration-test:
name: Full Integration Test
runs-on: ubuntu-latest
needs: [test-deepseek]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build project
run: pnpm run build
- name: Run integration tests
run: pnpm run test:integration
env:
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
- name: Test MCP Protocol Compliance
run: |
# Test basic MCP protocol responses
timeout 30s node -e "
import('./dist/index.js').then(() => {
console.log('✅ MCP server loads successfully');
process.exit(0);
}).catch(err => {
console.error('❌ MCP server failed to load:', err.message);
process.exit(1);
});
"
env:
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
# Report Results
report:
name: Test Report
runs-on: ubuntu-latest
needs: [test-deepseek, test-openai, test-anthropic, integration-test]
if: always()
steps:
- name: Report Results
run: |
echo "## API Test Results 📊" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Provider | Status |" >> $GITHUB_STEP_SUMMARY
echo "|----------|--------|" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.test-deepseek.result }}" == "success" ]; then
echo "| DeepSeek | ✅ Passed |" >> $GITHUB_STEP_SUMMARY
else
echo "| DeepSeek | ❌ Failed |" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ needs.test-openai.result }}" == "success" ]; then
echo "| OpenAI | ✅ Passed |" >> $GITHUB_STEP_SUMMARY
elif [ "${{ needs.test-openai.result }}" == "skipped" ]; then
echo "| OpenAI | ⏭️ Skipped |" >> $GITHUB_STEP_SUMMARY
else
echo "| OpenAI | ❌ Failed |" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ needs.test-anthropic.result }}" == "success" ]; then
echo "| Anthropic | ✅ Passed |" >> $GITHUB_STEP_SUMMARY
elif [ "${{ needs.test-anthropic.result }}" == "skipped" ]; then
echo "| Anthropic | ⏭️ Skipped |" >> $GITHUB_STEP_SUMMARY
else
echo "| Anthropic | ❌ Failed |" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ needs.integration-test.result }}" == "success" ]; then
echo "| Integration | ✅ Passed |" >> $GITHUB_STEP_SUMMARY
else
echo "| Integration | ❌ Failed |" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "_Last updated: $(date)_" >> $GITHUB_STEP_SUMMARY
- name: Notify on Failure
if: failure()
uses: actions/github-script@v7
with:
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'API Integration Test Failure',
body: `🚨 **API Integration Tests Failed**
One or more AI provider APIs are not responding correctly.
**Failed Tests:**
- DeepSeek: ${{ needs.test-deepseek.result }}
- OpenAI: ${{ needs.test-openai.result }}
- Anthropic: ${{ needs.test-anthropic.result }}
- Integration: ${{ needs.integration-test.result }}
**Workflow:** ${context.workflow}
**Run:** ${context.runNumber}
**Commit:** ${context.sha}
Please investigate and resolve the API connectivity issues.`,
labels: ['bug', 'api', 'urgent']
})