name: Minimal

on:
  pull_request:
    branches:
      - master

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

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        platform: ['x86_64', 'x86', 'armhf', 'armv7', 'aarch64', 'ppc64le', 'riscv64']
        branch: ['v3.21', 'v3.22', 'edge']
    
    name: Minimal ${{matrix.platform}}${{matrix.branch != 'v3.22' && format(' - {0}', matrix.branch) || format('')}}
    defaults:
      run:
        shell: alpine.sh {0}
    steps:
      - uses: actions/checkout@v5
      - uses: jirutka/setup-alpine@v1
        with:
          branch: ${{matrix.branch}}
          arch: ${{matrix.platform}}
          packages: >
            build-base
            cmake
            duktape-dev
            fmt-dev
            git
            gtest-dev
            libupnp-dev
            ninja
            pkgconf
            pugixml-dev
            jsoncpp-dev
            spdlog-dev
            sqlite-dev
            icu-dev
            util-linux-dev
            zlib-dev

      - name: Build
        run: |
          cmake -S . -B build -G Ninja --preset=minimal
          cmake --build build -j$(nproc) --verbose

      - name: Test
        run: |
          cd build
          ctest --output-on-failure
