diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 5612b4cd55..6c8ce5e2da 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -13,6 +13,13 @@ on: pull_request: # run pipeline on merge queue merge_group: + # run pipeline from another workflow + workflow_call: + inputs: + target: + type: string + description: "The CMake target to run (e.g.: all)" + required: true # run this workflow manually from the Actions tab workflow_dispatch: inputs: @@ -23,7 +30,8 @@ on: options: - all - power_grid_model_c - - power_grid_model_cpp + - power_grid_model_api_tests + - all power_grid_model_benchmark_cpp required: true concurrency: @@ -62,12 +70,12 @@ jobs: brew install boost eigen nlohmann-json msgpack-cxx doctest - name: Set build target in case of push - if: github.event_name != 'workflow_dispatch' + if: github.event_name != 'workflow_dispatch' && github.event.event_name != 'workflow_call' run: | - echo "TARGET=power_grid_model_c" >> $GITHUB_ENV + echo "TARGET=power_grid_model_api_tests" >> $GITHUB_ENV - name: Set build target in case of workflow dispatch - if: github.event_name == 'workflow_dispatch' + if: github.event_name == 'workflow_dispatch' || github.event.event_name == 'workflow_call' run: | echo "TARGET=${{ github.event.inputs.target }}" >> $GITHUB_ENV diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9d10b81b1f..d9cde12fa3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,6 +14,8 @@ on: pull_request: # run pipeline on merge queue merge_group: + # run pipeline from another workflow + workflow_call: # run this workflow manually from the Actions tab workflow_dispatch: inputs: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000000..688df5526c --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,25 @@ +# SPDX-FileCopyrightText: Contributors to the Power Grid Model project +# +# SPDX-License-Identifier: MPL-2.0 + +name: Nightly build + +# Controls when the workflow will run +on: + workflow_dispatch: + schedule: + - cron: "0 2 * * *" # Based on UTC time + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + main: + uses: "./.github/workflows/main.yml" + + clang-tidy: + uses: "./.github/workflows/clang-tidy.yml" + with: + target: power_grid_model_c + # target: "all power_grid_model_benchmark_cpp" # TODO(mgovers): re-enable when more clang-tidy stuff is fixed diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp index 861d69cb2b..00d02a04bd 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/deserializer.hpp @@ -385,7 +385,7 @@ class Deserializer { Deserializer& operator=(Deserializer const&) = delete; // movable Deserializer(Deserializer&&) = default; - Deserializer& operator=(Deserializer&&) = default; + Deserializer& operator=(Deserializer&&) noexcept = default; // destructor ~Deserializer() = default; diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/serializer.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/serializer.hpp index 81b00977c0..35f1b3717d 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/serializer.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/serialization/serializer.hpp @@ -23,7 +23,7 @@ #include // custom packers -namespace msgpack { +namespace msgpack { // NOLINT(modernize-concat-nested-namespaces) MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) { namespace adaptor { diff --git a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp index 9f96024ef1..c4f9cd7cad 100644 --- a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp +++ b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/buffer.hpp @@ -28,8 +28,8 @@ class Buffer { void set_nan(Idx buffer_offset) { set_nan(*this, buffer_offset, 1); } void set_nan(Idx buffer_offset, Idx size) { set_nan(*this, buffer_offset, size); } - static void set_value(MetaAttribute const* attribute, Buffer const& buffer, RawDataConstPtr src_ptr, - Idx buffer_offset, Idx size, Idx src_stride) { + static void set_value(MetaAttribute const* attribute, Buffer& buffer, // NOSONAR: no reference-to-const + RawDataConstPtr src_ptr, Idx buffer_offset, Idx size, Idx src_stride) { buffer.handle_.call_with(PGM_buffer_set_value, attribute, buffer.buffer_.get(), src_ptr, buffer_offset, size, src_stride); } diff --git a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp index 4f41128510..0398603048 100644 --- a/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp +++ b/power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp @@ -80,14 +80,16 @@ class DatasetWritable { static DatasetInfo const& get_info(DatasetWritable const& dataset) { return dataset.info_; } DatasetInfo const& get_info() const { return get_info(*this); } - static void set_buffer(DatasetWritable& dataset, std::string const& component, Idx* indptr, RawDataPtr data) { + static void set_buffer(DatasetWritable& dataset, // NOSONAR: no reference-to-const + std::string const& component, Idx* indptr, RawDataPtr data) { dataset.handle_.call_with(PGM_dataset_writable_set_buffer, dataset.dataset_, component.c_str(), indptr, data); } void set_buffer(std::string const& component, Idx* indptr, RawDataPtr data) { set_buffer(*this, component, indptr, data); } - static void set_buffer(DatasetWritable& dataset, std::string const& component, Idx* indptr, Buffer const& data) { + static void set_buffer(DatasetWritable& dataset, // NOSONAR: no reference-to-const + std::string const& component, Idx* indptr, Buffer const& data) { dataset.handle_.call_with(PGM_dataset_writable_set_buffer, dataset.dataset_, component.c_str(), indptr, data.get()); } @@ -95,8 +97,8 @@ class DatasetWritable { set_buffer(*this, component, indptr, data); } - static void set_attribute_buffer(DatasetWritable& dataset, std::string const& component, - std::string const& attribute, RawDataPtr data) { + static void set_attribute_buffer(DatasetWritable& dataset, // NOSONAR: no reference-to-const + std::string const& component, std::string const& attribute, RawDataPtr data) { dataset.handle_.call_with(PGM_dataset_writable_set_attribute_buffer, dataset.dataset_, component.c_str(), attribute.c_str(), data); } @@ -104,8 +106,8 @@ class DatasetWritable { set_attribute_buffer(*this, component, attribute, data); } - static void set_attribute_buffer(DatasetWritable& dataset, std::string const& component, - std::string const& attribute, Buffer const& data) { + static void set_attribute_buffer(DatasetWritable& dataset, // NOSONAR: no reference-to-const + std::string const& component, std::string const& attribute, Buffer const& data) { dataset.handle_.call_with(PGM_dataset_writable_set_attribute_buffer, dataset.dataset_, component.c_str(), attribute.c_str(), data.get()); } @@ -127,43 +129,43 @@ class DatasetMutable { RawMutableDataset* get() const { return dataset_.get(); } - static void add_buffer(DatasetMutable const& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, RawDataPtr data) { + static void add_buffer(DatasetMutable& dataset, // NOSONAR: no reference-to-const + std::string const& component, Idx elements_per_scenario, Idx total_elements, + Idx const* indptr, RawDataPtr data) { dataset.handle_.call_with(PGM_dataset_mutable_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data); } void add_buffer(std::string const& component, Idx elements_per_scenario, Idx total_elements, Idx const* indptr, - RawDataPtr data) { // NOSONAR: no const + RawDataPtr data) { add_buffer(*this, component, elements_per_scenario, total_elements, indptr, data); } - static void add_buffer(DatasetMutable const& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, Buffer const& data) { + static void add_buffer(DatasetMutable& dataset, // NOSONAR: no reference-to-const + std::string const& component, Idx elements_per_scenario, Idx total_elements, + Idx const* indptr, Buffer const& data) { dataset.handle_.call_with(PGM_dataset_mutable_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data.get()); } void add_buffer(std::string const& component, Idx elements_per_scenario, Idx total_elements, Idx const* indptr, - Buffer const& data) { // NOSONAR: no const + Buffer const& data) { add_buffer(*this, component, elements_per_scenario, total_elements, indptr, data); } - static void add_attribute_buffer(DatasetMutable const& dataset, std::string const& component, - std::string const& attribute, RawDataPtr data) { + static void add_attribute_buffer(DatasetMutable& dataset, // NOSONAR: no reference-to-const + std::string const& component, std::string const& attribute, RawDataPtr data) { dataset.handle_.call_with(PGM_dataset_mutable_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data); } - void add_attribute_buffer(std::string const& component, std::string const& attribute, - RawDataPtr data) { // NOSONAR: no const + void add_attribute_buffer(std::string const& component, std::string const& attribute, RawDataPtr data) { add_attribute_buffer(*this, component, attribute, data); } - static void add_attribute_buffer(DatasetMutable const& dataset, std::string const& component, - std::string const& attribute, Buffer const& data) { + static void add_attribute_buffer(DatasetMutable& dataset, // NOSONAR: no reference-to-const + std::string const& component, std::string const& attribute, Buffer const& data) { dataset.handle_.call_with(PGM_dataset_mutable_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data.get()); } - void add_attribute_buffer(std::string const& component, std::string const& attribute, - Buffer const& data) { // NOSONAR: no const: no const + void add_attribute_buffer(std::string const& component, std::string const& attribute, Buffer const& data) { add_attribute_buffer(*this, component, attribute, data); } @@ -190,43 +192,43 @@ class DatasetConst { RawConstDataset* get() const { return dataset_.get(); } - static void add_buffer(DatasetConst const& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, RawDataConstPtr data) { + static void add_buffer(DatasetConst& dataset, // NOSONAR: no reference-to-const + std::string const& component, Idx elements_per_scenario, Idx total_elements, + Idx const* indptr, RawDataConstPtr data) { dataset.handle_.call_with(PGM_dataset_const_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data); } void add_buffer(std::string const& component, Idx elements_per_scenario, Idx total_elements, Idx const* indptr, - RawDataConstPtr data) { // NOSONAR: no const + RawDataConstPtr data) { add_buffer(*this, component, elements_per_scenario, total_elements, indptr, data); } - static void add_buffer(DatasetConst const& dataset, std::string const& component, Idx elements_per_scenario, - Idx total_elements, Idx const* indptr, Buffer const& data) { + static void add_buffer(DatasetConst& dataset, // NOSONAR: no reference-to-const + std::string const& component, Idx elements_per_scenario, Idx total_elements, + Idx const* indptr, Buffer const& data) { dataset.handle_.call_with(PGM_dataset_const_add_buffer, dataset.dataset_.get(), component.c_str(), elements_per_scenario, total_elements, indptr, data.get()); } void add_buffer(std::string const& component, Idx elements_per_scenario, Idx total_elements, Idx const* indptr, - Buffer const& data) { // NOSONAR: no const + Buffer const& data) { add_buffer(*this, component, elements_per_scenario, total_elements, indptr, data); } - static void add_attribute_buffer(DatasetConst const& dataset, std::string const& component, - std::string const& attribute, RawDataConstPtr data) { + static void add_attribute_buffer(DatasetConst& dataset, // NOSONAR: no reference-to-const + std::string const& component, std::string const& attribute, RawDataConstPtr data) { dataset.handle_.call_with(PGM_dataset_const_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data); } - void add_attribute_buffer(std::string const& component, std::string const& attribute, - RawDataConstPtr data) { // NOSONAR: no const + void add_attribute_buffer(std::string const& component, std::string const& attribute, RawDataConstPtr data) { add_attribute_buffer(*this, component, attribute, data); } - static void add_attribute_buffer(DatasetConst const& dataset, std::string const& component, - std::string const& attribute, Buffer const& data) { + static void add_attribute_buffer(DatasetConst& dataset, // NOSONAR: no reference-to-const + std::string const& component, std::string const& attribute, Buffer const& data) { dataset.handle_.call_with(PGM_dataset_const_add_attribute_buffer, dataset.dataset_.get(), component.c_str(), attribute.c_str(), data.get()); } - void add_attribute_buffer(std::string const& component, std::string const& attribute, - Buffer const& data) { // NOSONAR: no const + void add_attribute_buffer(std::string const& component, std::string const& attribute, Buffer const& data) { add_attribute_buffer(*this, component, attribute, data); } diff --git a/tests/benchmark_cpp/CMakeLists.txt b/tests/benchmark_cpp/CMakeLists.txt index 22ee5c544f..b42cc1cda3 100644 --- a/tests/benchmark_cpp/CMakeLists.txt +++ b/tests/benchmark_cpp/CMakeLists.txt @@ -6,7 +6,7 @@ set(PROJECT_SOURCES benchmark.cpp ) -add_executable(power_grid_model_benchmark_cpp ${PROJECT_SOURCES}) +add_executable(power_grid_model_benchmark_cpp EXCLUDE_FROM_ALL ${PROJECT_SOURCES}) target_link_libraries(power_grid_model_benchmark_cpp PRIVATE power_grid_model ) diff --git a/tests/native_api_tests/test_api_model.cpp b/tests/native_api_tests/test_api_model.cpp index 8deba7a596..9d2249d424 100644 --- a/tests/native_api_tests/test_api_model.cpp +++ b/tests/native_api_tests/test_api_model.cpp @@ -222,7 +222,7 @@ TEST_CASE("API Model") { } SUBCASE("Copy model") { - Model model_copy{model}; + auto const model_copy = Model{model}; model_copy.calculate(options, single_output_dataset); node_output.get_value(PGM_def_sym_output_node_id, node_result_id.data(), -1); node_output.get_value(PGM_def_sym_output_node_energized, node_result_energized.data(), 0, -1); diff --git a/tests/native_api_tests/test_api_serialization.cpp b/tests/native_api_tests/test_api_serialization.cpp index 7eb77e3cdb..fe1b6a8a2e 100644 --- a/tests/native_api_tests/test_api_serialization.cpp +++ b/tests/native_api_tests/test_api_serialization.cpp @@ -192,7 +192,7 @@ TEST_CASE("API Serialization and Deserialization") { ID node_id_2{0}; double node_u_rated_2; // set buffer - Buffer source_buffer_columnar{PGM_def_input_source, 1}; + Buffer const source_buffer_columnar{PGM_def_input_source, 1}; dataset.set_buffer("node", nullptr, nullptr); dataset.set_attribute_buffer("node", "id", &node_id_2); dataset.set_attribute_buffer("node", "u_rated", &node_u_rated_2);