# Checks that `make dist` works and builds the project with the default
# configuration.

name: Build

# Note: Keep this list in sync with DISTFILES in ../../Makefile.
on:
  workflow_dispatch:
  push:
    branches-ignore:
      - 'dependabot/**'
    paths:
      - 'contrib/**'
      - 'etc/**'
      - 'm4/**'
      - 'platform/**'
      - 'src/**'
      - 'test/**'
      - .github/workflows/build.yml
      - COPYING
      - Makefile
      - README
      - RELNOTES
      - ci/printenv.sh
      - config.mk.in
      - config.sh.in
      - configure
      - configure.ac
      - install.sh
      - mkdeb.sh
      - mketc.sh
  pull_request:
    paths:
      - 'contrib/**'
      - 'etc/**'
      - 'm4/**'
      - 'platform/**'
      - 'src/**'
      - 'test/**'
      - .github/workflows/build.yml
      - COPYING
      - Makefile
      - README
      - RELNOTES
      - ci/printenv.sh
      - config.mk.in
      - config.sh.in
      - configure
      - configure.ac
      - install.sh
      - mkdeb.sh
      - mketc.sh

permissions:  # added using https://github.com/step-security/secure-workflows
  contents: read

jobs:
  build:
    runs-on: ubuntu-22.04
    timeout-minutes: 10
    steps:
    - name: Harden Runner
      uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9
      with:
        egress-policy: block
        allowed-endpoints: >
          github.com:443
    - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
    - name: print env
      run: ./ci/printenv.sh
    - name: configure
      run: >
        ./configure
        --prefix=/usr --enable-fatal-warnings
        --disable-apparmor --disable-selinux
        || (cat config.log; exit 1)
    - name: make
      run: make -j "$(nproc)"
    - name: make install
      run: sudo make install
    - name: make installcheck
      run: make installcheck
