gitlab-ci: Add a job to run common coccinelle checks
PATCH 1/1 gitlab-ci: Add a job to run common coccinelle checks
Add a job to run common coccinelle checks.
We use spatch tool from Fedora 32 (Docker image) because more recent versions are failing.
---
Based-on: <[email protected]>
--- .gitlab-ci.d/containers.yml | 5 ++++ .gitlab-ci.yml | 26 +++++++++++++++++++ .../dockerfiles/fedora-coccinelle.docker | 16 ++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 tests/docker/dockerfiles/fedora-coccinelle.docker
.gitlab-ci.d/containers.yml +5 -0
@@ -249,3 +249,8 @@ amd64-opensuse-leap-container: <<: *container_job_definition variables: NAME: opensuse-leap + +cocci-fedora-container: + <<: *container_job_definition + variables: + NAME: fedora-coccinelle
.gitlab-ci.yml +26 -0
@@ -746,6 +746,32 @@ build-libvhost-user: - meson - ninja +check-cocci: + stage: build + needs: ['cocci-fedora-container'] + image: $CI_REGISTRY_IMAGE/qemu/fedora-coccinelle:latest + script: + - for script in + scripts/coccinelle/errp-guard.cocci + scripts/coccinelle/exec_rw_const.cocci + scripts/coccinelle/inplace-byteswaps.cocci + scripts/coccinelle/overflow_muldiv64.cocci + scripts/coccinelle/qom-parent-type.cocci + scripts/coccinelle/qom-parent-type.cocci + scripts/coccinelle/remove_local_err.cocci + scripts/coccinelle/remove_muldiv64.cocci + scripts/coccinelle/return_directly.cocci + scripts/coccinelle/typecast.cocci + scripts/coccinelle/use-after-abort-fatal-errp.cocci + ; do + spatch --macro-file scripts/cocci-macro-file.h + --sp-file $script + --timeout 137 + --jobs 2 + --use-gitgrep + --dir . + ; done + # Prepare for GitLab pages deployment. Anything copied into the # "public" directory will be deployed to $USER.gitlab.io/$PROJECT pages:
tests/docker/dockerfiles/fedora-coccinelle.docker new file +16 -0
@@ -0,0 +1,16 @@ +# +# Docker image to run Coccinelle spatch +# (program matching and transformation engine) +# +# Copyright (C) 2021 Red Hat, Inc. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +FROM fedora:32 + +# Please keep this list sorted alphabetically +RUN dnf install -y \ + coccinelle \ + diffutils \ + findutils \ + git-core
Signature · 1 line
2.26.2
Quoted 1 line · Philippe Mathieu-Daudé
Add a job to run common coccinelle checks.
This makes sense only for coccinelle scripts that come up clean and have a reasonably high confidence.
Come up clean: we get no reports for master. Otherwise new reports will drown in the old reports, and soon enough nobody will bother to look.
Reasonably high confidence: when the scripts complain, the complaint is valid often enough, and when they propose a change, the change is good enough often enough.
How do the scripts proposed in this patch score?
Quoted 31 lines
We use spatch tool from Fedora 32 (Docker image) because more recent versions are failing.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Based-on: <[email protected]>--- .gitlab-ci.d/containers.yml | 5 ++++ .gitlab-ci.yml | 26 +++++++++++++++++++ .../dockerfiles/fedora-coccinelle.docker | 16 ++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 tests/docker/dockerfiles/fedora-coccinelle.docker.gitlab-ci.d/containers.yml +5
-0@@ -249,3 +249,8 @@ amd64-opensuse-leap-container: <<: *container_job_definition variables: NAME: opensuse-leap + +cocci-fedora-container: + <<: *container_job_definition + variables: + NAME: fedora-coccinelle.gitlab-ci.yml +0
-0
.gitlab-ci.yml build-libvhost-user: · line 755
Quoted 10 lines
.gitlab-ci.yml +7
-0@@ -746,6 +746,32 @@ build-libvhost-user: - meson - ninja +check-cocci: + stage: build + needs: ['cocci-fedora-container'] + image: $CI_REGISTRY_IMAGE/qemu/fedora-coccinelle:latest + script: + - for script in + scripts/coccinelle/errp-guard.cocci
I doubt the tree's state permits this one. Its output should not be applied blindly.
Quoted 44 lines
.gitlab-ci.yml +19
-0+ scripts/coccinelle/exec_rw_const.cocci + scripts/coccinelle/inplace-byteswaps.cocci + scripts/coccinelle/overflow_muldiv64.cocci + scripts/coccinelle/qom-parent-type.cocci + scripts/coccinelle/qom-parent-type.cocci + scripts/coccinelle/remove_local_err.cocci + scripts/coccinelle/remove_muldiv64.cocci + scripts/coccinelle/return_directly.cocci + scripts/coccinelle/typecast.cocci + scripts/coccinelle/use-after-abort-fatal-errp.cocci + ; do + spatch --macro-file scripts/cocci-macro-file.h + --sp-file $script + --timeout 137 + --jobs 2 + --use-gitgrep + --dir . + ; done + # Prepare for GitLab pages deployment. Anything copied into the # "public" directory will be deployed to $USER.gitlab.io/$PROJECT pages:tests/docker/dockerfiles/fedora-coccinelle.docker new file +16
-0@@ -0,0 +1,16 @@ +# +# Docker image to run Coccinelle spatch +# (program matching and transformation engine) +# +# Copyright (C) 2021 Red Hat, Inc. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +FROM fedora:32 + +# Please keep this list sorted alphabetically +RUN dnf install -y \ + coccinelle \ + diffutils \ + findutils \ + git-core