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']
    name: Minimal ${{matrix.platform}}
    defaults:
      run:
        shell: alpine.sh {0}
    steps:
      - uses: actions/checkout@v4
      - 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
            spdlog-dev
            sqlite-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
