name: CI

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main

jobs:
  test:
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        os:
          - ubuntu-latest
          - macOS-latest
        node_version:
          - 16
          - 18

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: ${{ matrix.node_version }}
          cache: 'yarn'

      # ensure the lockfile is in sync with the specified dependencies
      - run: yarn install --frozen-lockfile

      - run: yarn build

      - run: yarn lint
      - run: yarn test

      - run: yarn lerna exec 'yarn next build' --scope=example
