Skip to content

Commit

Permalink
Add Static Code Analysis GitHub Action
Browse files Browse the repository at this point in the history
For now runs clazy, but should get clang-tidy added in the future.
  • Loading branch information
kbroulik committed Dec 18, 2023
1 parent 696d055 commit 4b0d4ef
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/static-code-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# SPDX-License-Identifier: BSD-2-Clause
#
# SPDX-FileCopyrightText: 2023 Kai Uwe Broulik <ghqalpha@broulik.de>

name: Static Code Analysis

on: ["push", "pull_request"]

jobs:
static-code-analysis:
strategy:
matrix:
config:
- {name: "Ubuntu 22.04 (Clang)", os: "ubuntu-22.04", CC: "clang", CXX: "clang++"}

name: ${{matrix.config.name}}
runs-on: ${{matrix.config.os}}

steps:
- name: Install dependencies
env:
DEBIAN_FRONTEND: "noninteractive"
run: sudo apt-get update && sudo apt-get install -y build-essential cmake clazy clang-tidy qtbase5-dev qtdeclarative5-dev qtquickcontrols2-5-dev extra-cmake-modules libkf5coreaddons-dev libkf5declarative-dev libkf5sysguard-dev libsensors-dev

- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: recursive

- name: Export Compile Commands
env:
CC: ${{matrix.config.CC}}
CXX: ${{matrix.config.CXX}}
BUILD_DIR: "build/"
run: |
cmake -B ${BUILD_DIR} -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCLAZY_RUN=ON
- name: Clazy
env:
BUILD_DIR: "build/"
run: |
find src/ -name '*.cpp' | xargs clazy-standalone -p ${BUILD_DIR}compile_commands.json
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ add_feature_info(KINFOCENTER ${BUILD_KINFOCENTER} "Plug-in for KDE's Info Center
option(BUILD_EXAMPLES "Build examples" OFF)
add_feature_info(BUILD_EXAMPLES ${BUILD_EXAMPLES} "Example code")

option(CLAZY_RUN "Clazy run" OFF)
if (CLAZY_RUN)
add_compile_definitions(-DCLAZY_RUN=1)
endif()

set(API_URL "https://openapi.alphaess.com/api/" CACHE STRING "Default API URL")
add_feature_info(API_URL On "Default API URL is '${API_URL}'")

Expand Down
2 changes: 2 additions & 0 deletions src/infocenter/kcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ bool KCMAlphaCloud::presentationBuild() const
#endif
}

#ifndef CLAZY_RUN
#include "kcm.moc"
#endif
2 changes: 2 additions & 0 deletions src/qml/qmlplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,6 @@ void QAlphaCloudQmlPlugin::registerTypes(const char *uri)
qmlRegisterUncreatableMetaObject(QAlphaCloud::staticMetaObject, uri, 1, 0, "QAlphaCloud", tr("Cannot create instances of QAlphaCloud."));
}

#ifndef CLAZY_RUN
#include "qmlplugin.moc"
#endif
2 changes: 2 additions & 0 deletions src/systemstats/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,6 @@ void SystemStatsPlugin::update()
}
}

#ifndef CLAZY_RUN
#include "plugin.moc"
#endif

0 comments on commit 4b0d4ef

Please sign in to comment.