From aa6fd73d05f91f40c062d7bef38e83745dee1ed9 Mon Sep 17 00:00:00 2001
From: Emanuele Aina <emanuele.aina@collabora.com>
Date: Fri, 15 Jan 2021 11:25:29 +0100
Subject: [PATCH] gitlab-ci: Ensure that `latest` tag comes from the latest
 pipeline

We want to ensure that the jobs updating the `latest` tags always reflect
the actual latest pipeline.

When two pipelines are started at the same time on the same branch
sometimes the earlier one can complete last due to scheduling or any
other reason, thus breaking the previous assumption.

To avoid that, make the whole pipeline interruptible up to the tagging jobs
so that earlier pipelines get killed when a new one is started.

Signed-off-by: Emanuele Aina <emanuele.aina@collabora.com>
---
 .gitlab-ci.yml | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0280784..00125ae 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -12,6 +12,15 @@ variables:
   STABLE: auto
   TEST_TAG: test-${CI_PIPELINE_ID}
 
+default:
+  # we want to ensure that the jobs updating the `latest` tags always reflect
+  # the actual latest pipeline. when two pipelines are started at the same time
+  # on the same branch sometimes the earlier one can complete last due to
+  # scheduling or any other reason, thus breaking the previous assumption.
+  # to avoid that, make the whole pipeline interruptible up to the tagging jobs
+  # so that earlier pipelines get killed when a new one is started
+  interruptible: true
+
 before_script:
   - |
     if [ "${CI_COMMIT_BRANCH%%/*}" = "$DISTRO" ]
-- 
GitLab