From ac1ada1cd91dfc13665700c9aa3d8572a3f691b3 Mon Sep 17 00:00:00 2001 From: Raphael Defosseux <raphael.defosseux@eurecom.fr> Date: Tue, 2 Nov 2021 14:55:17 +0100 Subject: [PATCH] fix(ci): when the shared image dockerfile is being modified, force its build Signed-off-by: Raphael Defosseux <raphael.defosseux@eurecom.fr> --- ci-scripts/cls_containerize.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ci-scripts/cls_containerize.py b/ci-scripts/cls_containerize.py index 3e65f83e06..d0669b7665 100644 --- a/ci-scripts/cls_containerize.py +++ b/ci-scripts/cls_containerize.py @@ -195,6 +195,7 @@ class Containerize(): # the potential merge. Note that merge conflicts should already been checked earlier imageTag = 'develop' sharedTag = 'develop' + forceSharedImageBuild = False if (self.ranAllowMerge): imageTag = 'ci-temp' if self.ranTargetBranch == '': @@ -203,6 +204,13 @@ class Containerize(): else: logging.debug('Merging with the target branch: ' + self.ranTargetBranch) mySSH.command('git merge --ff origin/' + self.ranTargetBranch + ' -m "Temporary merge for CI"', '\$', 5) + mySSH.command('git diff HEAD..origin/develop -- docker/Dockerfile.ran' + self.dockerfileprefix + ' | grep -i INDEX', '\$', 5) + result = re.search('index', mySSH.getBefore()) + if result is not None: + forceSharedImageBuild = True + sharedTag = 'ci-temp' + else: + forceSharedImageBuild = True # if asterix, copy the entitlement and subscription manager configurations if self.host == 'Red Hat': @@ -214,13 +222,14 @@ class Containerize(): sharedimage = 'ran-build' # Let's remove any previous run artifacts if still there mySSH.command(self.cli + ' image prune --force', '\$', 30) - if (not self.ranAllowMerge): - mySSH.command(self.cli + ' image rm ' + sharedimage + ':' + sharedTag, '\$', 30) + if forceSharedImageBuild: + mySSH.command(self.cli + ' image rm ' + sharedimage + ':' + sharedTag + ' || true', '\$', 30) for image,pattern in imageNames: - mySSH.command(self.cli + ' image rm ' + image + ':' + imageTag, '\$', 30) + mySSH.command(self.cli + ' image rm ' + image + ':' + imageTag + ' || true', '\$', 30) # Build the shared image only on Push Events (not on Merge Requests) - if (not self.ranAllowMerge): + # On when the shared image docker file is being modified. + if forceSharedImageBuild: mySSH.command(self.cli + ' build ' + self.cliBuildOptions + ' --target ' + sharedimage + ' --tag ' + sharedimage + ':' + sharedTag + ' --file docker/Dockerfile.ran' + self.dockerfileprefix + ' --build-arg NEEDED_GIT_PROXY="http://proxy.eurecom.fr:8080" . > cmake_targets/log/ran-build.log 2>&1', '\$', 1600) # First verify if the shared image was properly created. status = True -- 2.26.2