Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 189 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
Language: Cpp
# BasedOnStyle: Microsoft
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveMacros: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: false
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
QualifierAlignment: Leave
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
PackConstructorInitializers: BinPack
BasedOnStyle: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
AllowAllConstructorInitializersOnNextLine: true
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 1000
PenaltyIndentedWhitespace: 0
PointerAlignment: Left
PPIndentWidth: -1
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
BeforeNonEmptyParentheses: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: Latest
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
Empty file added .github/.keep
Empty file.
41 changes: 41 additions & 0 deletions .github/actions/building/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Build"
description: "Executes a compilation."

runs:
using: "composite"
steps:
- name: Compile
shell: bash
run: |
sudo apt update
sudo apt install libmicrohttpd-dev

PROJECT_ROOT=$(pwd)
SUBMODULE_DIR="$PROJECT_ROOT/submodule/lib/prometheus-client-c"

cd "$SUBMODULE_DIR/prom"
mkdir -p build
cd build
cmake ..
make
sudo make install

cd "$SUBMODULE_DIR/promhttp"
mkdir -p build
cd build
cmake ..
make
sudo make install

cd "$PROJECT_ROOT"

pip install conan
conan profile detect --force
conan config home
cp ~/.conan2/profiles/default ~/.conan2/profiles/debug && sed -i -e 's/Release/Debug/g' ~/.conan2/profiles/debug
conan install . --build=missing --profile=debug

mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug
make
56 changes: 56 additions & 0 deletions .github/actions/coverage_and_test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "Test and coverage check"
description: "Test and coverage check with gcovr, pass if coverage is greater than 20%"

runs:
using: "composite"
steps:
- name: "Run coverage"
shell: bash
run: |
PROJECT_PATH=$(pwd)

ERROR_FILE_FLAG=$(pwd)/tests_errors.txt

CTEST_ERROR_FILE_FLAG=$(pwd)/ctest_errors.txt
# run tests built with cmake
# --output-on-faileure: prints everythin outputted by the tests if it fails
# -VV verbose output
CTEST_COMMAND=$(ctest --test-dir build/tests --output-on-failure -VV 2> $CTEST_ERROR_FILE_FLAG 1>$ERROR_FILE_FLAG)

if [ -s $CTEST_ERROR_FILE_FLAG ]; then
echo "Error: Unit Tests Failed"
exit 1
else
echo "All tests where passed!"
fi

# run coverage of those tests and oputput to file
gcovr -r $PROJECT_PATH . >> $ERROR_FILE_FLAG

echo "Runnig: gcovr -r $PROJECT_PATH ."

cat $ERROR_FILE_FLAG

# Find the value of correct coverage
# parse coverage output file and extracts coverage percentage
# grep pulls out the line of the total
# awk prints only the last field (NF = number of fields of the grepped line)
# cut finnaly creates a list using '%' as a delimiter (-d '%') and keeps first value (-f 1)
COVERAGE_RESULT=$(grep "TOTAL" $ERROR_FILE_FLAG | awk '{print $NF}' | cut -d '%' -f 1)

# Coverage lines GT 5
if [ "$(echo "$COVERAGE_RESULT > 5" | bc)" -eq 1 ]; then
echo "Coverage is greater than 5%. Nice!"
exit 0
else
echo "Error: Coverage is less than or equal to 5%"
exit 1
fi

# Upload errors as an artifact, when failed
- uses: actions/upload-artifact@v3
if: failure()
with:
name: Tests or coverage errors!!!
path: ./tests_errors.txt
retention-days: 1
44 changes: 44 additions & 0 deletions .github/actions/documentation/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "Doc check"
description: "Code documentation generation with Doxygen"

runs:
using: "composite"
steps:
- name: "Run doxygen command"
shell: bash
run: |
# We only make check, not changes
DOX_CONF_FILE=$(pwd)/Doxyfile

# Append to DOX_CONF_FILE input source directories, if you have libs, add $(pwd)/lib
{
cat $DOX_CONF_FILE
echo "INPUT" = $(pwd)/src $(pwd)/include
} > $DOX_CONF_FILE

# Generate documentation
# dot -c clears Graphviz configuration, doxygen uses Graphviz for generating graphical representations
sudo dot -c

ERROR_FILE_FLAG=$(pwd)/dox_errors.txt

# create documentation: -s specifies comments of configurations items will be omitted.
# pipe stderr to error file
DOXYGEN_COMMAND=$(doxygen -s $DOX_CONF_FILE 2> $ERROR_FILE_FLAG)

# if error file not empty fail
if [ -s $ERROR_FILE_FLAG ]; then
echo "Error: There are some files that are not documented correctly"
exit 1
else
echo "All files are documented correctly. Niiiceee"
exit 0
fi

# Upload errors as an artifact, when failed
- uses: actions/upload-artifact@v3
if: failure()
with:
name: Doxygen errors!!!
path: ./dox_errors.txt
retention-days: 1
40 changes: 40 additions & 0 deletions .github/actions/style/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "Style check"
description: "Style check using clang-format"

runs:
using: "composite"
steps:
- name: "Run clang-format"
shell: bash
run: |
# We only make check, not changes
# Use the find command with the variable
PROJECT_PATH=$(pwd)

SOURCE_FILES=$(find $PROJECT_PATH/src -type f \( -name "*.cpp" -or -name "*.hpp" -or -name "*.h" -or -name "*.c" \) | tr "\n" " ")
SOURCE_FILES+=$(find $PROJECT_PATH/include -type f \( -name "*.cpp" -or -name "*.hpp" -or -name "*.h" -or -name "*.c" \) | tr "\n" " ")
# If you have a lib, uncomment the following line
# SOURCE_FILES+=$(find $PROJECT_PATH/lib -type f \( -name "*.cpp" -or -name "*.hpp" -or -name "*.h" -or -name "*.c" \) | tr "\n" " ")

ERROR_FILE_FLAG=$PROJECT_PATH/clang-format_errors.txt

echo "Running: clang-format -n $SOURCE_FILES"

CLANG_COMMAND=$(clang-format -n $SOURCE_FILES 2> ${ERROR_FILE_FLAG})

if [ -s $ERROR_FILE_FLAG ]; then
echo "Error: There are some files that are not formatted correctly"
cat $ERROR_FILE_FLAG
exit 1
else
echo "All files are formatted correctly. Niiiceee"
exit 0
fi

# Upload errors as an artifact, when failed
- uses: actions/upload-artifact@v3
if: failure()
with:
name: Clang-format errors!!!
path: ./clang-format_errors.txt
retention-days: 1
Loading
Loading