name: Github CI

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

jobs:
  main_matrix:
    name: Unix
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest]
        compiler: [gcc, clang]
        build_system: [makefile, mymake]
        hyper_use_rviz: [rviz_1, rviz_0]
        hyper_use_png: [png_1]
        hyper_use_glew: [glew_1]
    env:
      GH_OS: ${{ matrix.os }}
      GH_COMPILER: ${{ matrix.compiler }}
      GH_BUILDSYS: ${{ matrix.build_system }}
      GH_HYP_RVIZ: ${{ matrix.hyper_use_rviz }}
      GH_HYP_PNG: ${{ matrix.hyper_use_png }}
      GH_HYP_GLEW: ${{ matrix.hyper_use_glew }}
    steps:
    - uses: actions/checkout@v2
    - name: Install build dependencies
      run: .github/workflows/install_deps.sh
    - name: Build
      run: .github/workflows/build.sh
    - name: Do a simple test
      run: .github/workflows/test_simple.sh

  windows:
    name: Windows
    runs-on: windows-latest
    strategy:
      fail-fast: false
      matrix:
        compiler: [gcc]
        build_system: [makefile, mymake]
        hyper_use_rviz: [rviz_1, rviz_0]
        hyper_use_png: [png_1]
        hyper_use_glew: [glew_1]
    env:
      GH_OS: windows-latest
      GH_COMPILER: ${{ matrix.compiler }}
      GH_BUILDSYS: ${{ matrix.build_system }}
      GH_HYP_RVIZ: ${{ matrix.hyper_use_rviz }}
      GH_HYP_PNG: ${{ matrix.hyper_use_png }}
      GH_HYP_GLEW: ${{ matrix.hyper_use_glew }}
    defaults:
      run:
        shell: msys2 {0}
    steps:
    - uses: msys2/setup-msys2@v2
      with:
        update: true
        install: 'pactoys'
    - uses: actions/checkout@v2
    - name: Install build dependencies
      env:
        MSYSTEM: MSYS
      run: .github/workflows/install_deps.sh
    - name: Build
      run: .github/workflows/build.sh
    - name: Do a simple test
      run: .github/workflows/test_simple.sh

  emscripten:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Build
      run: |
        docker run --rm -v $(pwd):/src trzeci/emscripten make emscripten
    - name: Do a simple test
      run: |
        ls -lAF hyper.html hyper.js hyper.wasm