From b194b04e5f4f0abae617094e5717ed35cac8bb92 Mon Sep 17 00:00:00 2001
From: Andre Anjos <andre.dos.anjos@gmail.com>
Date: Tue, 8 Nov 2022 11:15:57 +0100
Subject: [PATCH] [data/gitlab-ci] Refactor to remove all references to
 $CI_RUNNER_TAGS [ci skip]

---
 bob/devtools/data/gitlab-ci/docs.yaml         |  2 +-
 bob/devtools/data/gitlab-ci/nightlies.yaml    | 35 +++++++++++--------
 bob/devtools/data/gitlab-ci/noarch.yaml       | 13 +++++--
 .../data/gitlab-ci/python-package.yaml        |  2 +-
 .../data/gitlab-ci/single-package.yaml        |  2 +-
 5 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/bob/devtools/data/gitlab-ci/docs.yaml b/bob/devtools/data/gitlab-ci/docs.yaml
index 4e8af61e..ade9700e 100644
--- a/bob/devtools/data/gitlab-ci/docs.yaml
+++ b/bob/devtools/data/gitlab-ci/docs.yaml
@@ -29,8 +29,8 @@ stages:
     - python3 bootstrap.py -vv channel base
     - source ${CONDA_ROOT}/etc/profile.d/conda.sh
     - conda activate base
-    - if [[ "${CI_RUNNER_TAGS}" =~ bob.*docker\|docker.*bob ]]; then git config --global --add safe.directory ${CI_PROJECT_DIR}; fi
     - conda clean --all
+    - git config --global --add safe.directory ${CI_PROJECT_DIR}
   cache:
     paths:
       - .cache/torch
diff --git a/bob/devtools/data/gitlab-ci/nightlies.yaml b/bob/devtools/data/gitlab-ci/nightlies.yaml
index 162b0d83..49681f2f 100644
--- a/bob/devtools/data/gitlab-ci/nightlies.yaml
+++ b/bob/devtools/data/gitlab-ci/nightlies.yaml
@@ -21,7 +21,6 @@ stages:
     - curl --silent "${BOOTSTRAP}" --output "bootstrap.py"
     - python3 bootstrap.py -vv channel base
     - source ${CONDA_ROOT}/etc/profile.d/conda.sh
-    - if [[ "${CI_RUNNER_TAGS}" =~ bob.*docker\|docker.*bob ]]; then git config --global --add safe.directory ${CI_PROJECT_DIR}; fi
     - conda activate base
     - conda clean --all
   cache:
@@ -48,6 +47,19 @@ stages:
   variables:
     # The version of cuda at Idiap
     CONDA_OVERRIDE_CUDA: "11.6"
+  before_script:
+    - !reference [.bootstrap, before_script]
+    - git config --global --add safe.directory ${CI_PROJECT_DIR}
+    - bdt ci check -vv
+
+.build_macos_template:
+  extends: .build_template
+  tags:
+    - bob
+    - macos
+  before_script:
+    - !reference [.bootstrap, before_script]
+    - bdt ci check -vv
 
 build_linux_39:
   extends: .build_linux_template
@@ -64,50 +76,45 @@ build_linux_310:
     key: 'build-py310'
 
 build_macos_intel_39:
-  extends: .build_template
+  extends: .build_macos_template
   variables:
     PYTHON_VERSION: "3.9"
   tags:
-    - bob
-    - macos
+    - !reference [.build_macos_template, tags]
     - intel
   cache:
     key: 'build-py39'
 
 build_macos_intel_310:
-  extends: .build_template
+  extends: .build_macos_template
   variables:
     PYTHON_VERSION: "3.10"
   tags:
-    - bob
-    - macos
+    - !reference [.build_macos_template, tags]
     - intel
   cache:
     key: 'build-py310'
 
 build_macos_arm_39:
-  extends: .build_template
+  extends: .build_macos_template
   variables:
     PYTHON_VERSION: "3.9"
   tags:
-    - bob
-    - macos
+    - !reference [.build_macos_template, tags]
     - arm
   cache:
     key: 'build-py39'
 
 build_macos_arm_310:
-  extends: .build_template
+  extends: .build_macos_template
   variables:
     PYTHON_VERSION: "3.10"
   tags:
-    - bob
-    - macos
+    - !reference [.build_macos_template, tags]
     - arm
   cache:
     key: 'build-py310'
 
-
 # Periodic cleanup of beta packages
 .cleanup_template:
   extends: .bootstrap
diff --git a/bob/devtools/data/gitlab-ci/noarch.yaml b/bob/devtools/data/gitlab-ci/noarch.yaml
index a20e6975..3edaa22f 100644
--- a/bob/devtools/data/gitlab-ci/noarch.yaml
+++ b/bob/devtools/data/gitlab-ci/noarch.yaml
@@ -23,10 +23,7 @@ stages:
     - curl --silent "${BOOTSTRAP}" --output "bootstrap.py"
     - python3 bootstrap.py -vv channel base
     - source ${CONDA_ROOT}/etc/profile.d/conda.sh
-    # for conda inspect during builds (on macos)
-    - if [[ "${CI_RUNNER_TAGS}" =~ bob.*docker\|docker.*bob ]]; then git config --global --add safe.directory ${CI_PROJECT_DIR}; fi
     - conda activate base
-    - bdt ci check -vv
     - conda clean --all
   cache:
     paths:
@@ -59,6 +56,10 @@ build_linux:
   variables:
     PYTHON_VERSION: "3.10"
     BUILD_EGG: "true"
+  before_script:
+    - !reference [.bootstrap, before_script]
+    - git config --global --add safe.directory ${CI_PROJECT_DIR}
+    - bdt ci check -vv
   script:
     - bdt ci build -vv
     - bdt ci readme -vv dist/*.zip
@@ -83,6 +84,9 @@ build_macos_intel:
     - bob
     - macos
     - intel
+  before_script:
+    - !reference [.bootstrap, before_script]
+    - bdt ci check -vv
 
 
 build_macos_arm:
@@ -95,6 +99,9 @@ build_macos_arm:
     - bob
     - macos
     - arm
+  before_script:
+    - !reference [.bootstrap, before_script]
+    - bdt ci check -vv
 
 
 # Test targets (not normally used)
diff --git a/bob/devtools/data/gitlab-ci/python-package.yaml b/bob/devtools/data/gitlab-ci/python-package.yaml
index b0edd1b2..4fba94e2 100644
--- a/bob/devtools/data/gitlab-ci/python-package.yaml
+++ b/bob/devtools/data/gitlab-ci/python-package.yaml
@@ -26,7 +26,7 @@ build:
     - docker
   stage: build
   before_script:
-    - if [[ "${CI_RUNNER_TAGS}" =~ bob.*docker\|docker.*bob ]]; then git config --global --add safe.directory ${CI_PROJECT_DIR}; fi
+    - git config --global --add safe.directory ${CI_PROJECT_DIR}
     - pip install twine pre-commit sphinx sphinx-rtd-theme
   script:
     - "[ -r .pre-commit-config.yaml ] && pre-commit run --all-files --show-diff-on-failure --verbose"
diff --git a/bob/devtools/data/gitlab-ci/single-package.yaml b/bob/devtools/data/gitlab-ci/single-package.yaml
index 329977c0..d05d1bb2 100644
--- a/bob/devtools/data/gitlab-ci/single-package.yaml
+++ b/bob/devtools/data/gitlab-ci/single-package.yaml
@@ -23,8 +23,8 @@ stages:
     - curl --silent "${BOOTSTRAP}" --output "bootstrap.py"
     - python3 bootstrap.py -vv channel base
     - source ${CONDA_ROOT}/etc/profile.d/conda.sh
-    # for conda inspect during builds (on macos)
     - conda activate base
+    - conda clean --all
   cache:
     paths:
       - miniconda.sh
-- 
GitLab