image: registry.forge.ird.fr/diade/culebront_pipeline/podman/gitlab-runner:0.0.1 # docker image used
####################
# TAG stages: we define 3 test steps called install, test, deploy
stages:
  - install
  - test
#variables:
#  CI_DEBUG_TRACE: "true"

####################
# TAG before_script : we list all the commands required before running any test. eg.: clone repo, install soft
# at each stage is launched
before_script:
  - echo ${CI_PROJECT_DIR}
  - export PATH=$PATH:/root/.local/bin # ajouter les binaires dans le home
  - export APPTAINER_BINDPATH="${CI_PROJECT_DIR}:${CI_PROJECT_DIR},/root:/root" # bin automatique de l'aptainer pour ne pas avoir a le mettre dans SMK
  #- python3 -m pip install -U snakemake setuptools build pip
  #- python3 -m pip install snakecdysis@git+https://forge.ird.fr/phim/sravel/snakecdysis.git@main
  - python3 -m pip install --user RNAja@git+https://forge.ird.fr/phim/rnaja-pipeline.git@$CI_COMMIT_REF_NAME
  - RNAja --install_env
  #- bash -ec 'CPDIR="/root/.local/lib/python3.10/site-packages/culebrONT/containers"; DIR="/usr/local/culebrONT/Containers"; if [[ -d $DIR ]]; then ls $DIR;  echo "copy Containers files in $DIR to $CPDIR"; ln -sf $DIR/* $CPDIR; fi'
  - RNAja install_local

####### COMMON (Install) #######
RNAja:installing:
  stage: install                       # Put the name of stage defined previously
  script:                              # shell commands executed by the runner
    - RNAja --install_env
  tags:
    - VM
  rules:                               # Condition if the test is run or not
    - if: $CI_COMMIT_TAG =~ "/^v.*rc/" # Tests ran if commit message start with v.
    - if: $CI_COMMIT_MESSAGE =~ "/.*-TEST.*/i"

# @Description TEST single
RNAja:single:
  stage: test
  artifacts:
    name: RNAja-config_single
    paths:
      - test/RNAJA_OUTPUT
  script:
    - RNAja --install_env
    - RNAja test_install -d test
    - RNAja run_local -t 12 -c ./RNAja/install_files/config_test/RNAja-config_single.yaml;
  tags:
    - VM
  rules:
    - if: $CI_COMMIT_TAG =~ "/^v.*rc/" # Tests ran if commit message start with v.
    - if: $CI_COMMIT_MESSAGE =~ "/.*-TEST.*/i"


# @Description TEST paired
RNAja:paired:
  stage: test
  artifacts:
    name: RNAja-config_paired
    paths:
      - test/RNAJA_OUTPUT
  script:
    - RNAja --install_env
    - RNAja test_install -d test
    - RNAja run_local -t 12 -c ./RNAja/install_files/config_test/RNAja-config_paired.yaml
  tags:
    - VM
  rules:
    - if: $CI_COMMIT_TAG =~ "/^v.*rc/" # Tests ran if commit message start with v.
    - if: $CI_COMMIT_MESSAGE =~ "/.*-TEST.*/i"