on: [push, pull_request]

jobs:
  build:

    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v1
    - name: install dependencies
      run: |
        sudo apt-get update
        sudo apt-get install -y cmake pkg-config check libsubunit-dev cppcheck doxygen libsystemd-dev libcurl4-gnutls-dev libmicrohttpd-dev libjansson-dev gnutls-bin
    - name: cppcheck
      run: cppcheck --force --enable=warning,missingInclude --error-exitcode=1 .
    - name: dependencies
      run: |
        cd /opt
        git clone https://github.com/babelouest/orcania.git
        git clone https://github.com/babelouest/yder.git
        git clone https://github.com/babelouest/ulfius.git
        git clone https://github.com/babelouest/rhonabwy.git
        mkdir build
        cd build
        
        cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib ../orcania
        make
        sudo make install
        rm -rf *
        
        cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib ../yder
        make
        sudo make install
        rm -rf *
        
        cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib ../ulfius
        make
        sudo make install
        rm -rf *
        
        cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=lib ../rhonabwy
        make
        sudo make install
        rm -rf *
    - name: build
      run: |
        mkdir build
        cd build
        cmake -DBUILD_IDDAWC_TESTING=on ..
        ln -s ../test/cert/ .
        ./cert/create-cert.sh || (cat ../test/cert/certtool.log && false)
        make test package
        sudo make install
