name: CMake

on:
  push:
    branches: ["master"]
    tags: ["4.*"]
  pull_request:
    branches: ["master"]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

env:
  BUILD_TYPE: Release

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        os: [ 'ubuntu:22.04', 'ubuntu:24.04' ]

    runs-on: ubuntu-latest
    container: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v6

      - name: Install dependencies
        env:
          DEBIAN_FRONTEND: noninteractive
        uses: ./.github/workflows/actions/ubuntu-build-deps

      - name: Configure
        run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
      - name: Build
        run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

      - run: ./run_tests.sh
        working-directory: examples/
      - run: ./run_tests_conf.sh
        working-directory: examples/
