Ensure the repository is not shallow before fetching branches in
check-patch job. This prevents issues where git merge-base fails
due to incomplete history. Set the timeout of check-patch job to 1h.
Signed-off-by: Vignesh Raman <vignesh.raman@collabora.com>
---
drivers/gpu/drm/ci/check-patch.py | 16 ++++++++++++----
drivers/gpu/drm/ci/static-checks.yml | 1 +
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/ci/check-patch.py b/drivers/gpu/drm/ci/check-patch.py
index a5f399a20e25..b206f12feb64 100755
--- a/drivers/gpu/drm/ci/check-patch.py
+++ b/drivers/gpu/drm/ci/check-patch.py
@@ -18,12 +18,20 @@ repourl = "https://gitlab.freedesktop.org/%s.git" % os.environ["CI_MERGE_REQUEST
# GitLab CI environment does not give us any direct info about the
# base for the user's branch. We thus need to figure out a common
# ancestor between the user's branch and current git master.
-os.environ["GIT_DEPTH"] = "1000"
subprocess.call(["git", "remote", "remove", "check-patch"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
subprocess.check_call(["git", "remote", "add", "check-patch", repourl])
-subprocess.check_call(["git", "fetch", "check-patch", os.environ["CI_MERGE_REQUEST_TARGET_BRANCH_NAME"]],
- stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL)
+
+# Check if the repository is shallow
+shallow = subprocess.run(["git", "rev-parse", "--is-shallow-repository"],
+ stdout=subprocess.PIPE, universal_newlines=True).stdout.strip()
+
+if shallow == "true":
+ print("Repository is shallow, unshallow git history")
+ subprocess.check_call(["git", "fetch", "--unshallow", "check-patch", os.environ["CI_MERGE_REQUEST_TARGET_BRANCH_NAME"]],
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+else:
+ subprocess.check_call(["git", "fetch", "check-patch", os.environ["CI_MERGE_REQUEST_TARGET_BRANCH_NAME"]],
+ stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
ancestor = subprocess.check_output(["git", "merge-base",
"check-patch/%s" % os.environ["CI_MERGE_REQUEST_TARGET_BRANCH_NAME"], "HEAD"],
diff --git a/drivers/gpu/drm/ci/static-checks.yml b/drivers/gpu/drm/ci/static-checks.yml
index 13ffa827b7fa..734d6055fa65 100644
--- a/drivers/gpu/drm/ci/static-checks.yml
+++ b/drivers/gpu/drm/ci/static-checks.yml
@@ -1,4 +1,5 @@
check-patch:
+ timeout: "1h"
extends:
- .build
- .use-debian/x86_64_build
--
2.47.2
Hi Vignesh, On Fri, 28 Mar 2025 at 11:03, Vignesh Raman <vignesh.raman@collabora.com> wrote: > Ensure the repository is not shallow before fetching branches in > check-patch job. This prevents issues where git merge-base fails > due to incomplete history. Set the timeout of check-patch job to 1h. Ouch - an hour is pretty brutal. Is there a way to unshallow only back to the merge base? Cheers, Daniel
Hi Daniel, On 28/03/25 17:05, Daniel Stone wrote: > Hi Vignesh, > > On Fri, 28 Mar 2025 at 11:03, Vignesh Raman <vignesh.raman@collabora.com> wrote: >> Ensure the repository is not shallow before fetching branches in >> check-patch job. This prevents issues where git merge-base fails >> due to incomplete history. Set the timeout of check-patch job to 1h. > > Ouch - an hour is pretty brutal. Is there a way to unshallow only back > to the merge base? I set it to 1h, but the job is completed in ~15min for https://gitlab.freedesktop.org/vigneshraman/linux/-/merge_requests/18 which has 486 commits. I will check if we can unshallow only up to the merge base. Regards, Vignesh > > Cheers, > Daniel
Hi Daniel, On 28/03/25 17:40, Vignesh Raman wrote: > Hi Daniel, > > On 28/03/25 17:05, Daniel Stone wrote: >> Hi Vignesh, >> >> On Fri, 28 Mar 2025 at 11:03, Vignesh Raman >> <vignesh.raman@collabora.com> wrote: >>> Ensure the repository is not shallow before fetching branches in >>> check-patch job. This prevents issues where git merge-base fails >>> due to incomplete history. Set the timeout of check-patch job to 1h. >> >> Ouch - an hour is pretty brutal. Is there a way to unshallow only back >> to the merge base? > > I set it to 1h, but the job is completed in ~15min for > https://gitlab.freedesktop.org/vigneshraman/linux/-/merge_requests/18 > which has 486 commits. > > I will check if we can unshallow only up to the merge base. I tried this and still checkpatch failed. Below is the sequence. - GitLab starts with a shallow fetch (depth=10). - Script fetches full commit history (--unshallow --filter=blob:none). We need this to calculate the merge-base commit. - Calculates how much history to fetch using the merge-base commit. - Refetch with depth (--depth=N) until the merge-base commit - checkpatch.pl fails because the earlier blobless fetch (--unshallow --filter=blob:none) skipped file contents. Please see the commit and pipeline, https://gitlab.freedesktop.org/vigneshraman/linux/-/commit/40a3fc31c2405f90f3fc3177a575a66a10b33324 https://gitlab.freedesktop.org/vigneshraman/linux/-/jobs/73884148 Looks like the reliable solution is to fully unshallow the repository (without any --filter) and set a 30m timeout? Would this be acceptable? Regards, Vignesh > > Regards, > Vignesh > >> >> Cheers, >> Daniel >
© 2016 - 2025 Red Hat, Inc.