[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/23] gitlab: add a CI job for running checkpatch.pl
From: |
Thomas Huth |
Subject: |
[PULL 14/23] gitlab: add a CI job for running checkpatch.pl |
Date: |
Tue, 13 Oct 2020 12:55:18 +0200 |
From: Daniel P. Berrangé <berrange@redhat.com>
This job is advisory since it is expected that certain patches will fail
the style checks and checkpatch.pl provides no way to mark exceptions to
the rules.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20200918132903.1848939-2-berrange@redhat.com>
[thuth: Use "stage: build" to let it run earlier]
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
.gitlab-ci.d/check-patch.py | 48 +++++++++++++++++++++++++++++++++++++
.gitlab-ci.yml | 12 ++++++++++
2 files changed, 60 insertions(+)
create mode 100755 .gitlab-ci.d/check-patch.py
diff --git a/.gitlab-ci.d/check-patch.py b/.gitlab-ci.d/check-patch.py
new file mode 100755
index 0000000000..5a14a25b13
--- /dev/null
+++ b/.gitlab-ci.d/check-patch.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python3
+#
+# check-patch.py: run checkpatch.pl across all commits in a branch
+#
+# Copyright (C) 2020 Red Hat, Inc.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import os
+import os.path
+import sys
+import subprocess
+
+namespace = "qemu-project"
+if len(sys.argv) >= 2:
+ namespace = sys.argv[1]
+
+cwd = os.getcwd()
+reponame = os.path.basename(cwd)
+repourl = "https://gitlab.com/%s/%s.git" % (namespace, reponame)
+
+# 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.
+subprocess.check_call(["git", "remote", "add", "check-patch", repourl])
+subprocess.check_call(["git", "fetch", "check-patch", "master"],
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL)
+
+ancestor = subprocess.check_output(["git", "merge-base",
+ "check-patch/master", "HEAD"],
+ universal_newlines=True)
+
+ancestor = ancestor.strip()
+
+subprocess.check_call(["git", "remote", "rm", "check-patch"])
+
+errors = False
+
+print("\nChecking all commits since %s...\n" % ancestor)
+
+ret = subprocess.run(["scripts/checkpatch.pl", ancestor + "..."])
+
+if ret.returncode != 0:
+ print(" ❌ FAIL one or more commits failed scripts/checkpatch.pl")
+ sys.exit(1)
+
+sys.exit(0)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 29e934fd53..f1e18d3e90 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -399,3 +399,15 @@ check-crypto-only-gnutls:
variables:
IMAGE: centos7
MAKE_CHECK_ARGS: check
+
+
+check-patch:
+ stage: build
+ image: $CI_REGISTRY_IMAGE/qemu/centos8:latest
+ script: .gitlab-ci.d/check-patch.py
+ except:
+ variables:
+ - $CI_PROJECT_NAMESPACE == 'qemu-project' && $CI_COMMIT_BRANCH ==
'master'
+ variables:
+ GIT_DEPTH: 1000
+ allow_failure: true
--
2.18.2
- [PULL 05/23] Acceptance tests: show test report on GitLab CI, (continued)
- [PULL 05/23] Acceptance tests: show test report on GitLab CI, Thomas Huth, 2020/10/13
- [PULL 06/23] qtest: add fuzz test case, Thomas Huth, 2020/10/13
- [PULL 08/23] softmmu/vl: Be less verbose about missing KVM when running the qtests, Thomas Huth, 2020/10/13
- [PULL 13/23] configure: fixes indent of $meson setup, Thomas Huth, 2020/10/13
- [PULL 12/23] docs/system/deprecated: Mark the 'moxie' CPU as deprecated, Thomas Huth, 2020/10/13
- [PULL 09/23] Add a comment in bios-tables-test.c to clarify the reason behind approach, Thomas Huth, 2020/10/13
- [PULL 10/23] MAINTAINERS: Ignore bios-tables-test in the qtest section, Thomas Huth, 2020/10/13
- [PULL 11/23] Remove superfluous .gitignore files, Thomas Huth, 2020/10/13
- [PULL 15/23] gitlab: add a CI job to validate the DCO sign off, Thomas Huth, 2020/10/13
- [PULL 07/23] tests/migration: Allow longer timeouts, Thomas Huth, 2020/10/13
- [PULL 14/23] gitlab: add a CI job for running checkpatch.pl,
Thomas Huth <=
- [PULL 16/23] gitlab: assign python helper files to GitLab maintainers section, Thomas Huth, 2020/10/13
- [PULL 18/23] scripts/ci/gitlab-pipeline-status: improve message regarding timeout, Thomas Huth, 2020/10/13
- [PULL 17/23] scripts/ci/gitlab-pipeline-status: make branch name configurable, Thomas Huth, 2020/10/13
- [PULL 20/23] scripts/ci/gitlab-pipeline-status: refactor parser creation, Thomas Huth, 2020/10/13
- [PULL 21/23] scripts/ci/gitlab-pipeline-status: handle keyboard interrupts, Thomas Huth, 2020/10/13
- [PULL 19/23] scripts/ci/gitlab-pipeline-status: give early feedback on running pipelines, Thomas Huth, 2020/10/13
- [PULL 23/23] scripts/ci/gitlab-pipeline-status: wait for pipeline creation, Thomas Huth, 2020/10/13
- [PULL 22/23] scripts/ci/gitlab-pipeline-status: use more descriptive exceptions, Thomas Huth, 2020/10/13
- Re: [PULL 00/23] qtests, gitlab-CI and misc patches, Peter Maydell, 2020/10/13