name: Unit tests

on:
  push:
    branches:
      - next
  pull_request:
    types: [opened, reopened, labeled, synchronize]

jobs:
  build:
    name: Core Unit Tests node-${{ matrix.node_version }}, ${{ matrix.os }}
    if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'ci:matrix')
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest]
        node_version: [12, 14, 16]
        include:
          - os: macos-latest
            node_version: 16
          - os: windows-latest
            node_version: 16
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v2
      - name: Set node version to ${{ matrix.node_version }}
        uses: actions/setup-node@v2
        with:
          node-version: ${{ matrix.node_version }}
          cache: yarn
      - name: install, bootstrap
        run: |
          cd code
          yarn install --immutable
          yarn bootstrap --core
      - name: test
        run: |
          cd code
          yarn test --runInBand --ci
