name: Continuous Integration
on:
  # branches pushed by collaborators
  push:
    branches:
      - master
  # pull request from non-collaborators
  pull_request: {}
  # nightly
  # schedule:
  #   - cron:  '0 0 * * *'
jobs:
  test:
    name: "Test: ${{ matrix.os }}, node ${{ matrix.node }}"
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-20.04]
        # Don't forget to add all new flavors to this list!
        node: 
          - "12"
          - "14"
          - "15"
          - "16"
          - "17"
    steps:
      # checkout code
      - uses: actions/checkout@v2
      # install node
      - name: Use Node.js ${{ matrix.node }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node }}
      # Downgrade npm as necessary
      - run: |
          case "${{ matrix.node }}" in
            5|5.6.0)
              npm install -g npm@4;
              ;;
          esac
      - run: npm install
      - run: |
          case "${{ matrix.node }}" in
          4|5.6.0)
            ./node_modules/.bin/tap test/node-version-test.js;
            ;;
          *)
            npm run tap;
            ;;
          esac
          case "${{ matrix.node }}" in
          4|5.6.0|5|6|8)
            ;;
          *)
            npm run eslint;
            npm run bench;
            ;;
          esac
