name: Node.js CI

on:
  push:
    branches: [ main ]
  pull_request:

jobs:
  test:
    strategy:
      matrix:
        node-version: [12.x]
        os: [ubuntu-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node }}
      - id: yarn-cache
        run: echo "::set-output name=dir::$(yarn cache dir)"
      - uses: actions/cache@v2
        with:
          path: ${{ steps.yarn-cache.outputs.dir }}
          key: ${{ matrix.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ matrix.os }}-yarn-
      - run: yarn --frozen-lockfile
      - run: yarn build
      - run: yarn lint
      - run: yarn test