name: GoodGo MCP Server CI

on:
  push:
    paths:
      - 'services/goodgo-mcp-server/**'
  pull_request:
    paths:
      - 'services/goodgo-mcp-server/**'

permissions:
  contents: read

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '22'

      - name: Install pnpm
        uses: pnpm/action-setup@v4
        with:
          version: 8

      - name: Install dependencies
        working-directory: services/goodgo-mcp-server
        run: pnpm install

      - name: Build
        working-directory: services/goodgo-mcp-server
        run: pnpm build

      - name: Run tests with coverage
        working-directory: services/goodgo-mcp-server
        run: pnpm test:coverage

      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v4
        with:
          files: services/goodgo-mcp-server/coverage/cobertura-coverage.xml
          flags: goodgo_mcp_server
          fail_ci_if_error: false
        env:
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
