From b8fa857b35157ce3f6d0d3421dea08f621c1568b Mon Sep 17 00:00:00 2001 From: Sam Gleske Date: Sat, 26 Feb 2022 00:00:23 -0500 Subject: [PATCH] Fix GitHub Actions Static Analyzer Check Dockerfile ---------- This dockerfile was used to emulate GitHub actions.
Dockerfile source (click to expand) ```dockerfile FROM ubuntu:20.04 ENV DEBIAN_FRONTEND=noninteractive RUN set -ex; \ apt-get update; \ apt-get install -y build-essential meson appstream clang clang-format clang-tools libdbus-1-dev libinih-dev libsystemd-dev git RUN set -ex; \ yes | adduser ci-user USER ci-user ```
Commands to reproduce --------------------- I simulated GitHub actions with a local docker environment. docker build -t ci . I ran the following commands to reproduce the issue so that I could bugfix the static analyzer script. ```bash docker run -e CI=true --rm -v "$PWD:$PWD" -w "$PWD" --init ci ./scripts/static-analyser-check.sh docker run -e CI=true --rm -v "$PWD:$PWD" -w "$PWD" --init ci ./bootstrap.sh -Dwith-examples=true docker run --rm -v "$PWD:$PWD" -w "$PWD" --init ci meson test -C builddir docker run --rm -v "$PWD:$PWD" -w "$PWD" --init ci dbus-run-session -- gamemode-simulate-game docker run --rm -v "$PWD:$PWD" -w "$PWD" --init ci ./scripts/static-analyser-check.sh ``` All commands reuse the same workspace which is how it works in GH actions. Legitimate bugs --------------- Now the error displayed in build failure appears to be a legitimate bug. Four were found related to null pointer dereference. I'm not fixing the bug but the check should work properly for those who do. If you following my docker setup in this description you can view the bug report by starting the report server. ```bash docker run -p 127.0.0.1:8181:8181 -it --rm -v "$PWD:$PWD" -w "$PWD" --init ci scan-view --host 0.0.0.0 --allow-all-hosts builddir/meson-logs/scanbuild/* ``` After the report server is started you can visit `http://127.0.0.1:8181/` to view the bugs. Screenshot of report -------------------- ![Screenshot of bug report](https://user-images.githubusercontent.com/875669/155830028-473db1ea-7c98-4a82-bc3a-290d5c155108.png) --- .gitignore | 1 + scripts/static-analyser-check.sh | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..13aeef2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/builddir diff --git a/scripts/static-analyser-check.sh b/scripts/static-analyser-check.sh index bc7e388..0139367 100755 --- a/scripts/static-analyser-check.sh +++ b/scripts/static-analyser-check.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -exo pipefail + # Ensure we are at the project root cd "$(dirname $0)"/.. @@ -7,4 +9,4 @@ cd "$(dirname $0)"/.. ninja scan-build -C builddir | tee builddir/meson-logs/scan-build.txt # Invert the output - if this string exists it's a fail -exit ! grep -E '[0-9]+ bugs? found.' builddir/meson-logs/scan-build.txt +! grep -E '[0-9]+ bugs? found.' builddir/meson-logs/scan-build.txt