name: js

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-npm: [{node: '18.x', npm: '9.x'}, {node: '20.x', npm: '10.x'}]

    steps:
    - uses: actions/checkout@v4
    - name: Use Node.js ${{ matrix.node-npm.node }}
      uses: actions/setup-node@v3
      with:
        node-version: ${{ matrix.node-npm.node }}
    - name: install latest npm
      run: |
        npm install -g npm@${{ matrix.node-npm.npm }} &&
        npm --version &&
        npm list -g --depth 0
    - run: npm install
    - run: npm run build --if-present
    - run: npm test
      env:
        CI: true
    - name: Archive production artifacts
      uses: actions/upload-artifact@v3
      with:
        name: ncmb_min_js
        path: ncmb.min.js
