From 95c1baa6e702dd9fb9a62d7f3175d73d27769575 Mon Sep 17 00:00:00 2001
From: lb584 <lb584@cam.ac.uk>
Date: Mon, 30 Jan 2023 13:03:33 +0000
Subject: [PATCH] experimenting with manual jobs

---
 .gitlab-ci.yml | 71 +++++++++++++++++++++++++++-----------------------
 1 file changed, 39 insertions(+), 32 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 33ecebb..c15e1ff 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,8 +1,6 @@
 # This file is a template, and might need editing before it works on your project.
 # Official language image. Look for the different tagged releases at:
 # https://hub.docker.com/r/library/python/tags/
-image:
-  name: lb584/ews_coordinator:latest
 
 # Change pip's cache directory to be inside the project directory since we can
 # only cache local items.
@@ -20,40 +18,44 @@ cache:
     - .cache/pip
     - venv/
 
-before_script:
-  - python3 -V  # Print out python version for debugging
-#  - apt-get install --assume-yes git
-  - echo $PACKAGES_DIR
-  - mkdir $PACKAGES_DIR
-  - git clone "https://nouser:$GROUP_WHEAT_ACCESS_VAR@gitlab.developers.cam.ac.uk/gilligan-epid/wheat-rusts/ews-source-generation.git" $PACKAGES_DIR/source_gen
-  - git clone "https://nouser:$GROUP_WHEAT_ACCESS_VAR@gitlab.developers.cam.ac.uk/gilligan-epid/wheat-rusts/ews_plotting.git" $PACKAGES_DIR/plotting
-  - git clone "https://nouser:$GROUP_WHEAT_ACCESS_VAR@gitlab.developers.cam.ac.uk/gilligan-epid/wheat-rusts/flagdir.git" $PACKAGES_DIR/flagdir
-  - git clone "https://nouser:$GROUP_WHEAT_ACCESS_VAR@gitlab.developers.cam.ac.uk/gilligan-epid/wheat-rusts/ews-epimodel.git" $PACKAGES_DIR/epimodel
-  - git clone "https://nouser:$GROUP_WHEAT_ACCESS_VAR@gitlab.developers.cam.ac.uk/gilligan-epid/wheat-rusts/ews-advisory-builder.git" $PACKAGES_DIR/advisory_builder
-  - git clone "https://nouser:$GROUP_WHEAT_ACCESS_VAR@gitlab.developers.cam.ac.uk/gilligan-epid/wheat-rusts/ews_environmental_suitability_v2.git" $PACKAGES_DIR/environmental_suitability
-  - git clone "https://nouser:$GROUP_WHEAT_ACCESS_VAR@gitlab.developers.cam.ac.uk/gilligan-epid/wheat-rusts/ews-postprocessing.git" $PACKAGES_DIR/post_processing
-  - git clone "https://nouser:$GROUP_WHEAT_ACCESS_VAR@gitlab.developers.cam.ac.uk/gilligan-epid/wheat-rusts/ews_met_data_extraction.git" $PACKAGES_DIR/met_extractor_v2
-  - ls $PACKAGES_DIR
-  - source /storage/app/miniconda3/bin/activate /storage/app/EWS_prod/envs/conda/py3EWS/
-  - pip install coverage
-  - pwd
-  - flagdir=$PACKAGES_DIR/flagdir
-  - epimodel=$PACKAGES_DIR/epimodel
-  - advisory=$PACKAGES_DIR/advisory_builder
-  - met_processing=$PACKAGES_DIR/met_extractor_v2/met_data_extraction
-  - met_processor=$PACKAGES_DIR/environmental_suitability/environmental_suitability
-  - plotting=$PACKAGES_DIR/plotting/plotting
-  - post_processing=$PACKAGES_DIR/post_processing/ews_postprocessing
-  - source_gen=$PACKAGES_DIR/source_gen
-  - coordinator=$CI_PROJECT_DIR/coordinator
-  - coordinator_tests=$CI_PROJECT_DIR/tests
-  - export PYTHONPATH=$PYTHONPATH:$flagdir:$epimodel:$advisory:$met_processing:$met_processor:$plotting:$source_gen:$post_processing:$coordinator:$coordinator_tests
+prepare_code:
+  script:
+    - python3 -V  # Print out python version for debugging
+    - echo $PACKAGES_DIR
+    - mkdir $PACKAGES_DIR
+    - git clone "https://nouser:$GROUP_WHEAT_ACCESS_VAR@gitlab.developers.cam.ac.uk/gilligan-epid/wheat-rusts/ews-source-generation.git" $PACKAGES_DIR/source_gen
+    - git clone "https://nouser:$GROUP_WHEAT_ACCESS_VAR@gitlab.developers.cam.ac.uk/gilligan-epid/wheat-rusts/ews_plotting.git" $PACKAGES_DIR/plotting
+    - git clone "https://nouser:$GROUP_WHEAT_ACCESS_VAR@gitlab.developers.cam.ac.uk/gilligan-epid/wheat-rusts/flagdir.git" $PACKAGES_DIR/flagdir
+    - git clone "https://nouser:$GROUP_WHEAT_ACCESS_VAR@gitlab.developers.cam.ac.uk/gilligan-epid/wheat-rusts/ews-epimodel.git" $PACKAGES_DIR/epimodel
+    - git clone "https://nouser:$GROUP_WHEAT_ACCESS_VAR@gitlab.developers.cam.ac.uk/gilligan-epid/wheat-rusts/ews-advisory-builder.git" $PACKAGES_DIR/advisory_builder
+    - git clone "https://nouser:$GROUP_WHEAT_ACCESS_VAR@gitlab.developers.cam.ac.uk/gilligan-epid/wheat-rusts/ews_environmental_suitability_v2.git" $PACKAGES_DIR/environmental_suitability
+    - git clone "https://nouser:$GROUP_WHEAT_ACCESS_VAR@gitlab.developers.cam.ac.uk/gilligan-epid/wheat-rusts/ews-postprocessing.git" $PACKAGES_DIR/post_processing
+    - git clone "https://nouser:$GROUP_WHEAT_ACCESS_VAR@gitlab.developers.cam.ac.uk/gilligan-epid/wheat-rusts/ews_met_data_extraction.git" $PACKAGES_DIR/met_extractor_v2
+    - ls $PACKAGES_DIR
+    - source /storage/app/miniconda3/bin/activate /storage/app/EWS_prod/envs/conda/py3EWS/
+    - pip install coverage
+    - pwd
+    - flagdir=$PACKAGES_DIR/flagdir
+    - epimodel=$PACKAGES_DIR/epimodel
+    - advisory=$PACKAGES_DIR/advisory_builder
+    - met_processing=$PACKAGES_DIR/met_extractor_v2/met_data_extraction
+    - met_processor=$PACKAGES_DIR/environmental_suitability/environmental_suitability
+    - plotting=$PACKAGES_DIR/plotting/plotting
+    - post_processing=$PACKAGES_DIR/post_processing/ews_postprocessing
+    - source_gen=$PACKAGES_DIR/source_gen
+    - coordinator=$CI_PROJECT_DIR/coordinator
+    - coordinator_tests=$CI_PROJECT_DIR/tests
+    - export PYTHONPATH=$PYTHONPATH:$flagdir:$epimodel:$advisory:$met_processing:$met_processor:$plotting:$source_gen:$post_processing:$coordinator:$coordinator_tests
 
-  - echo $PYTHONPATH
-  - ls ../
+    - echo $PYTHONPATH
+    - ls ../
 
 half_fat_tests:
   when: always
+  image: lb584/ews_coordinator:latest
+  dependencies:
+    - prepare_code
+
   script:
     - cd $CI_PROJECT_DIR/tests/unit/coordinator/
     - python3 -m coverage run -m unittest *
@@ -74,6 +76,10 @@ half_fat_tests:
 
 half_fat_epi_tests:
   when: manual
+  image: lb584/ews_coordinator:latest
+  dependencies:
+    - prepare_code
+
   script:
     - cd $CI_PROJECT_DIR/tests/integration/partial/
     - python3 -m coverage run -m unittest test_epi.py
@@ -87,6 +93,7 @@ half_fat_epi_tests:
 
 manual_job:
   when: manual
+
   tags:
     - production
   script:
-- 
GitLab