diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2022-11-23 10:42:04 +0000 |
---|---|---|
committer | Daniel P. Berrangé <berrange@redhat.com> | 2023-01-17 10:09:40 +0000 |
commit | 17b028b6a2c77684d57991f36becf3384a84eece (patch) | |
tree | 1bcdf181c7155a88874353210d0ebcba93fe903d | |
parent | e96df99622dca395591685ab867284b2dc18c2b6 (diff) | |
download | libvirt-ci-17b028b6a2c77684d57991f36becf3384a84eece.zip libvirt-ci-17b028b6a2c77684d57991f36becf3384a84eece.tar.gz libvirt-ci-17b028b6a2c77684d57991f36becf3384a84eece.tar.bz2 |
containers: add a standard container for python 'flake8' tool
The 'flake8' tool provides opinionated code style checks of
python code. This adds a minimal container for running 'flake8'
as a CI job.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-rw-r--r-- | .gitlab-ci.yml | 5 | ||||
-rw-r--r-- | containers/flake8/Dockerfile | 5 | ||||
-rw-r--r-- | containers/flake8/README.rst | 29 | ||||
-rwxr-xr-x | containers/flake8/flake8.sh | 17 |
4 files changed, 56 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 37dac23..10cbea6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -114,6 +114,11 @@ black-container: variables: NAME: black +flake8-container: + extends: .build_container_template + variables: + NAME: flake8 + cirrus-run-container: extends: .build_container_template variables: diff --git a/containers/flake8/Dockerfile b/containers/flake8/Dockerfile new file mode 100644 index 0000000..b3fb19d --- /dev/null +++ b/containers/flake8/Dockerfile @@ -0,0 +1,5 @@ +FROM docker.io/library/python:3.9-alpine + +RUN pip install flake8 + +COPY flake8.sh /flake8 diff --git a/containers/flake8/README.rst b/containers/flake8/README.rst new file mode 100644 index 0000000..d4b4461 --- /dev/null +++ b/containers/flake8/README.rst @@ -0,0 +1,29 @@ +============================================= +Container for running flake8 code style check +============================================= + +This container provides a simple way to invoke ``flake8`` to validate code +style across a Rust codebase. It should be integrated into CI by setting the +following flag in ``ci/manifest.yml`` + +:: + + gitlab: + jobs: + flake8: true + +or adding the following snippet to ``.gitlab-ci.yml`` + +:: + + flake8: + stage: sanity_checks + image: registry.gitlab.com/libvirt/libvirt-ci/flake8:master + needs: [] + script: + - /flake8 + artifacts: + paths: + - flake8.txt + expire_in: 1 week + when: on_failure diff --git a/containers/flake8/flake8.sh b/containers/flake8/flake8.sh new file mode 100755 index 0000000..b47b807 --- /dev/null +++ b/containers/flake8/flake8.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +flake8 + +if test "$?" != "0" +then + echo + echo "❌ ERROR: some files failed flake8 code style check" + echo + echo "See the flake8.txt artifact for full details of mistakes." + echo + + flake8 --show-source > flake8.txt + exit 1 +fi + +echo "✔ OK: all files passed flake8 code style check" |