name: build
on: [push, pull_request]
jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest]
        postgres: [15, 14, 13, 12, 11, 10]
        include:
        - os: macos-latest
          postgres: 14
    steps:
    - uses: actions/checkout@v3
    - uses: ankane/setup-postgres@v1
      with:
        postgres-version: ${{ matrix.postgres }}
        dev-files: true
    - if: ${{ startsWith(matrix.os, 'ubuntu') }}
      run: sudo apt-get update && sudo apt-get install libipc-run-perl
    - run: make
    - if: ${{ startsWith(matrix.os, 'ubuntu') }}
      run: |
        export PG_CONFIG=`which pg_config`
        sudo --preserve-env=PG_CONFIG make install
    - if: ${{ startsWith(matrix.os, 'macos') }}
      run: make install
    - run: make installcheck
    - if: ${{ failure() }}
      run: cat regression.diffs
    - if: ${{ startsWith(matrix.os, 'ubuntu') }}
      run: make prove_installcheck
    - if: ${{ startsWith(matrix.os, 'macos') }}
      run: |
        brew install cpanm && cpanm IPC::Run
        wget -q https://github.com/postgres/postgres/archive/refs/tags/REL_14_5.tar.gz
        tar xf REL_14_5.tar.gz
        make prove_installcheck PROVE=prove PROVE_FLAGS="-I ./postgres-REL_14_5/src/test/perl" PERL5LIB="/Users/runner/perl5/lib/perl5"
