name: Lint

on:
  push:
    branches: main
  pull_request:
    branches: '*'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Install node
      uses: actions/setup-node@v1
      with:
       node-version: '12.x'
    - name: Cache node modules
      uses: actions/cache@v3
      env:
        cache-name: cache-node-modules
      with:
        # npm cache files are stored in `~/.npm` on Linux/macOS
        path: ~/.npm
        key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
        restore-keys: |
          ${{ runner.os }}-build-${{ env.cache-name }}-
          ${{ runner.os }}-build-
          ${{ runner.os }}-
    - name: Install dependencies
      run: |
        cd pyscriptjs
        npm install
    - name: Run linter
      run: |
        cd pyscriptjs
        npm run lint
