From faf619fcd177c0ef49ff4a2c9d97765b90b856a0 Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Tue, 17 Sep 2024 11:51:33 -0300 Subject: [PATCH 1/4] [CONFIG] [make] "prebuild" simplified. * Redundant call to cmake removed * "Export compile commands" moved to config file * cppcheck exhaustive mode enabled. --- CMakeLists.txt | 4 ++-- CMakePresets.json | 1 - Makefile | 14 ++++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea88d32..817f563 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,8 @@ list(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure") include(CTest) set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED on) -set(VCPKG_MANIFEST_INSTALL OFF) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) SET(GCC_COVERAGE_COMPILE_FLAGS "-fsanitize=address -fprofile-arcs -ftest-coverage -g -O0") SET(GCC_COVERAGE_LINK_FLAGS "--coverage") diff --git a/CMakePresets.json b/CMakePresets.json index 79a84d0..0fc602c 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -10,7 +10,6 @@ }, "generator": "Unix Makefiles", "binaryDir": "${sourceDir}/build/default" - } ] } diff --git a/Makefile b/Makefile index 318785b..7d025b3 100644 --- a/Makefile +++ b/Makefile @@ -55,9 +55,10 @@ clean: touch ./coverage/.gitkeep sh -c "rm -fr -v ./vcpkg_installed" || true -build: dependencies - cmake --preset debug -B build && \ - cmake --preset debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 build && \ +prebuild: dependencies + cmake --preset debug -B build + +build: prebuild cmake --build build --verbose dependencies: @@ -72,17 +73,18 @@ lint/yaml: lint: lint/markdown lint/yaml test/styling test/static -test/static: +test/static: prebuild cppcheck \ + --project=build/compile_commands.json \ --enable=all \ + --check-level=exhaustive \ --std=c++17 \ --library=posix \ --inconclusive \ --inline-suppr \ --error-exitcode=13 \ --suppress=missingIncludeSystem \ - --showtime=summary \ - src/ + --showtime=summary test/styling: clang-format --dry-run --Werror $(FILES) From 758805ca8e7817f048a234806c4d2c64872b880d Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Tue, 17 Sep 2024 11:52:59 -0300 Subject: [PATCH 2/4] [BUGFIX] cppcheck static check fix: [funcArgNamesDifferent] --- .../include/exercises/hackerrank/warmup/mini_max_sum.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/exercises/include/exercises/hackerrank/warmup/mini_max_sum.hpp b/src/lib/exercises/include/exercises/hackerrank/warmup/mini_max_sum.hpp index 94b890a..561aa97 100644 --- a/src/lib/exercises/include/exercises/hackerrank/warmup/mini_max_sum.hpp +++ b/src/lib/exercises/include/exercises/hackerrank/warmup/mini_max_sum.hpp @@ -5,5 +5,5 @@ namespace hackerrank::warmup { std::string miniMaxSumCalculate(const std::vector &arr); -void miniMaxSum(const std::vector &ar); +void miniMaxSum(const std::vector &arr); } // namespace hackerrank::warmup From a5e7b6c1b890c7a1b621116fae450b7a4b1935eb Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Tue, 17 Sep 2024 13:11:56 -0300 Subject: [PATCH 3/4] [CONFIG] [Github Actions] build dependencies simplified. --- .github/workflows/clang-format.yml | 7 ++++++- .github/workflows/codeql.yml | 10 ++-------- .github/workflows/cpp-coverage.yml | 10 ++-------- .github/workflows/cpp.yml | 10 ++-------- .github/workflows/cppcheck.yml | 16 ++++++++++++++-- 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index e782239..e98df2d 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -26,8 +26,13 @@ jobs: sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main" sudo apt-get -y update sudo apt-get -y install --no-install-recommends --no-install-suggests clang-format + # yamllint enable rule:line-length + + - name: Check Tools + run: | + make --version + cmake --version clang-format --version - # yamllint enable rule:line-length - name: Style Check run: make test/styling diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 96a14e0..500586b 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -81,8 +81,7 @@ jobs: - name: Install dependencies run: | - vcpkg --x-wait-for-lock integrate install - vcpkg --x-wait-for-lock install + make dependencies # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL @@ -112,12 +111,7 @@ jobs: shell: bash run: | export VCPKG_ROOT=/usr/local/share/vcpkg - cmake --preset debug -B build - cmake --preset debug \ - -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake \ - -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \ - build - cmake --build build --verbose + make build - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/cpp-coverage.yml b/.github/workflows/cpp-coverage.yml index bb16652..cefe1fe 100644 --- a/.github/workflows/cpp-coverage.yml +++ b/.github/workflows/cpp-coverage.yml @@ -32,19 +32,13 @@ jobs: - name: Install dependencies run: | - vcpkg --x-wait-for-lock integrate install - vcpkg --x-wait-for-lock install + make dependencies # yamllint disable rule:line-length - name: Build run: | export VCPKG_ROOT=/usr/local/share/vcpkg - cmake --preset debug -B build - cmake --preset debug \ - -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake \ - -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \ - build - cmake --build build --verbose + make build # yamllint enable rule:line-length - name: Test / Coverage diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index bda4b5a..7bfd3b9 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -34,19 +34,13 @@ jobs: - name: Install dependencies run: | - vcpkg --x-wait-for-lock integrate install - vcpkg --x-wait-for-lock install + make dependencies # yamllint disable rule:line-length - name: Build run: | export VCPKG_ROOT=/usr/local/share/vcpkg - cmake --preset debug -B build - cmake --preset debug \ - -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake \ - -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \ - build - cmake --build build --verbose + make build # yamllint enable rule:line-length - name: Test diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml index 44c53d1..d4b0838 100644 --- a/.github/workflows/cppcheck.yml +++ b/.github/workflows/cppcheck.yml @@ -19,11 +19,23 @@ jobs: - name: Checkout repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 - - name: Install dependencies + - name: Install tools run: | sudo apt-get update sudo apt-get install cppcheck + + - name: Check Tools + run: | + make --version + cmake --version + vcpkg --version cppcheck --version + - name: Install dependencies + run: | + make dependencies + - name: Lint - run: make test/static + run: | + export VCPKG_ROOT=/usr/local/share/vcpkg + make test/static From 229048d569d6e0cb4a73a1d5764b70ec8fdb6521 Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Tue, 17 Sep 2024 12:51:32 -0300 Subject: [PATCH 4/4] [CONFIG] [Github Actions] [Docker] cppcheck tool updated version installed from snap instead of apt. --- .github/workflows/cppcheck.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml index d4b0838..e4020f1 100644 --- a/.github/workflows/cppcheck.yml +++ b/.github/workflows/cppcheck.yml @@ -21,8 +21,7 @@ jobs: - name: Install tools run: | - sudo apt-get update - sudo apt-get install cppcheck + sudo snap install cppcheck - name: Check Tools run: |