name: Build for Linux (Trixie, pre-compiled libwlroots-dev)

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build_matrix:
    strategy:
      matrix:
        compiler: [ "gcc", "clang" ]
    runs-on: ubuntu-latest
    container:
      image: debian:trixie

    steps:
    - name: Install package dependencies.
      run: |
        apt-get update
        apt-get install -y \
          bison \
          clang \
          cmake \
          flex \
          gcc \
          git \
          libcairo2-dev \
          libncurses-dev \
          libwlroots-dev \
          pkg-config \
          plantuml \
          xwayland

    - name: Checkout code, including git submodules.
      uses: actions/checkout@v3
      with:
        # Not using 'recursive' prevents fetching extra submodules below
        # dependencies/. These are only needed to build wlroots from source.
        submodules: true

    - name: Configure wlmaker through CMake.
      run: |
        export CC="${{ matrix.compiler }}"
        cmake -B build/

    - name: Build wlmaker.
      run: |
        export CC="${{ matrix.compiler }}"
        cmake --build build/

    - name: Run all tests.
      run: |
        ctest --test-dir build/ --build-run-dir build/ -V

  generate_doc:
    runs-on: ubuntu-latest
    container:
      image: debian:trixie

    steps:
    - name: Install package dependencies.
      run: |
        apt-get update
        apt-get install -y \
          bison \
          clang \
          cmake \
          doxygen \
          flex \
          gcc \
          git \
          libcairo2-dev \
          libncurses-dev \
          libwlroots-dev \
          pkg-config \
          plantuml \
          xwayland

    - name: Checkout code, including git submodules.
      uses: actions/checkout@v3
      with:
        submodules: true

    - name: Configure wlmaker through CMake, with doxygen.
      run: |
        cmake -Dconfig_DOXYGEN_CRITICAL=ON -B build/

    - name: Build documentation.
      run: cmake --build build/ --target doc