From nobody Fri Apr 26 23:37:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=patchew-devel-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1609847940; cv=none; d=zohomail.com; s=zohoarc; b=YjqIMIfCyhM+EByOL5lO1eyyoXfqWuWgTrO51TM2u0Pc5gNSIQQslJ35swmog31mpmj54oE32eb5Hgc7n3PrdTF6miJx3BnifCAsy7bKSFxWOXw65utloUogfHjmBmEIpTY6gICVVcL260XxwAgsEfw5oAxNjtlqkmA1kErjKys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609847940; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=rc7tALOWGhiaGRPdQLnR/SKUE7SKJ+xxFcTvDpVTDKQ=; b=LPve/lOz0uev7z9v9oQ8pRLWwcQrIok9jWE95hpUrNhU+Tit3qGwBaAHHfyutkVqyy5cpzil12R8KC0L+jzHhC9IxK5H5hqanT+Hx2F120VDkAZ51QRk5Ua4ow4TV6UAbILEZipbq0oVXLJQRJuf35675XHKxXsdeuOv7XVr1Xw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1609847940045166.43937471136462; Tue, 5 Jan 2021 03:59:00 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-423-KQiyx6aQPkuN3Zwx5VETUg-1; Tue, 05 Jan 2021 06:58:56 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 831D8800D53; Tue, 5 Jan 2021 11:58:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FE6F5C1D5; Tue, 5 Jan 2021 11:58:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 32DE5180954D; Tue, 5 Jan 2021 11:58:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 105BwrVu027578 for ; Tue, 5 Jan 2021 06:58:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0FD302166B2A; Tue, 5 Jan 2021 11:58:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A1632166B29 for ; Tue, 5 Jan 2021 11:58:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 778E2858EEC for ; Tue, 5 Jan 2021 11:58:50 +0000 (UTC) Received: from sender2-op-o12.zoho.com.cn (sender2-op-o12.zoho.com.cn [163.53.93.243]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-445-ar3pi0UQMLCzfrtV5GS6Qg-1; Tue, 05 Jan 2021 06:58:46 -0500 Received: from localhost (ec2-52-56-101-76.eu-west-2.compute.amazonaws.com [52.56.101.76]) by mx.zoho.com.cn with SMTPS id 1609846998038363.60046938840026; Tue, 5 Jan 2021 19:43:18 +0800 (CST) X-MC-Unique: KQiyx6aQPkuN3Zwx5VETUg-1 X-MC-Unique: ar3pi0UQMLCzfrtV5GS6Qg-1 From: fam@euphon.net To: patchew-devel@redhat.com Message-ID: <20210105114313.90141-1-fam@euphon.net> Date: Tue, 5 Jan 2021 11:43:13 +0000 MIME-Version: 1.0 X-ZohoCNMailClient: External X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 105BwrVu027578 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH] Support 'git push -o ci.skip' for gitlab CI X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=patchew-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Fam Zheng When we update tags and re-apply series, don't trigger CI pipeline. Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- mods/git.py | 16 +++++++++++++--- patchew-cli | 17 +++++++++-------- tests/patchewtest.py | 14 +++++++++++--- tests/test_git.py | 11 +++++++++++ 4 files changed, 44 insertions(+), 14 deletions(-) diff --git a/mods/git.py b/mods/git.py index d10cbeb..df9374b 100644 --- a/mods/git.py +++ b/mods/git.py @@ -75,6 +75,9 @@ class GitModule(PatchewModule): schema.StringSchema( "public_repo", "Public repo", desc=3D"Publicly visible rep= o URL" ), + schema.BooleanSchema( + "use_git_push_option", "Enable git push options", desc=3D"= Whether the push remote accepts git push options" + ), schema.StringSchema( "url_template", "URL template", @@ -93,15 +96,21 @@ class GitModule(PatchewModule): declare_event("ProjectGitUpdate", project=3D"the updated project n= ame") declare_event("SeriesApplied", series=3D"the object of applied ser= ies") register_handler("SeriesComplete", self.on_series_update) - register_handler("TagsUpdate", self.on_series_update) + register_handler("TagsUpdate", self.on_tags_update) =20 - def mark_as_pending_apply(self, series): + def mark_as_pending_apply(self, series, data=3D{}): r =3D series.git_result or series.create_result(name=3D"git") r.log =3D None r.status =3D Result.PENDING - r.data =3D {} + r.data =3D data r.save() =20 + def on_tags_update(self, event, series, **params): + if series.is_complete: + self.mark_as_pending_apply(series, { + 'git.push_options': 'ci.skip', + }) + def on_series_update(self, event, series, **params): if series.is_complete: self.mark_as_pending_apply(series) @@ -327,6 +336,7 @@ class ApplierGetView(APILoginRequiredView): request=3Drequest, ) response["result_uri"] =3D reverse_detail(m.git_result, request) + response["git.push_options"] =3D m.git_result.data.get("git.push_o= ptions") return response =20 =20 diff --git a/patchew-cli b/patchew-cli index 8e3a357..ccef76b 100755 --- a/patchew-cli +++ b/patchew-cli @@ -934,19 +934,19 @@ class ApplyCommand(SubCommand): ) return list(maintainers) =20 - def _push(self, repo, remote, tag, logf): + def _push(self, repo, remote, tag, logf, push_options): subprocess.check_call( ["git", "remote", "add", "push_to", remote], cwd=3Drepo, stdout=3Dlogf, stderr=3Dlogf, ) - subprocess.check_call( - ["git", "push", "-f", "push_to", "%s:refs/tags/%s" % (tag, tag= )], - cwd=3Drepo, - stdout=3Dlogf, - stderr=3Dlogf, - ) + push_options_args =3D ['-o', push_options] if push_options else [] + cmd =3D ["git", "push", "-f", "push_to"] + \ + push_options_args + \ + ["%s:refs/tags/%s" % (tag, tag)] + logging.debug(" ".join(cmd)) + subprocess.check_call(cmd, cwd=3Drepo, stdout=3Dlogf, stderr=3Dlog= f) =20 def _applier_mode(self, args): applier_get_args =3D {} @@ -981,7 +981,8 @@ class ApplyCommand(SubCommand): ) maintainers =3D self._apply(wd, toapply, branch, force_branch,= tag, logf) if push_repo: - self._push(wd, push_repo, tag, logf) + push_options =3D toapply.get('git.push_options') if toappl= y.get("git.use_git_push_option") else None + self._push(wd, push_repo, tag, logf, push_options) url =3D toapply.get("git.url_template", "").replace("%t", tag) except Exception as e: if not isinstance(e, ApplyFailedException): diff --git a/tests/patchewtest.py b/tests/patchewtest.py index ab333ae..33923d1 100644 --- a/tests/patchewtest.py +++ b/tests/patchewtest.py @@ -70,8 +70,15 @@ class PatchewTestCase(dj_test.LiveServerTestCase): return user =20 def cli(self, argv): + return self.do_cli(False, argv) + + def cli_debug(self, argv): + return self.do_cli(True, argv) + + def do_cli(self, debug, argv): """Run patchew-cli command and return (retcode, stdout, stderr)""" - cmd =3D [PATCHEW_CLI, "-D", "-s", self.live_server_url] + argv + dbgopt =3D "-d" if debug else "-D" + cmd =3D [PATCHEW_CLI, dbgopt, "-s", self.live_server_url] + argv p =3D subprocess.Popen(cmd, stdout=3Dsubprocess.PIPE, stderr=3Dsub= process.PIPE) a, b =3D p.communicate() a =3D a.decode("utf-8") @@ -105,13 +112,14 @@ class PatchewTestCase(dj_test.LiveServerTestCase): def cli_import(self, mbox, rc=3D0): self.check_cli(["import", self.get_data_path(mbox)], rc) =20 - def do_apply(self): + def do_apply(self, debug=3DFalse): while True: - r, out, err =3D self.cli(["apply", "--applier-mode"]) + r, out, err =3D self.do_cli(debug, ["apply", "--applier-mode"]) if r !=3D 0: break for s in Message.objects.series_heads(): self.assertNotEqual(s.git_result.status, Result.PENDING) + return out, err =20 def get_data_path(self, fname): r =3D tempfile.NamedTemporaryFile(dir=3DRUN_DIR, prefix=3D"test-da= ta-", delete=3DFalse) diff --git a/tests/test_git.py b/tests/test_git.py index 4718322..857454c 100755 --- a/tests/test_git.py +++ b/tests/test_git.py @@ -194,6 +194,17 @@ class GitTest(PatchewTestCase): self.assertEqual(resp.status_code, 200) self.assertEquals(len(resp.data["results"]), 0) =20 + def test_git_push_options(self): + self.p.config['git']["use_git_push_option"] =3D True + self.p.save() + self.cli_import("0013-foo-patch.mbox.gz") + out, err =3D self.do_apply(True) + self.assertNotIn("ci.skip", out) + + # Getting a new reviewed-by shouldn't trigger re-test + self.cli_import("0025-foo-patch-review.mbox.gz") + out, err =3D self.do_apply(True) + self.assertIn("ci.skip", out) =20 if __name__ =3D=3D "__main__": main() --=20 2.25.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel