name: Test and Build
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, 22]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run type checking
run: npm run typecheck
- name: Run linter
run: npm run lint || echo "No lint script configured"
- name: Build package
run: npm run build
- name: Run tests
run: npm test || echo "No tests configured yet"
- name: Test stdio mode
run: |
timeout 2s npm start || true
echo "stdio mode starts successfully"
- name: Test HTTP mode
run: |
HN_MCP_HTTP=true timeout 2s npm start &
sleep 1
curl -s http://localhost:3000/health || echo "Health check endpoint not implemented"
pkill -f "node dist/index.js" || true
build-docker:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check if Dockerfile exists
id: check_dockerfile
run: |
if [ -f "Dockerfile" ]; then
echo "dockerfile_exists=true" >> $GITHUB_OUTPUT
else
echo "dockerfile_exists=false" >> $GITHUB_OUTPUT
echo "Dockerfile not found, skipping Docker build"
fi
- name: Build Docker image
if: steps.check_dockerfile.outputs.dockerfile_exists == 'true'
run: docker build -t hn-mcp:test .
- name: Test Docker container
if: steps.check_dockerfile.outputs.dockerfile_exists == 'true'
run: |
docker run --rm hn-mcp:test --help || true