From fe9f30d5c3c0c1e3cfb45be2eed9ad434187ca64 Mon Sep 17 00:00:00 2001
From: Geoffrey Arthaud <geoffrey.arthaud@developpement-durable.gouv.fr>
Date: Tue, 16 Jul 2024 17:24:35 +0200
Subject: [PATCH] Rust image check and rebuild manually activated

---
 .gitlab-ci.yml | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2af0e56..c509ca8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,6 +6,7 @@ workflow:
 
 variables:
   RUST_VERSION: "1.79" # slim or alpine not adapted because of openSSL dependency
+  RUST_IMAGE: "registry.gitlab-forge.din.developpement-durable.gouv.fr/pub/numeco/gitlab-project-doctor/rust-tools"
   TARGET_ARCH: default
   CARGO_HOME: .cargo
   TEST_OPTIONS: --url $CI_PROJECT_URL -a
@@ -55,6 +56,8 @@ include:
 
 build-rust-image:
   cache: [ ]
+  rules:
+    - if: $RUST_REBUILD_IMAGE
 
 release-gpd-image:
   needs:
@@ -66,7 +69,7 @@ release-gpd-image:
 
 check-format:
   stage: deps_and_lint
-  image: ${REGISTRY_IMAGE_RUST}
+  image: ${RUST_IMAGE}:${RUST_VERSION}
   script:
     - cargo fetch
     - cargo fmt --all -- --check
@@ -79,7 +82,7 @@ check-format:
 
 test-rust-current:
   stage: build_test
-  image: ${REGISTRY_IMAGE_RUST}
+  image: ${RUST_IMAGE}:${RUST_VERSION}
   script:
     - cargo test --verbose
     - cargo run -- $TEST_OPTIONS
@@ -93,7 +96,7 @@ test-rust-nightly:
   allow_failure: true
 
 .rust-release:
-  image: ${REGISTRY_IMAGE_RUST}
+  image: ${RUST_IMAGE}:${RUST_VERSION}
   stage: release
   variables:
     APP_NAME: gitlab-project-doctor
@@ -115,8 +118,9 @@ test-rust-nightly:
     - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
     - if: $CI_COMMIT_TAG
   needs:
-    - build-rust-image
-    - test-rust-current
+    - job: build-rust-image
+      optional: true
+    - job: test-rust-current
 
 release-linux:
   extends: .rust-release
@@ -169,6 +173,7 @@ test-release-docker:
     - gitlab-project-doctor $CLEAN_OPTIONS --token $TEST_GL_TOKEN
   cache: [ ]
   needs:
+    - release-linux
     - release-gpd-image
   rules:
     - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
-- 
GitLab