From nobody Thu Apr 25 14:53:44 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1589365976; cv=none; d=zohomail.com; s=zohoarc; b=kWc+V+rEbfCF2xSp+GonDp3Lyt5nCpuIUqZ3MxIAHC7D1nte50AN/VQsmm6veuGEfo9UQ/FEdS13BczZa0QUq94h4pnhwmygA5XM2BKDmCMqLALvrexyoVJeCQYchOYPymhgLzU6yTGNbN3REH/QxjZM6oDZVNB1YFTi2s0fyE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589365976; 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=PiOMiPt9lwURp73D6Nr6Ct1YKRHe1uExmJzF0bIyZHM=; b=aRljZLXdjQiCg/Y0ZCti1kYqXe6jwHOm93pH61vNqWFlc01eJaXrbUBvnK02OSz4cRzhnky0Uq/berjrY/I39VOupKB3ToQ2rw2kBMXtUs0y19rSmVfqhQpv2BqT8tf4uyP1FsnhkzccHQLP81CvG0UdUZehXhDzTwwjBe6G6M4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1589365976765914.4764631839138; Wed, 13 May 2020 03:32:56 -0700 (PDT) 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-4-jhYwhOKhN6yNTj4rMD5MRw-1; Wed, 13 May 2020 06:32:51 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4256F461; Wed, 13 May 2020 10:32:46 +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 9078618A75; Wed, 13 May 2020 10:32:45 +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 878AF1809543; Wed, 13 May 2020 10:32:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04DAWhdp009128 for ; Wed, 13 May 2020 06:32:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 556BA75293; Wed, 13 May 2020 10:32:43 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.110.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76AE118A75; Wed, 13 May 2020 10:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589365975; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=PiOMiPt9lwURp73D6Nr6Ct1YKRHe1uExmJzF0bIyZHM=; b=QA+VccM19/+BtqTJ8TsyezFZ+T8B8N1eWiUQU892vnTNZxPLEDMoGyna7I5jysjDnI1KPC NTZkoFYQAGUkASfimgJaxpyRnosOoOrEyR5N+cMY7YSUEUxDQQyZXZMa0QYzF9GSgY30R5 V6fvWypNMq4/c9Ijc39WQHyjgpgA/bU= X-MC-Unique: jhYwhOKhN6yNTj4rMD5MRw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt-ci PATCH] containers: add a standard container for running cargo fmt Date: Wed, 13 May 2020 11:32:38 +0100 Message-Id: <20200513103238.1247438-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The "cargo fmt" code style checking tool is something we wish to run on all Rust code, so it is useful to have a common container that can be used by all relevant projects. Signed-off-by: Daniel P. Berrang=C3=A9 --- .gitlab-ci.yml | 5 +++++ containers/cargo-fmt/Dockerfile | 11 +++++++++++ containers/cargo-fmt/README.rst | 20 ++++++++++++++++++++ containers/cargo-fmt/cargo-fmt.sh | 22 ++++++++++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 containers/cargo-fmt/Dockerfile create mode 100644 containers/cargo-fmt/README.rst create mode 100755 containers/cargo-fmt/cargo-fmt.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 080c8d1..e5f121f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,6 +27,11 @@ go-fmt-container: variables: NAME: go-fmt =20 +cargo-fmt-container: + <<: *build_container_definition + variables: + NAME: cargo-fmt + # Check that all commits are signed-off for the DCO. Skip # on master branch and -maint branches, since we only need # to test developer's personal branches. diff --git a/containers/cargo-fmt/Dockerfile b/containers/cargo-fmt/Dockerf= ile new file mode 100644 index 0000000..0ed1c46 --- /dev/null +++ b/containers/cargo-fmt/Dockerfile @@ -0,0 +1,11 @@ +FROM rust:1.43 + +RUN export DEBIAN_FRONTEND=3Dnoninteractive && \ + apt-get update && \ + apt-get install --no-install-recommends -y \ + diffstat && \ + apt-get autoclean -y + +RUN rustup component add rustfmt + +COPY cargo-fmt.sh /cargo-fmt diff --git a/containers/cargo-fmt/README.rst b/containers/cargo-fmt/README.= rst new file mode 100644 index 0000000..00f50a2 --- /dev/null +++ b/containers/cargo-fmt/README.rst @@ -0,0 +1,20 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Container for running cargo fmt code style check +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +This container provides a simple way to invoke ``cargo fmt`` to validate c= ode +style across a Rust codebase. It should be integrated into CI by adding +the following snippet to ``.gitlab-ci.yml`` + +:: + + cargo-fmt: + stage: prebuild + image: registry.gitlab.com/libvirt/libvirt-ci/cargo-fmt:master + script: + - /cargo-fmt + artifacts: + paths: + - cargo-fmt.patch + expire_in: 1 week + when: on_failure diff --git a/containers/cargo-fmt/cargo-fmt.sh b/containers/cargo-fmt/cargo= -fmt.sh new file mode 100755 index 0000000..53fb0df --- /dev/null +++ b/containers/cargo-fmt/cargo-fmt.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +cargo fmt -v -- --check > cargo-fmt.patch + +if test -s cargo-fmt.patch +then + echo + echo "=E2=9D=8C ERROR: some files failed cargo fmt code style check" + echo + diffstat cargo-fmt.patch + echo + echo "See the cargo-fmt patch artifact for full details of mistakes." + echo + echo "For guidance on how to configure Emacs or Vim to automatically" + echo "run cargo fmt when saving files read" + echo + echo " https://github.com/rust-lang/rustfmt" + echo + exit 1 +fi + +echo "=E2=9C=94 OK: all files passed cargo fmt code style check" --=20 2.26.2