qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: "Thomas Huth" <thuth@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>
Subject: Re: [PATCH 1/3] gitlab: add a CI job for running checkpatch.pl
Date: Fri, 18 Sep 2020 15:46:30 +0200	[thread overview]
Message-ID: <19bb60cd-1159-6215-6759-c2a10b9f8a66@redhat.com> (raw)
In-Reply-To: <20200918132903.1848939-2-berrange@redhat.com>

On 9/18/20 3:29 PM, Daniel P. Berrangé wrote:
> 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>
> ---
>  .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)

Hmm I'm very tempted to add various check I've been reluctant to
add to checkpatch.pl here, and use check-patch.py instead...



  reply	other threads:[~2020-09-18 13:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-18 13:29 [PATCH 0/3] gitlab: add jobs for checking paches Daniel P. Berrangé
2020-09-18 13:29 ` [PATCH 1/3] gitlab: add a CI job for running checkpatch.pl Daniel P. Berrangé
2020-09-18 13:46   ` Philippe Mathieu-Daudé [this message]
2020-10-13  8:08   ` Thomas Huth
2020-10-13  8:09     ` Daniel P. Berrangé
2020-09-18 13:29 ` [PATCH 2/3] gitlab: add a CI job to validate the DCO sign off Daniel P. Berrangé
2020-09-18 13:29 ` [PATCH 3/3] gitlab: assign python helper files to GitLab maintainers section Daniel P. Berrangé
2020-09-18 13:47   ` Philippe Mathieu-Daudé
2020-09-18 13:36 ` [PATCH 0/3] gitlab: add jobs for checking paches no-reply
2020-09-18 13:54 ` no-reply
2020-09-18 14:07 ` Thomas Huth
2020-09-18 14:10   ` Philippe Mathieu-Daudé
2020-09-18 14:15   ` Daniel P. Berrangé
2020-09-18 14:19     ` 罗勇刚(Yonggang Luo)
2020-09-18 14:57 ` no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19bb60cd-1159-6215-6759-c2a10b9f8a66@redhat.com \
    --to=philmd@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    --cc=wainersm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).