name: CI

on:
  push:
    branches:
      - master
    tags:
      - v[0-9]+.[0-9]+.[0-9]+*
  pull_request:

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [windows-latest, macOS-latest, ubuntu-latest]
        node-version: [10.x, 12.x, 14.x]

    steps:
      - name: Fix git checkout line endings
        run: git config --global core.autocrlf input
      - uses: actions/checkout@v2
      - name: Setup Node.js
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
      - name: Get yarn cache
        id: yarn-cache
        run: echo "::set-output name=dir::$(yarn cache dir)"
      - uses: actions/cache@v1
        with:
          path: ${{ steps.yarn-cache.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }}
          restore-keys: |
            ${{ runner.os }}-yarn-
      - name: Install
        run: yarn
      - name: Lint
        run: yarn lint
      - name: Test
        run: yarn coverage
