name: Test
on: [push, pull_request]

jobs:
  test:
    name: Test Node.JS
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node: [10, 12, 14, 15]
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node }}
      - name: Install
        run: yarn install
      - name: Test
        run: yarn test

  coverage:
    name: Coverage Report
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
      - name: Install
        run: |
          yarn install
          yarn global add codeclimate-test-reporter
          echo "$(yarn global bin)" >> $GITHUB_PATH
      - name: Test
        run: yarn test --coverage
      - name: Coverage Report
        env:
          CODECLIMATE_REPO_TOKEN: ${{ secrets.CODECLIMATE_REPO_TOKEN }}
        run: codeclimate-test-reporter < coverage/lcov.info
