From ba58071aea115dc3ac694ac3fa7c8b6d477f78eb Mon Sep 17 00:00:00 2001
From: Vakho Tsulaia <tsulaia@cern.ch>
Date: Tue, 5 Nov 2024 21:44:49 -0800
Subject: [PATCH] Changes in the pipeline configuration

1. Run Athena early testing only on merge request events and when changes in GeoModelCore, GeoModelIO or cmake directories, as well as in CMakeLists.txt
2. Run Ubuntu jobs only on merge request events when changes are either in CMakeLists.txt or any directory other than documentation
3. Run documentation building on merge request events when changes are in the documentation directory
4. Run documentation building and deployment after an MR has been merged
---
 .gitlab-ci.yml   | 19 ++++++++++++-------
 athena_ci/ci.yml | 10 ++++++++++
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3a541275b..9d77f0ab5 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -47,9 +47,13 @@ workflow:
 # of the build, by using the 'standalone' job only
 .ubuntu-template-job-default: &ubuntu-job
   image: gitlab-registry.cern.ch/geomodeldev/ubuntu-geant4-image:main-base
+  variables:
+    CHANGEDIR: '[!d]*'
   rules:
-    - when: always
-
+    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
+      changes:
+      - $CHANGEDIR/**/*
+      - CMakeLists.txt
 
 # TEMPLATES FOR BUILDING PACKAGES
 .geomodel-build-template: &geomodel-job
@@ -364,6 +368,7 @@ ubu-geomodelatlas:
     - git clone https://${EOS_ACCOUNT_USERNAME}:${GEOMODEL_READ_ACCESS}@gitlab.cern.ch/atlas/geomodelatlas/GeoModelATLAS.git
     - ls -lh
     - CI/compile_GeoModel.sh
+
 #####################
 ### Documentation ###
 #####################
@@ -371,7 +376,7 @@ ubu-geomodelatlas:
 docs-build:
     stage: step-A
     rules:
-      - if: '$CI_COMMIT_BRANCH == "main"' # Build documentation only if changes are pushed to main.
+      - if: $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "merge_request_event"
         changes:
         - documentation/**/*
     allow_failure: true
@@ -506,16 +511,16 @@ persist-tag-artifacts:
       - install
     expire_in: never
 
-
 tests-ubuntu:
   <<: *ubuntu-job
-  stage: step-test
-  needs: ["ubu-gm-all"]
   stage: test
+  needs: ["ubu-gm-all"]
+  variables:
+      DUMMY: dummy # Work around weird configuration problems
   script:
     - mv build ../
     - cd ../build
-    - ctest #--output-on-failure
+    - ctest
   
 include:
   - athena_ci/ci.yml
diff --git a/athena_ci/ci.yml b/athena_ci/ci.yml
index 0018dd393..52f2cdda0 100644
--- a/athena_ci/ci.yml
+++ b/athena_ci/ci.yml
@@ -4,6 +4,11 @@ build_geomodel_athena:
   stage: step-A
   rules:
     - if: $CI_PIPELINE_SOURCE == "merge_request_event"
+      changes:
+      - GeoModelCore/**/*
+      - GeoModelIO/**/*
+      - cmake/**/*
+      - CMakeLists.txt
 
   variables:
     CCACHE_KEY_SUFFIX: r2
@@ -52,6 +57,11 @@ build_geomodel_athena:
 
   rules:
     - if: $CI_PIPELINE_SOURCE == "merge_request_event"
+      changes:
+      - GeoModelCore/**/*
+      - GeoModelIO/**/*
+      - cmake/**/*
+      - CMakeLists.txt
 
   # This image sould work, but it seems it doesn't. Using my derivative until 
   # I figure out what the difference is.
-- 
GitLab