name: Sanity Verification

on: [pull_request]

jobs:
  build-ubuntu:
    name: Build and Test Ubuntu Latest
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Init submodules
      run: git submodule update --init --recursive
    - name: Build the Ubuntu Latest Docker image
      run: docker build . --file .ci/Dockerfile.ubuntu --tag ubuntu_debugimage:latest
    - name: Run tests
      run: docker run ubuntu_debugimage:latest ctest /build --output-on-failure
  build-windows:
    name: Static Build and Test Windows MSVC
    runs-on: windows-latest
    steps:
    - uses: actions/checkout@v2
    - name: Init submodules
      run: git submodule update --init --recursive
    - uses: shogo82148/actions-setup-perl@v1
      with:
        perl-version: '5.30'
        distribution: strawberry
    - uses: microsoft/setup-msbuild@v1.0.2
      with:
        vs-version: '16.4'
    - name: Install Deps
      run: |
        choco install wget golang
        mkdir C:\yasm
        wget -q http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win64.exe -O C:\yasm\yasm.exe
    - name: Install Qt
      run: |
        wget -q https://download.qt.io/official_releases/online_installers/qt-unified-windows-x86-online.exe -O C:/qt-unified-windows-x86-online.exe
        C:/qt-unified-windows-x86-online.exe --script ./.ci/qt_installer_windows.qs -d
    - name: Build in Windows
      run: |
        mkdir build-static
        cd build-static
        setx GOROOT "c:\Go"
        setx path "%path%;C:\Qt\5.15.2\msvc2019_64\bin;C:\Go\bin;C:\yasm"
        set GOROOT="c:\Go"
        set PATH="%PATH%;C:\Qt\5.15.2\msvc2019_64\bin;C:\Go\bin;C:\yasm"
        cmake -DCMAKE_PREFIX_PATH="C:\Qt\5.15.2\msvc2019_64;C:\Go\bin;C:\yasm" -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug ..
        cmake --build . --config Debug
    - name: Run tests
      run: |
        cd build-static
        ctest -C Debug -E grpc --output-on-failure