name: Run Tests on Pull Request
on:
pull_request:
types: [opened, synchronize, converted_to_draft, ready_for_review]
jobs:
test:
runs-on: ubuntu-latest
# Only run tests for PRs created by okoshi-f
if: github.event.pull_request.user.login == 'okoshi-f'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Run tests
run: node test/test-server.js
- name: Test MCP server functionality
run: |
echo "Testing random number generation..."
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": {"name": "generate_random_number", "arguments": {"min": 1, "max": 10}}}' | node dist/index.js
echo "Testing random string generation..."
echo '{"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "generate_random_string", "arguments": {"length": 8}}}' | node dist/index.js
echo "Testing error handling..."
echo '{"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {"name": "generate_random_number", "arguments": {"min": 10, "max": 1}}}' | node dist/index.js