name: Build Test

on: [push, pull_request]

jobs:
  build-debian-testing:
    name: Debian Testing
    runs-on: ubuntu-latest
    strategy:
      matrix:
        dc: [ldc, gdc]

    steps:
    - uses: actions/checkout@v3

    - name: Create Build Environment
      run: cd tests/ci/ && podman build -t asgen -f ./Dockerfile-debian-testing .

    - name: Build & Test
      continue-on-error: ${{ matrix.dc == 'gdc' }}
      run: podman run -a stdout -a stderr -e DC=${{ matrix.dc }} -v `pwd`:/build asgen
           ./tests/ci/build-and-test.sh


  build-debian-stable:
    name: Debian Stable
    runs-on: ubuntu-latest
    strategy:
      matrix:
        dc: [ldc]

    steps:
    - uses: actions/checkout@v3

    - name: Create Build Environment
      run: cd tests/ci/ && podman build -t asgen -f ./Dockerfile-debian-stable .

    - name: Build & Test
      continue-on-error: ${{ matrix.dc == 'gdc' }}
      run: podman run -a stdout -a stderr -e DC=${{ matrix.dc }} -v `pwd`:/build asgen
           ./tests/ci/build-and-test.sh


  build-fedora-latest:
    name: Fedora Latest
    runs-on: ubuntu-latest
    strategy:
      matrix:
        dc: [ldc, gdc]

    steps:
    - uses: actions/checkout@v3

    - name: Create Build Environment
      run: cd tests/ci/ && podman build -t asgen -f ./Dockerfile-fedora-latest .

    - name: Build & Test
      continue-on-error: ${{ matrix.dc == 'gdc' }}
      run: podman run -a stdout -a stderr -e DC=${{ matrix.dc }} -v `pwd`:/build asgen
           ./tests/ci/build-and-test.sh


  build-ubuntu-lts:
    name: Ubuntu LTS
    runs-on: ubuntu-22.04
    steps:
    - uses: actions/checkout@v3

    - name: Create Build Environment
      run: sudo ./tests/ci/install-deps-deb.sh

    - name: Update Meson
      run: sudo pip3 install 'meson~=0.62'

    - name: Make & Install 3rd-party
      run: sudo ./tests/ci/ci-install-extern.sh

    - name: Build & Test
      run: DC=ldc2 ./tests/ci/build-and-test.sh
