image: eicweb.phy.anl.gov:4567/eic/juggler/juggler:$JUGGLER_TAG

default:
  artifacts:
    expire_in: 20 weeks
    paths:
      - results/
      - datasets/
      - sim_output/
      - data
    reports:
      dotenv: juggler.env
  before_script:
    - git clone https://eicweb.phy.anl.gov/EIC/NPDet.git
    - git clone https://eicweb.phy.anl.gov/EIC/detectors/topside.git && mkdir topside/build && cd topside/build && cmake ../. -DCMAKE_INSTALL_PREFIX=/usr/local && make -j20 install && cd ../..
    - git clone https://eicweb.phy.anl.gov/EIC/detectors/accelerator.git && cd topside && ln -s ../accelerator/eic && cd ../.

stages:
  - data_init
  - simulate
  - benchmarks
  - deploy

get_data:
  stage: data_init
  tags:
    - silicon
  script:
    - git clone https://eicweb.phy.anl.gov/EIC/datasets.git datasets
    - ln -s datasets/data
    - mkdir -p results
    - mkdir -p sim_output

roman_pot_simu:
  stage: simulate
  needs: 
    - ["get_data"]
  tags:
    - silicon
  script:
    - cp NPDet/src/detectors/trackers/compact/elements.xml ./.
    - cp NPDet/src/detectors/trackers/compact/materials.xml ./.
    - bash trackers/roman_pot_simu.sh

roman_pot_nhits:
  stage: benchmarks
  needs:
    - ["roman_pot_simu"]
  tags:
    - silicon
  script:
    - root -b -q trackers/simple_tracking.cxx+
  allow_failure: true

roman_pot_eta:
  stage: benchmarks
  tags:
    - silicon
  needs:
    - ["roman_pot_simu"]
  script:
    - root -b -q trackers/roman_pot_hit_eta.cxx+
  allow_failure: true

include:
  - local: 'calorimeters/calorimeters_config.yml'

deploy_results:
  stage: deploy
  needs:
    - ["ben_emcal_barrel_electrons"]
  tags:
    - silicon
  script:
    - echo "deploy results!"

pages:
  stage: deploy
  rules:
    - if: '$CI_COMMIT_BRANCH == "master" && $CI_SERVER_HOST != "eicweb.phy.anl.gov"'
  cache:
    paths:
      - node_modules/
  image: node:latest
  script:
    - mkdir public && cp doc/main.html public/index.html
  artifacts:
    paths:
      - public

