meta-arm.lists.yoctoproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] CI: add CI_CLEAN_REPOS variable to allow cleaning the repo reference cache
@ 2023-03-27 16:52 Ross Burton
  2023-03-30 23:17 ` Jon Mason
  0 siblings, 1 reply; 2+ messages in thread
From: Ross Burton @ 2023-03-27 16:52 UTC (permalink / raw)
  To: meta-arm; +Cc: nd

If the repository reference directory gets corrupted it's not easy to
wipe it, so add a variable CI_CLEAN_REPOS that if set in the pipeline
will clean the clones and re-fetch them.

Also, stop the fetch from detaching during the garbage collection, just
in case it was a long-running GC that got killed that caused the
corruption in the first place.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 .gitlab-ci.yml  | 3 ++-
 ci/update-repos | 8 +++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9c52b106..28d0cc19 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -58,7 +58,8 @@ stages:
       - $CI_PROJECT_DIR/work/build/tmp/work*/**/testimage/*
 
 #
-# Prep stage, update repositories once
+# Prep stage, update repositories once.
+# Set the CI variable CI_CLEAN_REPOS=1 to refetch the respositories from scratch
 #
 update-repos:
   extends: .setup
diff --git a/ci/update-repos b/ci/update-repos
index 91ff1975..9487102d 100755
--- a/ci/update-repos
+++ b/ci/update-repos
@@ -4,6 +4,7 @@
 
 import sys
 import os
+import shutil
 import subprocess
 import pathlib
 
@@ -34,9 +35,14 @@ if __name__ == "__main__":
 
     for repo in repositories:
         repodir = base_repodir / repo_shortname(repo)
+
+        if "CI_CLEAN_REPOS" in os.environ:
+            print("Cleaning %s..." % repo)
+            shutil.rmtree(repodir, ignore_errors=True)
+
         if repodir.exists():
             print("Updating %s..." % repo)
-            subprocess.run(["git", "-C", repodir, "fetch"], check=True)
+            subprocess.run(["git", "-C", repodir, "-c", "gc.autoDetach=false", "fetch"], check=True)
         else:
             print("Cloning %s..." % repo)
             subprocess.run(["git", "clone", "--bare", repo, repodir], check=True)
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] CI: add CI_CLEAN_REPOS variable to allow cleaning the repo reference cache
  2023-03-27 16:52 [PATCH] CI: add CI_CLEAN_REPOS variable to allow cleaning the repo reference cache Ross Burton
@ 2023-03-30 23:17 ` Jon Mason
  0 siblings, 0 replies; 2+ messages in thread
From: Jon Mason @ 2023-03-30 23:17 UTC (permalink / raw)
  To: meta-arm, Ross Burton; +Cc: nd

On Mon, 27 Mar 2023 17:52:14 +0100, Ross Burton wrote:
> If the repository reference directory gets corrupted it's not easy to
> wipe it, so add a variable CI_CLEAN_REPOS that if set in the pipeline
> will clean the clones and re-fetch them.
> 
> Also, stop the fetch from detaching during the garbage collection, just
> in case it was a long-running GC that got killed that caused the
> corruption in the first place.

Applied, thanks!

[1/1] CI: add CI_CLEAN_REPOS variable to allow cleaning the repo reference cache
      commit: 2db12df861fda0896f196a101572d6300bb4cc78

Best regards,
-- 
Jon Mason <jon.mason@arm.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-31  2:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-27 16:52 [PATCH] CI: add CI_CLEAN_REPOS variable to allow cleaning the repo reference cache Ross Burton
2023-03-30 23:17 ` Jon Mason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).