name: Continuous Integration - Other

on: [push, pull_request]

jobs:
  build:
    name: ${{ matrix.config.name }}
    runs-on: ${{ matrix.config.os }}
    strategy:
      fail-fast: false
      matrix:
        config:
#        - {
#            name: "macOS",
#            os: macos-latest
#          }
        - {
            name: "Linux",
            os: ubuntu-latest
          }

    steps:
    - uses: actions/checkout@v1

    - name: Build
      run: |
        if [[ "${{ runner.os }}" == 'macOS' ]]; then
          make mac
        elif [[ "${{ runner.os }}" == 'Linux' ]]; then
          sudo apt-get update
          sudo apt install mesa-common-dev
          make linux
        fi

    - name: Test Files Presence
      run: |
        FILES=( \
          Build/Builder.exe \
          Build/libBuilderNative.so \
          Build/Plugins/AutomapMode.dll \
          Build/Plugins/BuilderEffects.dll \
          Build/Plugins/BuilderModes.dll \
          Build/Plugins/ColorPicker.dll \
          Build/Plugins/CommentsPanel.dll \
          Build/Plugins/NodesViewer.dll \
          Build/Plugins/SoundPropagationMode.dll \
          Build/Plugins/StairSectorBuilder.dll \
          Build/Plugins/TagExplorer.dll \
          Build/Plugins/TagRange.dll \
          Build/Plugins/ThreeDFloorMode.dll \
          Build/Plugins/VisplaneExplorer.dll \
        )
        for filename in "${FILES[@]}"; do
          if [ ! -f $filename ]; then
           echo "ERROR: File $filename is missing"
           exit 1
          fi
        done

    - name: Upload Package
      uses: actions/upload-artifact@v1
      with:
        path: Build
        name: "UDB_${{ matrix.config.name }}"
