---
name: Build
on: [pull_request]

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        os: [macos-latest, ubuntu-18.04]
        compiler: [gcc, clang]
        nginx:
          # Mainline
          - 1.23.3
          # Stable.
          - 1.22.1
          # First version with loadable module support.
          - 1.9.15
          # Oldest supported version.
          - 0.8.55
        dynamic: [0, 1]
        exclude:
          - nginx: 0.8.55
            dynamic: 1
          - nginx: 0.8.55
            os: macos-latest
          - compiler: gcc
            os: macos-latest
    runs-on: ${{ matrix.os }}
    env:
      CFLAGS: "-Wno-error"
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Install Packages
        run: |
          case $RUNNER_OS in
            Linux )
              sudo apt update
              sudo apt install -y libpcre3-dev libssl-dev
              ;;
            * )
              ;;
          esac
          t/get-pup || echo 'Tests needing pup will be skipped'
      - name: Test
        env:
          CC: ${{ matrix.compiler }}
        run: t/build-and-run ${{ matrix.nginx }} ${{ matrix.dynamic }}
