aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Bolognani <abologna@redhat.com>2022-04-04 17:56:04 +0200
committerAndrea Bolognani <abologna@redhat.com>2022-04-04 18:24:51 +0200
commit40edc2e88a49173288bbd1a9e1237d27358a884c (patch)
tree93a7333965aaec4ed1c5dcb3c906e786bbfa5c71
parent6a09e37415fef1de21fc40087796dd05d3bfcc83 (diff)
downloadlibvirt-ci-40edc2e88a49173288bbd1a9e1237d27358a884c.zip
libvirt-ci-40edc2e88a49173288bbd1a9e1237d27358a884c.tar.gz
libvirt-ci-40edc2e88a49173288bbd1a9e1237d27358a884c.tar.bz2
containers: Add cargo-clippy
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
-rw-r--r--.gitlab-ci.yml5
-rw-r--r--containers/cargo-clippy/Dockerfile5
-rw-r--r--containers/cargo-clippy/README.rst21
-rwxr-xr-xcontainers/cargo-clippy/cargo-clippy.sh15
4 files changed, 46 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e13201a..f859c33 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -96,6 +96,11 @@ cargo-fmt-container:
variables:
NAME: cargo-fmt
+cargo-clippy-container:
+ extends: .build_container_template
+ variables:
+ NAME: cargo-clippy
+
clang-format-container:
extends: .build_container_template
variables:
diff --git a/containers/cargo-clippy/Dockerfile b/containers/cargo-clippy/Dockerfile
new file mode 100644
index 0000000..fbf9010
--- /dev/null
+++ b/containers/cargo-clippy/Dockerfile
@@ -0,0 +1,5 @@
+FROM docker.io/library/rust:1.59-alpine
+
+RUN rustup component add clippy
+
+COPY cargo-clippy.sh /cargo-clippy
diff --git a/containers/cargo-clippy/README.rst b/containers/cargo-clippy/README.rst
new file mode 100644
index 0000000..5dff575
--- /dev/null
+++ b/containers/cargo-clippy/README.rst
@@ -0,0 +1,21 @@
+===================================================
+Container for running cargo clippy code style check
+===================================================
+
+This container provides a simple way to invoke ``cargo clippy`` to validate
+code style across a Rust codebase. It should be integrated into CI by adding
+the following snippet to ``.gitlab-ci.yml``
+
+::
+
+ cargo-clippy:
+ stage: sanity_checks
+ image: registry.gitlab.com/libvirt/libvirt-ci/cargo-clippy:master
+ needs: []
+ script:
+ - /cargo-clippy
+ artifacts:
+ paths:
+ - cargo-clippy.txt
+ expire_in: 1 week
+ when: on_failure
diff --git a/containers/cargo-clippy/cargo-clippy.sh b/containers/cargo-clippy/cargo-clippy.sh
new file mode 100755
index 0000000..6919fe5
--- /dev/null
+++ b/containers/cargo-clippy/cargo-clippy.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+cargo clippy --quiet --no-deps --all-targets > cargo-clippy.txt
+
+if test -s cargo-clippy.txt
+then
+ echo
+ echo "❌ ERROR: some files failed cargo clippy code style check"
+ echo
+ echo "See the cargo-clippy.txt artifact for full details of mistakes."
+ echo
+ exit 1
+fi
+
+echo "✔ OK: all files passed cargo clippy code style check"