build:ubuntu_cpp:
  stage: build
  tags:
    - docker
  image: n2d2-ci/ubuntu20.04/cpu:latest

  script:
    - INSTALL_PATH="$CI_PROJECT_DIR/install_cpp"
    - mkdir -p $INSTALL_PATH
    - mkdir -p build_cpp

    # Clone and compile dependencies
    - MODULE_NAME="aidge_core"
    - BASE_URL=`echo $CI_REPOSITORY_URL | sed "s;\/*$CI_PROJECT_PATH.*;;"`
    - REPO_URL="$BASE_URL/aidge/$MODULE_NAME.git"
    - git clone $REPO_URL $MODULE_NAME
    - mkdir -p $MODULE_NAME/build
    - cd $MODULE_NAME/build
    - cmake -DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON ..
    
    - cd ../..
    
    # Build current module
    - cd build_cpp
    - cmake -DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_PATH -DCMAKE_BUILD_TYPE=Debug -DWERROR=ON ..
    - make -j4 all install

  artifacts:
    paths:
      - build_cpp/
      - install_cpp/

build:ubuntu_python:
  stage: build
  tags:
    - docker
  image: n2d2-ci/ubuntu20.04/cpu:latest

  script:
    - export AIDGE_INSTALL=`pwd`/install

    # Create virtaul env
    - python3 -m pip install virtualenv
    - virtualenv venv
    - source venv/bin/activate

    # Clone dependencies
    - MODULE_NAME="aidge_core"
    - BASE_URL=`echo $CI_REPOSITORY_URL | sed "s;\/*$CI_PROJECT_PATH.*;;"`
    - REPO_URL="$BASE_URL/aidge/$MODULE_NAME.git"
    - git clone $REPO_URL $MODULE_NAME

    # Pip install dependancy
    - cd $MODULE_NAME
    - python3 -m pip install . -v

    - cd ..
    - python3 -m pip install . -v
  artifacts:
    paths:
      - venv/