From cb192d10714bad33f2c3ab5ec7702953860e6cdc Mon Sep 17 00:00:00 2001
From: Evgeny Snitko <evgeny@parity.io>
Date: Tue, 9 Apr 2024 23:49:39 +0400
Subject: [PATCH] Check for bundled forklift (#4055)

Added check if forklift already exists in ci image as forklift binary is
now bundled with the ci-unified.
This is a temporary check for the transition period
---
 .gitlab-ci.yml | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index fbcd94b5256..5e57dd86f14 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -119,19 +119,26 @@ default:
 #
 .forklift-cache:
   before_script:
-    - 'curl --header "PRIVATE-TOKEN: $FL_CI_GROUP_TOKEN" -o forklift  -L "${CI_API_V4_URL}/projects/676/packages/generic/forklift/${FL_FORKLIFT_VERSION}/forklift_${FL_FORKLIFT_VERSION}_linux_amd64"'
-    - chmod +x forklift
     - mkdir ~/.forklift
     - cp $FL_FORKLIFT_CONFIG ~/.forklift/config.toml
-    - shopt -s expand_aliases
-    - export PATH=$PATH:$(pwd)
     - >
       if [ "$FORKLIFT_BYPASS" != "true" ]; then
-      echo "FORKLIFT_BYPASS not set, creating alias cargo='forklift cargo'"; 
-      alias cargo="forklift cargo";
+        echo "FORKLIFT_BYPASS not set"; 
+        if command -v forklift >/dev/null 2>&1; then
+          echo "forklift already exists"; 
+          forklift version
+        else
+          echo "forklift does not exist, downloading";
+          curl --header "PRIVATE-TOKEN: $FL_CI_GROUP_TOKEN" -o forklift  -L "${CI_API_V4_URL}/projects/676/packages/generic/forklift/${FL_FORKLIFT_VERSION}/forklift_${FL_FORKLIFT_VERSION}_linux_amd64"; 
+          chmod +x forklift;
+          export PATH=$PATH:$(pwd);
+          echo ${FL_FORKLIFT_VERSION};
+        fi
+        echo "Creating alias cargo='forklift cargo'"; 
+        shopt -s expand_aliases;
+        alias cargo="forklift cargo";
       fi
     #
-    - echo "FL_FORKLIFT_VERSION ${FL_FORKLIFT_VERSION}"
 
 .common-refs:
   rules:
-- 
GitLab