{"thread":{"id":"60667","subject":"[PATCH] ci: add job performing static analysis on GitLab CI","startedAt":"2023-12-28T11:02:56Z","lastAt":"2024-01-04T09:26:45Z","messageCount":2,"participants":["Patrick Steinhardt","Toon Claes"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"486115","messageId":"1536a5ef07ad24dafb5d685b40099882f89e6cc5.1703761005.git.ps@pks.im","threadId":"60667","inReplyTo":null,"subject":"[PATCH] ci: add job performing static analysis on GitLab CI","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2023-12-28T11:02:50Z","receivedAt":"2023-12-28T11:02:56Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Our GitHub Workflows definitions have a static analysis job that\nruns the following tasks:\n\n  - Coccinelle to check for suggested refactorings.\n\n  - `make hdr-check` to check for missing includes or forward\n    declarations in our header files.\n\n  - `make check-pot` to check our translations for issues.\n\n  - `./ci/check-directional-formatting.bash` to check whether our\n    sources contain any Unicode directional formatting code points.\n\nAdd an equivalent job to our GitLab CI definitions.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n\nThis addition is inspired by my reftable patch series where I forgot to\nadd a \"hash-ll.h\" include. This would've been catched by our GitLab CI\npipeline if we already had the static-analysis job added in this patch.\n\nThese changes are part of [1], which thus also contains an example\npipeline run.\n\n[1]: https://gitlab.com/gitlab-org/git/-/merge_requests/79\n\n .gitlab-ci.yml                    | 10 ++++++++++\n ci/install-docker-dependencies.sh |  7 ++++++-\n 2 files changed, 16 insertions(+), 1 deletion(-)\n\ndiff --git a/.gitlab-ci.yml b/.gitlab-ci.yml\nindex cd98bcb18a..793243421c 100644\n--- a/.gitlab-ci.yml\n+++ b/.gitlab-ci.yml\n@@ -51,3 +51,13 @@ test:\n     paths:\n       - t/failed-test-artifacts\n     when: on_failure\n+\n+static-analysis:\n+  image: ubuntu:22.04\n+  variables:\n+    jobname: StaticAnalysis\n+  before_script:\n+    - ./ci/install-docker-dependencies.sh\n+  script:\n+    - ./ci/run-static-analysis.sh\n+    - ./ci/check-directional-formatting.bash\ndiff --git a/ci/install-docker-dependencies.sh b/ci/install-docker-dependencies.sh\nindex 48c43f0f90..eb2c9e1eca 100755\n--- a/ci/install-docker-dependencies.sh\n+++ b/ci/install-docker-dependencies.sh\n@@ -21,7 +21,7 @@ linux-musl)\n \t\tapache2 apache2-http2 apache2-proxy apache2-ssl apache2-webdav apr-util-dbd_sqlite3 \\\n \t\tbash cvs gnupg perl-cgi perl-dbd-sqlite >/dev/null\n \t;;\n-linux-*)\n+linux-*|StaticAnalysis)\n \t# Required so that apt doesn't wait for user input on certain packages.\n \texport DEBIAN_FRONTEND=noninteractive\n \n@@ -31,6 +31,11 @@ linux-*)\n \t\tperl-modules liberror-perl libauthen-sasl-perl libemail-valid-perl \\\n \t\tlibdbd-sqlite3-perl libio-socket-ssl-perl libnet-smtp-ssl-perl ${CC_PACKAGE:-${CC:-gcc}} \\\n \t\tapache2 cvs cvsps gnupg libcgi-pm-perl subversion\n+\n+\tif test \"$jobname\" = StaticAnalysis\n+\tthen\n+\t\tapt install -q -y coccinelle\n+\tfi\n \t;;\n pedantic)\n \tdnf -yq update >/dev/null &&\n-- \n2.43.GIT\n\n"},{"id":"486284","messageId":"87plyhfo00.fsf@iotcl.com","threadId":"60667","inReplyTo":"1536a5ef07ad24dafb5d685b40099882f89e6cc5.1703761005.git.ps@pks.im","subject":"Re: [PATCH] ci: add job performing static analysis on GitLab CI","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2024-01-04T09:19:31Z","receivedAt":"2024-01-04T09:26:45Z","isPatch":true,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"\nPatrick Steinhardt <ps@pks.im> writes:\n\n> --- a/ci/install-docker-dependencies.sh\n> +++ b/ci/install-docker-dependencies.sh\n> @@ -21,7 +21,7 @@ linux-musl)\n>  \t\tapache2 apache2-http2 apache2-proxy apache2-ssl apache2-webdav apr-util-dbd_sqlite3 \\\n>  \t\tbash cvs gnupg perl-cgi perl-dbd-sqlite >/dev/null\n>  \t;;\n> -linux-*)\n> +linux-*|StaticAnalysis)\n>  \t# Required so that apt doesn't wait for user input on certain packages.\n>  \texport DEBIAN_FRONTEND=noninteractive\n>\n> @@ -31,6 +31,11 @@ linux-*)\n>  \t\tperl-modules liberror-perl libauthen-sasl-perl libemail-valid-perl \\\n>  \t\tlibdbd-sqlite3-perl libio-socket-ssl-perl libnet-smtp-ssl-perl ${CC_PACKAGE:-${CC:-gcc}} \\\n>  \t\tapache2 cvs cvsps gnupg libcgi-pm-perl subversion\n> +\n> +\tif test \"$jobname\" = StaticAnalysis\n> +\tthen\n> +\t\tapt install -q -y coccinelle\n> +\tfi\n\nI was wondering why this was added, because I would assume the GitHub\nWorkflow needed this too. Well, it seems the \"StaticAnalysis\" job for\nthe Workflow runs ci/install-dependencies.sh instead of\nci/install-docker-dependencies.sh. The ci/install-docker-dependencies.sh\nscript is only used in the GitHub Workflow for the \"dockerized\" jobs.\nThey set $jobname to \"linux-musl\", \"linux32\", and \"pedantic\", so this\nchange is not affected by that.\n\nBottom line, changes all look good to me.\n\n--\nToon\n"}]}