name: Test & Build

on: [pull_request]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: ./.github/actions/install

      - name: Test with Coverage
        run: pnpm run coverage

      - name: ESLint
        run: pnpm run lint

      - name: Report Coverage
        uses: coverallsapp/github-action@v2
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}

  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: ./.github/actions/install

      - name: Build Dist
        run: pnpm run build

      - name: Bundlewatch
        run: npx bundlewatch

      - name: Build Docs
        run: pnpm run build:docs
