[PATCH] lint: Add pre-merge checks using pre-push hook
Kieran Bingham
kieran.bingham at ideasonboard.com
Fri Jun 14 17:57:18 CEST 2024
Wrap the existing libcamera pre-push hook into a lint task to make sure
that the rules we apply to merging are conveyed as part of the CI jobs.
Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
.gitlab-ci/lint-pre-push.sh | 27 +++++++++++++++++++++++++++
gitlab-ci.yml | 16 +++++++++++++++-
2 files changed, 42 insertions(+), 1 deletion(-)
create mode 100755 .gitlab-ci/lint-pre-push.sh
diff --git a/.gitlab-ci/lint-pre-push.sh b/.gitlab-ci/lint-pre-push.sh
new file mode 100755
index 000000000000..8a4283cc0f15
--- /dev/null
+++ b/.gitlab-ci/lint-pre-push.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: © 2023 Laurent Pinchart <laurent.pinchart at ideasonboard.com>
+#
+# Pre-merge checks
+
+set -e
+
+source "$(dirname "$0")/lib.sh"
+
+libcamera_premerge() {
+ echo "Running Pre-merge checks for $CI_COMMIT_REF_NAME ($base..$CI_COMMIT_SHA)"
+
+ # Wrap parameters as git would send them to the pre-push hooks directly.
+ echo "$CI_COMMIT_REF_NAME $CI_COMMIT_SHA refs/heads/integration/pre-push-lint-test $base" \
+ | ./utils/hooks/pre-push origin "$CI_DEFAULT_BRANCH"
+}
+
+base=$(find_base origin/$CI_DEFAULT_BRANCH $CI_COMMIT_SHA)
+
+if [[ $base == $CI_COMMIT_SHA ]] ; then
+ echo "No commit to test, skipping"
+ exit 0
+fi
+
+run libcamera_premerge
diff --git a/gitlab-ci.yml b/gitlab-ci.yml
index 50b81e591458..d9b31ec8259e 100644
--- a/gitlab-ci.yml
+++ b/gitlab-ci.yml
@@ -311,7 +311,7 @@ build-package:cros:
dotenv: env
# ------------------------------------------------------------------------------
-# Lint stage - Run checkstyle.py
+# Lint stage - Run checkstyle.py and check merge suitability
# ------------------------------------------------------------------------------
lint:
@@ -330,6 +330,20 @@ lint:
script:
- $CI_PROJECT_DIR/.gitlab-ci/lint-libcamera.sh
+merge-check:
+ extends:
+ - .fdo.distribution-image at debian
+ - .history-jobs
+ - .libcamera-ci.debian:12
+ - .libcamera-ci.scripts
+ stage: lint
+ needs:
+ - job: container-debian:12
+ artifacts: false
+ script:
+ - $CI_PROJECT_DIR/.gitlab-ci/lint-pre-push.sh
+
+
# ------------------------------------------------------------------------------
# Test stage - Run unit tests and hardware tests
# ------------------------------------------------------------------------------
--
2.34.1
More information about the libcamera-devel
mailing list