Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: try out Trunk Check #259

Closed
wants to merge 7 commits into from
Closed
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
43 changes: 43 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Checks: >-
*
- llvmlibc-callee-namespace #
# bugprone-*,
# cppcoreguidelines-*,
# google-*,
# misc-*,
# modernize-*,
# performance-*,
# readability-*,
# -bugprone-lambda-function-name,
# -bugprone-reserved-identifier,
# -cppcoreguidelines-avoid-goto,
# -cppcoreguidelines-avoid-magic-numbers,
# -cppcoreguidelines-avoid-non-const-global-variables,
# -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
# -cppcoreguidelines-pro-type-vararg,
# -google-readability-braces-around-statements,
# -google-readability-function-size,
# -misc-no-recursion,
# -modernize-return-braced-init-list,
# -modernize-use-nodiscard,
# -modernize-use-trailing-return-type,
# -performance-unnecessary-value-param,
# -readability-magic-numbers,

CheckOptions:
- key: readability-function-cognitive-complexity.Threshold
value: 100
- key: readability-function-cognitive-complexity.IgnoreMacros
value: true
# Set naming conventions for your style below (there are dozens of naming settings possible):
# See https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-naming.html
- key: readability-identifier-naming.EnumConstantCase
value: UPPER_CASE
# - key: readability-identifier-naming.ClassCase
# value: CamelCase
# - key: readability-identifier-naming.NamespaceCase
# value: lower_case
# - key: readability-identifier-naming.PrivateMemberSuffix
# value: _
# - key: readability-identifier-naming.StructCase
# value: CamelCase
8 changes: 8 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*out
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
2 changes: 2 additions & 0 deletions .trunk/configs/.isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[settings]
profile=black
10 changes: 10 additions & 0 deletions .trunk/configs/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Autoformatter friendly markdownlint config (all formatting rules disabled)
default: true
blank_lines: false
bullet: false
html: false
indentation: false
line_length: false
spaces: false
url: false
whitespace: false
7 changes: 7 additions & 0 deletions .trunk/configs/.shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enable=all
source-path=SCRIPTDIR
disable=SC2154

# If you're having issues with shellcheck following source, disable the errors via:
# disable=SC1090
# disable=SC1091
10 changes: 10 additions & 0 deletions .trunk/configs/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rules:
quoted-strings:
required: only-when-needed
extra-allowed: ["{|}"]
empty-values:
forbid-in-block-mappings: true
forbid-in-flow-mappings: true
key-duplicates: {}
octal-values:
forbid-implicit-octal: true
5 changes: 5 additions & 0 deletions .trunk/configs/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Generic, formatter-friendly config.
select = ["B", "D3", "E", "F"]

# Never enforce `E501` (line length violations). This should be handled by formatters.
ignore = ["E501"]
27 changes: 27 additions & 0 deletions .trunk/setup-ci/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Trunk Check setup
description: Set up dependencies for Trunk Check

runs:
using: composite
steps:
- name: Install big dependencies
shell: bash
run: |
apt install libboost-all-dev libssl-dev libsqlite3-dev
- name: Checkout `everest-cmake`
shell: bash
run: |
cd ..
git clone https://github.com/EVerest/everest-cmake
- name: Run cmake
shell: bash
run: |
cmake -B build/ \
-D CMAKE_CXX_COMPILER=clang++-15 -D CXX_STANDARD=17 \
-D CMAKE_EXPORT_COMPILE_COMMANDS=1 \
-D CMAKE_BUILD_TYPE=Debug \
-D CMAKE_GENERATOR="Unix Makefiles"

- name: Run make
shell: bash
run: make -j$(nproc) install
41 changes: 41 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.17.2
plugins:
sources:
- id: trunk
ref: v1.2.6
uri: https://github.com/trunk-io/plugins
runtimes:
enabled:
- [email protected]
- [email protected]
- [email protected]
lint:
enabled:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- git-diff-check
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
actions:
disabled:
- trunk-announce
- trunk-check-pre-push
- trunk-fmt-pre-commit
enabled:
- trunk-upgrade-available
3 changes: 3 additions & 0 deletions lib/ocpp/v16/charge_point_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ void ChargePointImpl::clock_aligned_meter_values_sample() {
for (int32_t connector = 1; connector < this->configuration->getNumberOfConnectors() + 1; connector++) {
auto meter_value = this->get_latest_meter_value(
connector, this->configuration->getMeterValuesAlignedDataVector(), ReadingContext::Sample_Clock);

meter_value.value(); // <- this should trigger multiple clang-tidy warnings

if (meter_value.has_value()) {
if (this->transaction_handler->transaction_active(connector)) {
this->transaction_handler->get_transaction(connector)->add_meter_value(meter_value.value());
Expand Down