language: node_js
node_js: 20
version: ~> 1.0

before_install:
  - |-
    case $TRAVIS_OS_NAME in
      windows)
        powershell -Command Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe
        choco install -y --force nodejs-lts
        # force refresh path
        export PATH=$(cmd.exe //c "refreshenv > nul & C:\Progra~1\Git\bin\bash -c 'echo \$PATH' ")
        ;;
      linux)
        curl -Os https://uploader.codecov.io/latest/linux/codecov
        chmod +x codecov
        ls -lrt
        ;;
    esac

env:
  global: RUN_LONG_TEST=1 CLEAR_TEXT=0 DB=testn

import: mariadb-corporation/connector-test-machine:common-build.yml@master

jobs:
  include:
    - stage: Language
      env: srv=mariadb v=10.11 local=1 packet=8
      name: "CS 10.11 - node.js 16"
      node_js: 16
    - stage: Language
      env: srv=mariadb v=10.11 local=1 packet=40 CLEAR_TEXT=1
      node_js: 18
      name: "CS 10.11 - node.js 18"
    - stage: Language
      env: srv=mariadb v=10.11 local=1 DISABLE_SSL=1
      name: "CS 10.11 - node.js 20"
      node_js: 20
    - stage: Language
      env: srv=mariadb v=10.11 local=1
      name: "CS 10.11 - node.js 22"
      node_js: 22
    - stage: Benchmarks
      env: srv=mariadb v=10.11 BENCH=1 local=1
      name: "Benchmarks"

script:
  - npm install
  - npm install nyc -g
  - |-
    case $TRAVIS_OS_NAME in
      windows)
        npm run coverage:test
        ;;
      linux)
        npm run test:lint
        if [ -n "$BENCH" ] ; then
          npm install promise-mysql mysql2
          npm install microtime
          npm run benchmark
        else
          npm run coverage:test
        fi
        ;;
    esac

after_success:
  - if [ -z "$BENCH" ] ; then npm run coverage:report; fi
