name: compile_oldgcc

on: [push]

env:
  BUILD_TYPE: Release

jobs:
  compile_oldgcc:
    runs-on: ubuntu-16.04

    steps:
    - name: Checkout_git
      uses: actions/checkout@v2
      with:
        # We must fetch at least the immediate parents so that if this is
        # a pull request then we can checkout the head.
        fetch-depth: 15
    - name: install_packages
      run: |
           wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
           sudo apt-add-repository -y 'deb https://apt.kitware.com/ubuntu/ xenial main'
           sudo apt-get update
           sudo apt-get install graphviz gnuplot gnuplot-x11 libwxgtk3.0-dev maxima maxima-share ninja-build netcat-openbsd xvfb cmake appstream-util desktop-file-utils
    - name: configure
      run: |
           export CC=gcc-5
           export CXX=g++-5
           export CXXFLAGS="-Wall -Wextra -ansi -std=c++11"
           export LANG=en_US.UTF-8
           mkdir build
           touch build build/build.ninja
           cd build
           cmake -G "Ninja" -DCMAKE_UNITY_BUILD=YES -DCMAKE_BUILD_TYPE=debug -DCMAKE_UNITY_BUILD_BATCH_SIZE=8 -DWXM_UNIT_TESTS=YES ..
           cd ..
    - name: compile
      run: |
           cd build
           cmake --build .
           cd ..
    - name: update-locale
      run: |
           cd build
           cmake --build . --target update-locale
           cd ..
    - name: run_tests
      run: |
           cd build
           export CTEST_OUTPUT_ON_FAILURE=1
           export LD_PRELOAD=$(gcc -print-file-name=libSegFault.so)
           xvfb-run -a ctest -j 3 -E ImgCell;    
           cd ..
