# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on: [push, pull_request]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  build-linux:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
      
      # Runs a single command using the runners shell
      - name: Install dependencies
        run: |
          sudo apt-get update
          sudo apt-get install qt5-default libqt5websockets5-dev g++ make

      # Runs a set of commands using the runners shell
      - name: qmake and build
        run: |
          cd $GITHUB_WORKSPACE
          qmake
          make
          mv bin/config_sample bin/config

      - name: Run tests
        run: |
            for test in bin_tests/*; do
              LD_LIBRARY_PATH=./bin:$LD_LIBRARY_PATH ./$test
            done;
          
      - name: Upload binary
        uses: actions/upload-artifact@v2
        with:
          name: akashi-linux
          path: bin/
  
  build-windows:
    runs-on: windows-latest
    
    steps:
      - uses: actions/checkout@v2
      - uses: ilammy/msvc-dev-cmd@v1
      
      - name: Install Qt
        uses: jurplel/install-qt-action@v2
     
      - name: Build
        run: |
          cd $Env:GITHUB_WORKSPACE
          qmake "CONFIG += qtquickcompiler" akashi.pro
          nmake
          windeployqt bin\akashi.exe --release --no-opengl-sw
          mv bin\config_sample bin\config

      - name: Run tests
        run: |
          for test in bin_tests/*; do
            LD_LIBRARY_PATH=./bin:$LD_LIBRARY_PATH ./$test
          done;
        shell: bash
          
      - name: Upload zip
        uses: actions/upload-artifact@v2
        with:
          name: akashi-windows
          path: bin\