name: Node-CI

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [10.x, 12.x, 14.x, 16.x]

    steps:
      - uses: actions/checkout@v1

      - name: Cache Node Modules
        uses: actions/cache@v1
        id: cache
        with:
          path: node_modules
          key: ${{ runner.OS }}-node-modules-${{ hashFiles('**/package-lock.json') }}

      - name: Install NPM
        if: steps.cache.outputs.cache-hit != 'true'
        run: npm ci

      - name: Build
        run: npm run build
        env:
          CI: true

      - name: Test
        run: npm test
        env:
          CI: true
