Skip to content

Commit

Permalink
[eclipse-wakaamaGH-182] ci: Run Clang Static Analyzer
Browse files Browse the repository at this point in the history
Findings are available as artifact, but no further actions (e.g.
breaking the build) taken. Will gladdy do so however once we have fixed
the current findings.

Signed-off-by: Reto Schneider <code@reto-schneider.ch>
  • Loading branch information
rettichschnidi committed Apr 2, 2021
1 parent c6a3ceb commit 23247ff
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/clang-static-analyzer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Clang Static Analyzer

on: [push, pull_request]

jobs:
clang_static_analyzer:
runs-on: ubuntu-20.04

steps:
- name: Checkout code including full history and submodules
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0

- name: Install dependencies from APT repository
run: sudo apt-get install clang-tools-10 libcunit1-dev wget unzip

- name: Install CMake
uses: lukka/get-cmake@latest

- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@master

- name: Run Clang Static Analyzer
run: tools/ci/run_ci.sh --build --scan-build scan-build-10

- name: Upload scan build reports
uses: actions/upload-artifact@v1
with:
name: Clang Static Analyzer Reports
path: build-wakaama/clang-static-analyzer
20 changes: 18 additions & 2 deletions tools/ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ RUN_TESTS=0
OPT_VERBOSE=0
OPT_SANITIZER=""
OPT_TEST_COVERAGE_FORMAT=""
OPT_SCAN_BUILD=""
OPT_WRAPPER_CMD=""

HELP_MSG="usage: ${SCRIPT_NAME} <OPTIONS>...
Runs build and test steps in CI.
Expand All @@ -37,6 +39,9 @@ Options:
-h, --help Display this help and exit
--sanitizer TYPE Enable sanitizer
(TYPE: address leak thread undefined)
--scan-build BINARY Enable Clang code analyzer using specified
executable
(BINARY: e.g. scan-build-10)
--test-coverage FORMAT Create coverage info in given FORMAT
(FORMAT: xml html text)
Expand All @@ -60,8 +65,8 @@ function run_clean() {
function run_build() {
mkdir build-wakaama
pushd build-wakaama
cmake -GNinja -S .. ${CMAKE_ARGS}
ninja
${OPT_WRAPPER_CMD} cmake -GNinja -S .. ${CMAKE_ARGS}
${OPT_WRAPPER_CMD} ninja
popd
}

Expand Down Expand Up @@ -118,6 +123,7 @@ if ! PARSED_OPTS=$(getopt -o vah \
-l clean \
-l help \
-l sanitizer: \
-l scan-build: \
-l run-tests \
-l test-coverage: \
-l verbose \
Expand Down Expand Up @@ -146,6 +152,11 @@ while true; do
OPT_SANITIZER=$2
shift 2
;;
--scan-build)
OPT_SCAN_BUILD=$2
RUN_CLEAN=1 # Analyzing works only when code gets actually built
shift 2
;;
--test-coverage)
OPT_TEST_COVERAGE_FORMAT=$2
shift 2
Expand Down Expand Up @@ -191,6 +202,11 @@ if [ -n "${OPT_TEST_COVERAGE_FORMAT}" ]; then
CMAKE_ARGS="${CMAKE_ARGS} -DCOVERAGE=ON"
fi

if [ -n "${OPT_SCAN_BUILD}" ]; then
OPT_WRAPPER_CMD="${OPT_SCAN_BUILD} \
-o clang-static-analyzer"
fi

# Run Steps

if [ "${RUN_CLEAN}" -eq 1 ]; then
Expand Down

0 comments on commit 23247ff

Please sign in to comment.