name: CI

on: [push, pull_request]

jobs:
  test-coverage:
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        os:
          - ubuntu-latest
        node_version:
          - 10
          - 12
          - 14
          - 16

    name: Node ${{ matrix.node_version }} on ${{ matrix.os }}

    steps:
      - name: Checkout repo
        uses: actions/checkout@v2

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

      - name: Install yarn
        run: npm install -g yarn

      - name: Install dependencies
        run: yarn --frozen-lockfile

      - name: Run tests
        run: yarn test-coverage

      - name: Uninstall yarn
        if: always()
        run: npm uninstall -g yarn