name: 🔎 Tests
on:
  push:
    branches: [ master, develop, next/* ]
  pull_request:
    branches: [ master, develop, next/* ]
jobs:
  ubuntu_build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        # since last mocha version is compatible for node 12.0.0+ we remove 10.x matrix
        # Only LTS major version
        node-version: ['12', '14', '16', 'lts/*'] 
    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}
    - name: Cache node modules
      uses: actions/cache@v2
      id: cache
      with:
        path: node_modules
        key: ${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('yarn.lock') }}
    - name: Install package
      if: steps.cache.outputs.cache-hit != 'true'
      run: npm install -g yarn && yarn install
    - name: Build TS
      run: yarn build
    - name: Test package and Code coverage
      run: yarn test
