# This is a composition of lint and test scripts
# Make sure to update this file along with the others

name: Tests

# Run this job on all pushes and pull requests
# as well as tags with a semantic version
on:
  push:
    branches:
      - "*"
    tags:
      # normal versions
      - "v?[0-9]+.[0-9]+.[0-9]+"
      # pre-releases
      - "v?[0-9]+.[0-9]+.[0-9]+-**"
  pull_request: {}

jobs:
  # Performs quick checks before the expensive test runs
  check-and-lint:
    if: contains(github.event.head_commit.message, '[skip ci]') == false

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [18]

    steps:
      - uses: actions/checkout@v1
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v2.2.0
        with:
          node-version: ${{ matrix.node-version }}

      - name: Install Dependencies
        run: npm install

  # Runs library tests on all supported node versions and OSes
  lib-tests:
    if: contains(github.event.head_commit.message, '[skip ci]') == false

    needs: [check-and-lint]

    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        node-version: [18, 20, 22]
        os: [ubuntu-latest, windows-latest, macos-latest]

    steps:
      - uses: actions/checkout@v1
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v2.2.0
        with:
          node-version: ${{ matrix.node-version }}

      - name: Install Dependencies
        run: npm install

      - name: Run local tests
        run: npm test
