stages:  
  - build
  - test
  - clean

build:tests:
  stage: build
  script: 
    - python setup.py sdist --dist-dir=build
  artifacts:
    paths:
    - build/clmctest-SNAPSHOT.tar.gz
    expire_in: 1 day

test:all:
  stage: test
  dependencies: 
    - build:tests
  script: 
    - vagrant --fixture=scripts -- up
    - vagrant --fixture=scripts -- ssh test-runner -- -tt "pip3 install /vagrant/build/clmctest-SNAPSHOT.tar.gz"
    - vagrant --fixture=scripts -- ssh test-runner -- -tt "pytest -s --pyargs clmctest.scripts"
    - vagrant --fixture=monitoring -- up
    - vagrant --fixture=monitoring -- ssh test-runner -- -tt "pytest -s --pyargs clmctest.monitoring"  
    - vagrant --fixture=inputs -- up
    - vagrant --fixture=inputs -- ssh test-runner -- -tt "pytest -s --pyargs clmctest.inputs"        
  when: on_success      
  
clean:
  stage: clean
  script: 
    - scripts/build/deleteallvms.sh   
  when: always