name: Build Test

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:

  build-dub-ubuntu:
    name: Dub
    runs-on: ubuntu-latest
    strategy:
        matrix:
          dc: [dmd-latest, ldc-latest]
    steps:
    - uses: actions/checkout@v2

    - name: Install System Dependencies
      run: |
        sudo apt-get update -qq
        sudo apt-get install -yq \
                dh-dlang \
                libatk1.0-dev \
                libcairo2-dev \
                libglib2.0-dev \
                libgtk-3-dev \
                libpango1.0-dev \
                librsvg2-dev \
                libsecret-1-dev \
                libunwind-dev \
                libgtksourceview-3.0-dev \
                libpeas-dev \
                libvte-2.91-dev

    - name: Install D compiler
      uses: dlang-community/setup-dlang@v1
      with:
        compiler: ${{ matrix.dc }}

    - name: Build
      run: dub build --compiler=$DC

    - name: Test
      run: dub test --compiler=$DC


  build-debian-testing:
    name: Debian Testing
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

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

    - name: Build
      run: podman run -t -e COMPILER_VENDOR=$CVENDOR -e CC=gcc -e CXX=g++ -v `pwd`:/build tilix
           ./.github/ci/run-build.sh

    - name: Test
      run: podman run -t -e COMPILER_VENDOR=$CVENDOR -e CC=gcc -e CXX=g++ -v `pwd`:/build tilix
           ./.github/ci/run-tests.sh


  build-ubuntu:
    name: Ubuntu LTS
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Create Build Environment
      run: cd .github/ci/ && podman build -t tilix -f ./Dockerfile-ubuntu-jammy .

    - name: Build
      run: podman run -t -e COMPILER_VENDOR=$CVENDOR -e CC=gcc -e CXX=g++ -v `pwd`:/build tilix
           ./.github/ci/run-build.sh

    - name: Test
      run: podman run -t -e COMPILER_VENDOR=$CVENDOR -e CC=gcc -e CXX=g++ -v `pwd`:/build tilix
           ./.github/ci/run-tests.sh
