name: Build + test

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
  workflow_dispatch:

jobs:
  build-and-test:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        node-version: [18.x, 20.x]
        os: [macos-latest, ubuntu-latest, windows-latest]
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v4
        with:
          node-version: ${{ matrix.node-version }}
      - run: npm install -g npm@latest
      - run: bash ci/build-and-test.sh
        shell: bash
        env:
          CASE_BROKER_CI_TOKEN: ${{ secrets.PACTFLOW_TOKEN }}
          CASE_BROKER_BASEURL: https://timothyjones.pactflow.io/
          NODE_VERSION: ${{ matrix.node-version }}
          FORCE_COLOR: true
