name: CI

on: push

jobs:
  test:
    name: Node.js v${{ matrix.nodejs }} (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        nodejs: [10, 12]
        os: [ubuntu-latest]
    steps:
    - uses: actions/checkout@v1
      with:
        fetch-depth: 1

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

    - name: Install
      run: |
        npm install
        npm install -g nyc

    - name: Test w/ Coverage
      run: npx nyc npm test

    - name: Report
      if: matrix.nodejs >= 12
      run: |
        npx nyc report --reporter=text-lcov > coverage.lcov
        bash <(curl -s https://codecov.io/bash)
      env:
        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
