name: SDK

on:
  pull_request:
    paths:
      - "packages/sdk/**"
      - ".github/workflows/**"
  push:
    branches: [main, dev]

concurrency:
  group: ${{github.workflow}}-${{github.ref}}
  cancel-in-progress: true

defaults:
  run:
    working-directory: packages/sdk

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest

    steps:
      - name: Check out github repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 1

      - name: Use Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20.x
          cache: "yarn"

      - name: Install dependencies
        run: yarn --frozen-lockfile --network-concurrency 1

      - name: Run Build
        run: yarn build

      - name: Check types
        run: yarn check-types

  unit:
    name: Unit tests
    runs-on: ubuntu-latest
    steps:
      - name: Check out github repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 1

      - name: Use Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20.x
          cache: "yarn"

      - name: Install dependencies
        run: yarn install --frozen-lockfile

      - name: Run tests with coverage
        run: yarn test:cov
