Skip to content

Commit

Permalink
build: Enable cppCheck tests on ci (#2048)
Browse files Browse the repository at this point in the history
  • Loading branch information
rprospero authored Feb 4, 2025
1 parent a61638e commit 6d6355d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/qc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,11 @@ runs:
git diff
# Run quiet diff to fail the job if any changes were made (see man git-diff)
git diff --quiet
- name: Cpp Check
shell: bash
run: |
set -ex
MAX_ERRORS=3
MAX_WARNINGS=1
nix develop -L --command scripts/cppCheckTest.sh $MAX_ERRORS $MAX_WARNINGS
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
cmake-format
cmake-language-server
conan
cppcheck
direnv
gdb
gtk3
Expand Down
30 changes: 30 additions & 0 deletions scripts/cppCheckTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

set -e

if [ "$#" -ne 2 ]; then
echo "Usage: $0 MAX_ERRORS MAX_WARNINGS" >&2
exit 1
fi

MAX_ERRORS=$1
MAX_WARNINGS=$2

# Use or true because the script should continue even if cppcheck fails
cppcheck --check-level=exhaustive src 2> check.log || true

ERRORS=$( cat check.log | grep -c "error:" )
WARNINGS=$( cat check.log | grep -c "warning:" )

if [ "$ERRORS" -gt "$MAX_ERRORS" ]; then
cat check.log
echo "Wanted $MAX_ERRORS errors, but found $ERRORS"
false
else

if [ "$WARNINGS" -gt "$MAX_WARNINGS" ]; then
cat check.log
echo "Wanted $MAX_WARNINGS warnings, but found $WARNINGS"
false
fi
fi
6 changes: 3 additions & 3 deletions src/classes/partialSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ void PartialSet::reset()
ParallelPolicies::par, 0, atomTypeMix_.nItems(),
[&](int i, int j)
{
std::fill(partials_[{i, j}].values().begin(), partials_[{i, j}].values().end(), 0.0);
std::fill(boundPartials_[{i, j}].values().begin(), boundPartials_[{i, j}].values().end(), 0.0);
std::fill(unboundPartials_[{i, j}].values().begin(), unboundPartials_[{i, j}].values().end(), 0.0);
std::ranges::fill(partials_[{i, j}].values(), 0.0);
std::ranges::fill(boundPartials_[{i, j}].values(), 0.0);
std::ranges::fill(unboundPartials_[{i, j}].values(), 0.0);
emptyBoundPartials_[{i, j}] = true;
},
half_);
Expand Down
4 changes: 0 additions & 4 deletions src/data/sginfo/sgsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
#include <stdio.h>
#include <stdlib.h>

#ifdef APP_INCLUDE
#include APP_INCLUDE
#endif

#ifndef AppMalloc
#define AppMalloc(ptr, n) (ptr) = malloc((n) * sizeof(*(ptr)))
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/gui/addConfigurationDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ void AddConfigurationDialog::finalise()

// Add a GeneralRegion node
regionNode = generator.createRootNode<GeneralRegionGeneratorNode>({});
if (!regionNode)
Messenger::exception("Failed to create root node");
regionNode->keywords().set("Tolerance", 5.0);
}
else
Expand Down

1 comment on commit 6d6355d

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 6d6355d Previous: 681f80a Ratio
BM_Box_MinimumVector<CubicBox> 12.425796699429297 ns/iter 5.604678665837181 ns/iter 2.22
BM_HistogramBinning_1d/16777216 28.44803714477578 ns/iter 9.875267123828793 ns/iter 2.88
BM_HistogramBinning_2d/16777216 52.003089631797685 ns/iter 20.265535833198363 ns/iter 2.57

This comment was automatically generated by workflow using github-action-benchmark.

CC: @disorderedmaterials/dissolve-devs

Please sign in to comment.