name: API Tests
on:
  pull_request:
    branches: [main]
    paths:
      - "api/**"

  push:
    branches: [main]
    paths:
      - "api/**"

jobs:
  metadata:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: api/metadata

    steps:
      - name: checkout
        uses: actions/checkout@v4

      - uses: oven-sh/setup-bun@v2
        with:
          bun-version: latest

      - name: Install
        run: bun install

      - name: Run lints
        run: bun run ci:lint

      - name: Run tests
        run: bun run coverage

  cdn:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: api/cdn

    steps:
      - uses: actions/checkout@v3

      - uses: oven-sh/setup-bun@v2
        with:
          bun-version: latest

      - name: Install
        run: bun install

      - name: Run lints
        run: bun run ci:lint

      ## - name: Run tests
      ##  run: bun run coverage

  upload:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: api/upload

    steps:
      - uses: actions/checkout@v3

      - uses: oven-sh/setup-bun@v2
        with:
          bun-version: latest

      - name: Install
        run: bun install

      - name: Run lints
        run: bun run ci:lint

      - name: Run tests
        run: bun run coverage

  download:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: api/download

    steps:
      - uses: actions/checkout@v3

      - uses: oven-sh/setup-bun@v2
        with:
          bun-version: latest

      - name: Install
        run: bun install

      - name: Run lints
        run: bun run ci:lint
