name: Tests and build

on:
  pull_request:
    branches:
      - master

jobs:
  lint:
    name: Check code base before merge to master
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Read .nvmrc
        run: echo ::set-output name=NVMRC::$(cat .nvmrc)
        id: nvm

      - name: Set up Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '${{ steps.nvm.outputs.NVMRC }}'

      - name: Set up yarn
        run: npm install --global yarn

      - name: Set up dependencies
        run: yarn

      - name: Run lint
        run: yarn lint

      - name: Run tests
        run: yarn test:unit

      - name: Compile lib
        run: yarn compile

      - name: Build bundle
        run: yarn build
