name: Mosquitto - Build variants

on:
  push:
    branches:
      - master
      - develop
      - fixes
      - release/*
  pull_request:
    branches:
      - master
      - develop
      - fixes
      - release/*

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Install third party dependencies
      run: |
        sudo apt-get update
        sudo apt-get install -y \
          ccache \
          cmake \
          docbook-xsl \
          libargon2-dev \
          libc-ares-dev \
          libcjson-dev \
          libcunit1-dev \
          libedit-dev \
          libgmock-dev \
          libmicrohttpd-dev \
          libssl-dev \
          libsystemd-dev \
          libwrap0-dev \
          python3-all \
          uthash-dev \
          xsltproc

    - name: Configure ccache
      run: |
        mkdir "$GITHUB_WORKSPACE/ccache"
        echo "CCACHE_DIR=$GITHUB_WORKSPACE/ccache" >> $GITHUB_ENV

    - name: Restore ccache
      uses: actions/cache@v5
      with:
        path: ccache
        key: ${{ runner.os }}-build-variants-ccache

    - uses: actions/checkout@v6
      with:
        submodules: 'true'

    - name: build
      run: ./buildtest.py

    - name: Report ccache stats
      run: ccache -s
