stages:
  - tests
  - tests_recompilation

tests_without_recompilation:
  stage: tests
  image: debian
  script:
  #Eclipse Prolog compilation of COLIBRI
   - ./compile_colibri.sh
  #Bundle in bundle directory
   - ./bundle.sh
  #Test
   - apt-get update
   - apt-get install -y parallel
   - ./test.sh -j2
  artifacts:
    paths:
     - logs
    expire_in: 1 week
  tags:
    - docker

tests_with_recompilation:
  stage: tests_recompilation
  image: ocaml/opam2
  script:
   - rm -f Src/COLIBRI/lib/v7/x86_64_linux/* Src/COLIBRI/simplex_ocaml.pl
  #OCaml dependencies
   - opam depext --install dune zarith num ocplib-simplex parsexp
  #OCaml compilation
   - (cd Src/COLIBRI/simplex_ocaml; ECLIPSEBIN=$(pwd)/../../../Bin dune build simplex_ocaml_mod_v7.so simplex_ocaml.pl)
  #Copy OCaml targets
   - (cd Src/COLIBRI/simplex_ocaml; cp _build/default/simplex_ocaml.pl ..)
   - (cd Src/COLIBRI/simplex_ocaml; cp _build/default/simplex_ocaml_mod_v7.so ../lib/v7/x86_64_linux/simplex_ocaml.so)
  #C++ compilation and targets copying
   - (cd Src/Floats; g++ -fPIC -O -D__LINUX__ -I ../../Bin/ECLIPSE_V7.0_45/include/x86_64_linux -shared EclipseInterfaceSimFloat2.2.cpp Floatcpp-3.0_SimFloat2.2.cpp -o ../COLIBRI/lib/v7/x86_64_linux/float_util.so)
  #Eclipse Prolog compilation of COLIBRI
   - ./compile_colibri.sh
  #Bundle in bundle directory
   - ./bundle.sh
  #Test
   - apt-get update
   - apt-get install -y parallel
   - ./test.sh -j2
  artifacts:
    paths:
     - logs
    expire_in: 1 week
  tags:
    - docker