name: Bedrock Node.js CI

on: [push]

jobs:
  lint:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [14.x]
    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: npm install
    - name: Run eslint
      run: npm run lint
  test-node:
    runs-on: ubuntu-latest
    needs: [lint]
    strategy:
      matrix:
        node-version: [14.x]
    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: |
        npm install
        cd test
        npm install
    - name: Run test with Node.js ${{ matrix.node-version }}
      run: |
        cd test
        npm test
      env:
        CI: true
  coverage:
    needs: [test-node]
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [10.x, 12.x, 14.x]
    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: |
        npm install
        cd test
        npm install
    - name: Generate coverage report
      run: |
        cd test
        npm run coverage-ci
      env:
        CI: true
    - name: Upload coverage to Codecov
      uses: codecov/codecov-action@v1
      with:
        file: ./test/coverage/lcov.info
        fail_ci_if_error: true
