Skip to content

Commit

Permalink
Merge branch 'release/v1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
truschival committed Jun 8, 2022
2 parents 0c59cd2 + b49e5e2 commit aa35aa5
Show file tree
Hide file tree
Showing 54 changed files with 801 additions and 432 deletions.
195 changes: 195 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
Checks: '-*,
bugprone-argument-comment,
bugprone-bad-signal-to-kill-thread,
bugprone-bool-pointer-implicit-conversion,
bugprone-copy-constructor-init,
bugprone-dangling-handle,
bugprone-fold-init-type,
bugprone-forward-declaration-namespace,
bugprone-inaccurate-erase,
bugprone-incorrect-roundings,
bugprone-infinite-loop,
bugprone-integer-division,
bugprone-macro-repeated-side-effects,
bugprone-misplaced-operator-in-strlen-in-alloc,
bugprone-misplaced-pointer-artithmetic-in-alloc,
bugprone-misplaced-widening-cast,
bugprone-move-forwarding-reference,
bugprone-multiple-statement-macro,
bugprone-parent-virtual-call,
bugprone-posix-return,
bugprone-reserved-identifier,
bugprone-signed-char-misuse,
bugprone-sizeof-container,
bugprone-sizeof-expression,
bugprone-string-constructor,
bugprone-string-integer-assignment,
bugprone-string-literal-with-embedded-nul,
bugprone-suspicious-enum-usage,
bugprone-suspicious-include,
bugprone-suspicious-memset-usage,
bugprone-suspicious-missing-comma,
bugprone-suspicious-string-compare,
bugprone-swapped-arguments,
bugprone-terminating-continue,
bugprone-throw-keyword-missing,
bugprone-too-small-loop-variable,
bugprone-undefined-memory-manipulation,
bugprone-undelegated-constructor,
bugprone-unhandled-self-assignment,
bugprone-unused-raii,
bugprone-unused-return-value,
bugprone-use-after-move,
bugprone-virtual-near-miss,
cert-dcl21-cpp,
cert-dcl50-cpp,
cert-env33-c,
cert-err34-c,
cert-err52-cpp,
cert-flp30-c,
cert-mem57-cpp,
cert-msc50-cpp,
cert-oop58-cpp,
clang-analyzer-core.CallAndMessage,
clang-analyzer-core.DivideZero,
clang-analyzer-core.NonNullParamChecker,
clang-analyzer-core.NullDereference,
clang-analyzer-core.StackAddressEscape,
clang-analyzer-core.UndefinedBinaryOperatorResult,
clang-analyzer-core.uninitialized.ArraySubscript,
clang-analyzer-core.uninitialized.Assign,
clang-analyzer-core.uninitialized.Branch,
clang-analyzer-core.uninitialized.CapturedBlockVariable,
clang-analyzer-core.uninitialized.UndefReturn,
clang-analyzer-core.VLASize,
clang-analyzer-cplusplus.InnerPointer,
clang-analyzer-cplusplus.NewDelete,
clang-analyzer-cplusplus.NewDeleteLeaks,
clang-analyzer-cplusplus.PlacementNewChecker,
clang-analyzer-cplusplus.SelfAssignment,
clang-analyzer-deadcode.DeadStores,
clang-analyzer-optin.cplusplus.VirtualCall,
clang-analyzer-security.insecureAPI.bcmp,
clang-analyzer-security.insecureAPI.bcopy,
clang-analyzer-security.insecureAPI.bzero,
clang-analyzer-security.insecureAPI.getpw,
clang-analyzer-security.insecureAPI.gets,
clang-analyzer-security.insecureAPI.mkstemp,
clang-analyzer-security.insecureAPI.mktemp,
clang-analyzer-security.insecureAPI.rand,
clang-analyzer-security.insecureAPI.strcpy,
clang-analyzer-security.insecureAPI.UncheckedReturn,
clang-analyzer-unix.cstring.BadSizeArg,
clang-analyzer-unix.cstring.NullArg,
clang-analyzer-unix.Malloc,
clang-analyzer-unix.MallocSizeof,
clang-analyzer-unix.MismatchedDeallocator,
clang-analyzer-unix.Vfork,
google-build-explicit-make-pair,
google-build-namespaces,
google-default-arguments,
google-explicit-constructor,
google-readability-avoid-underscore-in-googletest-name,
google-readability-casting,
google-runtime-int,
google-runtime-operator,
hicpp-exception-baseclass,
misc-misplaced-const,
misc-redundant-expression,
misc-static-assert,
misc-throw-by-value-catch-by-reference,
misc-unconventional-assign-operator,
misc-unconventional-assign-operator,
misc-uniqueptr-reset-release,
misc-unused-alias-decls,
misc-unused-parameters,
misc-unused-using-decls,
modernize-avoid-bind,
modernize-loop-convert,
modernize-make-shared,
modernize-make-unique,
modernize-raw-string-literal,
modernize-redundant-void-arg,
modernize-replace-auto-ptr,
modernize-replace-random-shuffle,
modernize-use-bool-literals,
modernize-use-equals-default,
modernize-use-equals-delete,
modernize-use-nullptr,
modernize-use-using,
performance-faster-string-find,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-inefficient-algorithm,
performance-inefficient-vector-operation,
performance-move-constructor-init,
performance-no-automatic-move,
performance-trivially-destructible,
performance-unnecessary-copy-initialization,
readability-avoid-const-params-in-decls,
readability-const-return-type,
readability-container-size-empty,
readability-convert-member-functions-to-static,
readability-deleted-default,
readability-delete-null-pointer,
readability-identifier-naming,
readability-inconsistent-declaration-parameter-name,
readability-make-member-function-const,
readability-misplaced-array-index,
readability-non-const-parameter,
readability-qualified-auto,
readability-redundant-access-specifiers,
readability-redundant-control-flow,
readability-redundant-function-ptr-dereference,
readability-redundant-member-init,
readability-redundant-smartptr-get,
readability-redundant-string-cstr,
readability-redundant-string-init,
readability-simplify-boolean-expr,
readability-simplify-subscript-expr,
readability-static-definition-in-anonymous-namespace,
readability-string-compare,
readability-uniqueptr-delete-release,
zircon-temporary-objects,
'
WarningsAsErrors: '*'

CheckOptions:
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.EnumCase
value: CamelCase
- key: readability-identifier-naming.LocalVariableCase
value: lower_case
- key: readability-identifier-naming.StaticConstantCase
value: aNy_CasE
- key: readability-identifier-naming.MemberCase
value: lower_case
- key: readability-identifier-naming.PrivateMemberPrefix
value: ''
- key: readability-identifier-naming.ProtectedMemberPrefix
value: ''
- key: readability-identifier-naming.PublicMemberCase
value: lower_case
- key: readability-identifier-naming.MethodCase
value: camelBack
- key: readability-identifier-naming.PrivateMethodPrefix
value: ''
- key: readability-identifier-naming.ProtectedMethodPrefix
value: ''
- key: readability-identifier-naming.ParameterPackCase
value: lower_case
- key: readability-identifier-naming.StructCase
value: CamelCase
- key: readability-identifier-naming.TemplateTemplateParameterCase
value: CamelCase
- key: readability-identifier-naming.TemplateUsingCase
value: lower_case
- key: readability-identifier-naming.TypeTemplateParameterCase
value: CamelCase
- key: readability-identifier-naming.TypedefCase
value: CamelCase
- key: readability-identifier-naming.UnionCase
value: CamelCase
- key: readability-identifier-naming.UsingCase
value: CamelCase
24 changes: 23 additions & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@ jobs:
INSTALL_DIR_HOST: /tmp/install
BUILD_DIR: /build
SRC_DIR: /src
BUILD_IMAGE: ruschi/devlinuxqt-pistache
BUILD_IMAGE: ghcr.io/truschival/devlinuxqt-pistache:v1.1.0
CONTAINER_NAME: buildc
TEST_ARTIFACT: test-trace.tgz
INSTALL_DIR: /tmp/install
steps:
- name: Clone Repository
uses: actions/checkout@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.PULL_SECRET }}

- name: Check Environment
run: |
docker --version
Expand All @@ -31,21 +39,25 @@ jobs:
echo "host dir: $BUILD_DIR_HOST"
echo "container build dir: $BUILD_DIR"
echo "container src_dir: $SRC_DIR"
- name: Create build dir
run: |
mkdir -p $BUILD_DIR_HOST
mkdir -p $INSTALL_DIR_HOST
chmod 777 $BUILD_DIR_HOST $INSTALL_DIR_HOST
- name: Pull docker container
run: docker pull $BUILD_IMAGE
timeout-minutes: 5

- name: Start Docker
run: >
docker run -itd -u $UID:$GID --privileged --name $CONTAINER_NAME
-v$GITHUB_WORKSPACE:$SRC_DIR
-v$BUILD_DIR_HOST:$BUILD_DIR
-v$INSTALL_DIR_HOST:$INSTALL_DIR
$BUILD_IMAGE
- name: Configure
run: >
docker exec $CONTAINER_NAME cmake
Expand All @@ -54,43 +66,53 @@ jobs:
-H$SRC_DIR -B$BUILD_DIR
-DBUILD_TESTS=On -DTEST_COVERAGE=On -DBUILD_GTEST_FROM_SRC=On
-DREST_API=On
- name: Build
run: docker exec $CONTAINER_NAME cmake --build $BUILD_DIR --parallel

- name: Get OpenAPI client
run: |
docker exec -w $SRC_DIR $CONTAINER_NAME buildscripts/get_openapi_client.py
- name: Prepare Python
run: |
docker exec -w $SRC_DIR $CONTAINER_NAME python3 -m pip install nulltype
- name: Run tests
run: docker exec -w $BUILD_DIR $CONTAINER_NAME ctest -V

- name: Package Test output for analysis
if: failure()
run: >
tar -C ${{ env.BUILD_DIR_HOST }} -czf ${{ env.BUILD_DIR_HOST }}/${{ env.TEST_ARTIFACT }}
test_trace.log gtest_results.xml
- name: Upload program trace
if: failure()
uses: actions/upload-artifact@v1
with:
name: ${{ env.TEST_ARTIFACT }}
path: ${{ env.BUILD_DIR_HOST }}/${{ env.TEST_ARTIFACT }}

- name: Collect coverage
run: >
docker exec -w $BUILD_DIR $CONTAINER_NAME
lcov --directory .
--capture --output-file $BUILD_DIR/coverage.info
- name: Prune 3rd party code from coverage info
run: >
docker exec -w $BUILD_DIR $CONTAINER_NAME
lcov --remove $BUILD_DIR/coverage.info
--output-file $BUILD_DIR/coverage.info
"/usr/*" "*/GTestExternal/*" "*/__/*"
- name: Upload coverage to codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: /tmp/build/coverage.info

- name: Test make install
run: >
docker exec -w $BUILD_DIR -eDESTDIR=$INSTALL_DIR $CONTAINER_NAME
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/coverity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,22 @@ jobs:
BUILD_DIR_HOST: /tmp/build
BUILD_DIR: /build
SRC_DIR: /src
BUILD_IMAGE: ruschi/devlinuxqt-pistache
BUILD_IMAGE: ghcr.io/truschival/devlinuxqt-pistache:v1.1.0
CONTAINER_NAME: buildc
COVERITY_INSTALL_DIR: /tmp/coverity
COVERITY_RESULT_DIR: cov-int
COVERITY_TARBALL: digitalrooster_coverity.tar.bz2
steps:
- name: Clone Repository
uses: actions/checkout@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.PULL_SECRET }}

- name: Check Environment
run: |
docker --version
Expand All @@ -32,10 +40,12 @@ jobs:
echo "container src_dir: $SRC_DIR"
echo "Coverity tarball:" $COVERITY_TARBALL
echo "Coverity result:" $COVERITY_RESULT_DIR
- name: Create build dir
run: |
mkdir -p $BUILD_DIR_HOST
mkdir -p $COVERITY_INSTALL_DIR
- name: Install Coverity
run: |
wget -q https://scan.coverity.com/download/cxx/linux64 \
Expand All @@ -44,16 +54,19 @@ jobs:
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C $COVERITY_INSTALL_DIR
env:
TOKEN: ${{ secrets.COVERITY_TOKEN }}

- name: Pull docker container
run: docker pull $BUILD_IMAGE
timeout-minutes: 5

- name: Start Docker
run: >
docker run -itd -u $UID:$GID --privileged --name $CONTAINER_NAME
-v$GITHUB_WORKSPACE:$SRC_DIR
-v$BUILD_DIR_HOST:$BUILD_DIR
-v$COVERITY_INSTALL_DIR:/coverity
$BUILD_IMAGE
- name: Configure (Release, No Tests)
run: >
docker exec $CONTAINER_NAME cmake
Expand All @@ -62,6 +75,7 @@ jobs:
-H$SRC_DIR -B$BUILD_DIR
-DBUILD_TESTS=Off -DTEST_COVERAGE=Off -DBUILD_GTEST_FROM_SRC=Off
-DREST_API=On
- name: Gather Coverity build info
run: >
docker exec -w $BUILD_DIR $CONTAINER_NAME
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules/)
# Project Name
MESSAGE( STATUS "Running ${CMAKE_COMMAND} v${CMAKE_VERSION}" )
PROJECT(DigitalRooster
VERSION 1.1.0
VERSION 1.2.0
DESCRIPTION "A digital alarm clock and podcast player"
LANGUAGES CXX C
)
Expand Down
7 changes: 5 additions & 2 deletions REST/ApiHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <memory>
#include <string>
#include <optional>

#include <pistache/http.h>
#include <pistache/router.h>
Expand Down Expand Up @@ -95,12 +96,14 @@ QJsonObject DigitalRooster::REST::qjson_form_std_string(

/*****************************************************************************/
int DigitalRooster::REST::get_val_from_query_within_range(
const Pistache::Optional<std::string>& query, int min, int max) {
const std::optional<std::string>& query, int min, int max) {
qCDebug(CLASS_LC) << Q_FUNC_INFO;

int val = min;
try {
val = std::stoi(query.get());
val = std::stoi(query.value());
} catch (const std::bad_optional_access& e) {
qCCritical(CLASS_LC) << Q_FUNC_INFO << e.what();
} catch (const std::invalid_argument& e) {
qCCritical(CLASS_LC) << Q_FUNC_INFO << e.what();
}
Expand Down
Loading

0 comments on commit aa35aa5

Please sign in to comment.