name: Ubuntu CI
on:
  pull_request:
  push:
  schedule:
    - cron: 0 0 * * 0
  workflow_dispatch:
jobs:
  build:
    if: "!contains(github.event.head_commit.message, '[skip ubuntu ci]')"
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

      - name: Install dependencies
        run: |-
          sudo apt-get update --assume-yes
          sudo apt-get install --assume-yes --no-install-recommends \
            clang \
            g++ \
            gettext \
            git \
            libargon2-dev \
            libgnutls28-dev \
            libldap2-dev \
            libmysqlclient-dev \
            libpcre2-dev \
            libsqlite3-dev \
            libssl-dev \
            libtre-dev \
            ninja-build

      - name: Enable extras
        run: |-
          for MODULE in enc_argon2 enc_posix ldap mysql regex_pcre2 regex_posix regex_tre sqlite ssl_gnutls ssl_openssl
          do
            ln -s ${{ github.workspace }}/modules/extra/$MODULE.cpp ${{ github.workspace }}/modules
          done

      - name: Run CMake
        env:
          CC: ${{ matrix.compiler.cc }}
          CXX: ${{ matrix.compiler.cxx }}
          CXXFLAGS: -Werror
        run: |-
          cmake -B "build" \
                -D "CMAKE_BUILD_TYPE=Debug" \
                -D "INSTDIR=${{ github.workspace }}/run" \
                -G "Ninja" \
                -Wdeprecated \
                -Wdev

      - name: Build and install
        env:
          VERBOSE: ${{ runner.debug }}
        run: |-
          ninja -C "build" ${{ runner.debug == '1' && '-v' || '' }} install

    strategy:
      fail-fast: false
      matrix:
        compiler:
          - cc: clang
            cxx: clang++
          - cc: gcc
            cxx: g++
