name: smock - lint, build, test

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

jobs:
  build-test-lint:
    name: Run job on ${{matrix.node}}
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node: [ '10', '12', '14' ]

    steps:
      - uses: actions/checkout@v2

      - name: Setup node ${{ matrix.node }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node }}

      # START DEPENDENCY CACHING
      - name: Cache root deps
        uses: actions/cache@v1
        id: cache_base
        with:
          path: node_modules
          key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('package.json') }}

      # END DEPENDENCY CACHING

      - name: Install Dependencies
        run: yarn install

      - name: Lint
        run: yarn lint

      - name: Build
        run: |
          yarn clean
          yarn build

      - name: Test
        run: yarn test
