name: Bob the Builder

# Run on all branches, including all pull requests, except the 'dev'
# branch since that's where we run Coverity Scan (limited tokens/day)
on:
  push:
    branches:
      - '**'
      - '!dev'
  pull_request:
    branches:
      - '**'

jobs:
  build:
    # Verify we can build on latest Ubuntu with both gcc and clang
    name: ${{ matrix.compiler }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        compiler: [gcc, clang]
      fail-fast: false
    env:
      MAKEFLAGS: -j3
      CC: ${{ matrix.compiler }}
    steps:
      - name: Install dependencies
        run: |
          sudo apt-get -y update
          sudo apt-get -y install tree libconfuse-dev libssl-dev zlib1g-dev php-cgi
      - uses: actions/checkout@v6
      - name: Create configure script
        run: |
          ./autogen.sh
      - name: Build w/o HTTPS
        run: |
          ./configure --prefix=/ --without-ssl --enable-htaccess --enable-htpasswd
          make V=1
      - name: Build w/ HTTPS
        run: |
          make clean
          ./configure --prefix=/ --enable-htaccess --enable-htpasswd
          make V=1
      - name: Install to ~/tmp and Inspect
        run: |
          DESTDIR=~/tmp make install-strip
          tree ~/tmp
          ldd ~/tmp/sbin/merecat
          size ~/tmp/sbin/merecat
          ~/tmp/sbin/merecat -h
      - name: Run tests
        run: |
          # Tests must currently not run in parallel
          make -j1 check || (cat tests/test-suite.log; false)
