Skip to content

Commit 15ee433

Browse files
kenneth-jiaalex-q-chen
authored andcommitted
Update CI and fix failures
1 parent a146d10 commit 15ee433

18 files changed

+59
-41
lines changed

.clang-tidy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Checks: "*,\
44
-llvmlibc-restrict-system-libc-headers,\
55
-llvmlibc-callee-namespace,\
66
-llvmlibc-implementation-in-namespace,\
7+
-llvmlibc-inline-function-decl,\
78
-altera-*,\
89
-fuchsia-*,\
910
-google-readability-namespace-comments,\
@@ -14,6 +15,7 @@ Checks: "*,\
1415
-modernize-deprecated-headers,\
1516
-modernize-use-trailing-return-type,\
1617
-modernize-concat-nested-namespaces,\
18+
-modernize-type-traits,\
1719
-hicpp-special-member-functions,\
1820
-hicpp-vararg,\
1921
-hicpp-no-malloc,\
@@ -36,15 +38,20 @@ Checks: "*,\
3638
-cppcoreguidelines-pro-type-union-access,\
3739
-misc-non-private-member-variables-in-classes,\
3840
-misc-no-recursion,\
41+
-misc-include-cleaner,\
3942
-readability-magic-numbers,\
4043
-readability-implicit-bool-conversion,\
4144
-readability-braces-around-statements,\
4245
-readability-isolate-declaration,\
4346
-readability-identifier-length,\
4447
-readability-function-cognitive-complexity,\
48+
-readability-avoid-nested-conditional-operator,\
4549
-bugprone-unused-return-value,\
4650
-bugprone-easily-swappable-parameters,\
4751
-bugprone-exception-escape,\
52+
-bugprone-optional-value-conversion,\
4853
-cert-err58-cpp,\
54+
-performance-avoid-endl,\
55+
-performance-enum-size,\
4956
-clang-analyzer-optin.performance.Padding"
5057

.github/workflows/kafka_api_bazel_build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
env:
1010
KAFKA_SRC_LINK: https://archive.apache.org/dist/kafka/3.3.1/kafka_2.13-3.3.1.tgz
1111
CPU_CORE_NUM: 2
12-
LIBRDKAFKA_TAG: v2.0.2
12+
LIBRDKAFKA_TAG: v2.4.0
1313

1414
jobs:
1515
kafka-api-bazel-build:

.github/workflows/kafka_api_ci_tests.yml

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
env:
1010
KAFKA_SRC_LINK: https://archive.apache.org/dist/kafka/3.3.1/kafka_2.13-3.3.1.tgz
1111
CPU_CORE_NUM: 2
12-
LIBRDKAFKA_TAG: v2.0.2
12+
LIBRDKAFKA_TAG: v2.4.0
1313
BUILD_SUB_DIR: builds/sub-build
1414

1515
jobs:
@@ -49,48 +49,48 @@ jobs:
4949
test-labels: unit|integration
5050
enable-ut-stubs: true
5151

52-
- os: ubuntu-22.04
52+
- os: ubuntu-24.04
5353
build-cxx: g++
5454
build-type: Release
5555
test-labels: robustness
5656

57-
- os: ubuntu-22.04
57+
- os: ubuntu-24.04
5858
build-cxx: g++
5959
build-type: Release
6060
cxx-standard: 14
6161
test-labels: unit|integration
6262

63-
- os: ubuntu-22.04
63+
- os: ubuntu-24.04
6464
build-cxx: g++
6565
check-option: asan
6666
test-labels: unit|integration
6767

68-
- os: ubuntu-22.04
68+
- os: ubuntu-24.04
6969
build-cxx: g++
7070
check-option: tsan
7171
test-labels: unit|integration
7272

73-
- os: ubuntu-22.04
73+
- os: ubuntu-24.04
7474
build-cxx: g++
7575
check-option: ubsan
7676
test-labels: unit|integration
7777

78-
- os: ubuntu-22.04
78+
- os: ubuntu-24.04
7979
build-cxx: clang++
8080
test-labels: unit|integration
8181
generate-doc: true
8282
with-installation: true
8383

84-
- os: ubuntu-22.04
84+
- os: ubuntu-24.04
8585
build-cxx: clang++
8686
check-option: clang-tidy
8787
enable-ut-stubs: true
8888

89-
- os: ubuntu-20.04
89+
- os: ubuntu-22.04
9090
build-cxx: g++
9191
test-labels: unit|integration
9292

93-
- os: ubuntu-20.04
93+
- os: ubuntu-22.04
9494
build-cxx: clang++
9595
test-labels: robustness
9696

@@ -155,8 +155,7 @@ jobs:
155155
156156
# 6. Install tools to generate document
157157
if [ ${GENERATE_DOC} ]; then
158-
sudo apt install -y python3-pip
159-
sudo pip3 install markdown
158+
sudo apt install -y python3-markdown
160159
sudo apt install -y doxygen
161160
fi
162161
@@ -300,15 +299,17 @@ jobs:
300299
301300
# Install googletest
302301
vcpkg install gtest
303-
cp -v "C:\VCPKG\INSTALLED\x86-windows\lib\manual-link\gtest_main*" "C:\VCPKG\INSTALLED\x86-windows\lib\"
304-
cp -v "C:\VCPKG\INSTALLED\x86-windows\lib\manual-link\gtest_main*" "C:\VCPKG\INSTALLED\x86-windows\lib\"
302+
303+
cp -v "C:\VCPKG\INSTALLED\x64-windows\lib\manual-link\gtest_main*" "C:\VCPKG\INSTALLED\x64-windows\lib\"
304+
cp -v "C:\VCPKG\INSTALLED\x64-windows\lib\manual-link\gtest_main*" "C:\VCPKG\INSTALLED\x64-windows\lib\"
305305
306306
# Install boost headers/libraries
307307
vcpkg install boost-optional
308308
vcpkg install boost-algorithm
309309
vcpkg install boost-program-options
310310
311-
cp -v "C:\VCPKG\INSTALLED\x86-windows\lib\boost_program_options-vc140-mt.lib" "C:\VCPKG\INSTALLED\x86-windows\lib\boost_program_options.lib"
311+
ls "C:\VCPKG\INSTALLED\x64-windows\lib"
312+
cp -v "C:\VCPKG\INSTALLED\x64-windows\lib\boost_program_options-vc144-mt-x64-1_85.lib" "C:\VCPKG\INSTALLED\x64-windows\lib\boost_program_options.lib"
312313
313314
# Install rapidjson
314315
vcpkg install rapidjson
@@ -319,13 +320,13 @@ jobs:
319320
run: |
320321
cd $Env:BUILD_SUB_DIR
321322
322-
$Env:GTEST_ROOT='C:\VCPKG\INSTALLED\x86-windows\'
323-
$Env:BOOST_ROOT='C:\VCPKG\INSTALLED\x86-windows\'
324-
$Env:LIBRDKAFKA_INCLUDE_DIR='C:\VCPKG\INSTALLED\x86-windows\include\'
325-
$Env:LIBRDKAFKA_LIBRARY_DIR='C:\VCPKG\INSTALLED\x86-windows\lib\'
326-
$Env:RAPIDJSON_INCLUDE_DIRS='C:\VCPKG\INSTALLED\x86-windows\include\'
323+
$Env:GTEST_ROOT='C:\VCPKG\INSTALLED\x64-windows\'
324+
$Env:BOOST_ROOT='C:\VCPKG\INSTALLED\x64-windows\'
325+
$Env:LIBRDKAFKA_INCLUDE_DIR='C:\VCPKG\INSTALLED\x64-windows\include\'
326+
$Env:LIBRDKAFKA_LIBRARY_DIR='C:\VCPKG\INSTALLED\x64-windows\lib\'
327+
$Env:RAPIDJSON_INCLUDE_DIRS='C:\VCPKG\INSTALLED\x64-windows\include\'
327328
328-
cmake -B ./ -A Win32 -S ../.. "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
329+
cmake -B ./ -A x64 -S ../.. "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
329330
330331
- name: Build
331332
run: |

.github/workflows/kafka_api_demo_conan_build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828

2929
- name: Prepare
3030
run: |
31-
pip3 install conan==1.59.0
31+
pip3 install conan==1.64.1
3232
3333
- name: Build (non-windows)
3434
if: ${{!contains(matrix.os, 'windows')}}

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if (NOT parent_directory)
77
set(cppkafka_master_project ON)
88
# Use Strict Options
99
if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
10-
add_compile_options("-Wall" "-Werror" "-Wextra" "-Wshadow" "-Wno-unused-result")
10+
add_compile_options("-Wall" "-Werror" "-Wextra" "-Wshadow" "-Wno-unused-result" "-Wno-array-bounds")
1111
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
1212
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
1313
endif ()

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ About the *Modern C++ Kafka API*
66

77
The [modern-cpp-kafka API](http://opensource.morganstanley.com/modern-cpp-kafka/doxygen/annotated.html) is a layer of ***C++*** wrapper based on [librdkafka](https://github.com/confluentinc/librdkafka) (the ***C*** part only), with high quality, but more friendly to users.
88

9-
- By now, [modern-cpp-kafka](https://github.com/morganstanley/modern-cpp-kafka) is compatible with [librdkafka v2.0.2](https://github.com/confluentinc/librdkafka/releases/tag/v2.0.2).
9+
- By now, [modern-cpp-kafka](https://github.com/morganstanley/modern-cpp-kafka) is compatible with [librdkafka v2.4.0](https://github.com/confluentinc/librdkafka/releases/tag/v2.4.0).
1010

1111

1212
```

examples/example_ProducerRecordHeaders.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
#include <kafka/KafkaProducer.h>
1+
#include <kafka/ProducerRecord.h>
2+
#include <kafka/Types.h>
23

4+
#include <cstddef>
35
#include <iostream>
46
#include <string>
57

examples/kafka_auto_commit_consumer.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "kafka/KafkaConsumer.h"
22

3+
#include <chrono>
34
#include <iostream>
45
#include <string>
56

include/kafka/Log.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ template <std::size_t MAX_CAPACITY>
4343
class LogBuffer
4444
{
4545
public:
46-
LogBuffer():_wptr(_buf.data()) { _buf[0] = 0; } // NOLINT
46+
LogBuffer() { clear(); }
4747

4848
LogBuffer& clear()
4949
{
50-
_wptr = _buf.data();
5150
_buf[0] = 0;
51+
_wptr = _buf.data();
5252
return *this;
5353
}
5454

@@ -72,7 +72,7 @@ class LogBuffer
7272

7373
private:
7474
std::array<char, MAX_CAPACITY> _buf;
75-
char* _wptr;
75+
char* _wptr = nullptr;
7676
};
7777

7878

include/kafka/addons/KafkaMetrics.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <rapidjson/writer.h>
99

1010
#include <algorithm>
11+
#include <cstdint>
1112
#include <iostream>
1213
#include <sstream>
1314
#include <stdexcept>

scripts/start-local-kafka-cluster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def main():
157157
cmd = 'lsof -nP -iTCP:{0} | grep LISTEN'.format(brokerPort)
158158
cmdCall = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
159159
(out, err) = cmdCall.communicate();
160-
matched = re.search('[^\s-]+ +([0-9]+) +.*', out.decode('utf-8'))
160+
matched = re.search(r'[^\s-]+ +([0-9]+) +.*', out.decode('utf-8'))
161161
if matched:
162162
kafkaBrokerPids.append(matched.group(1))
163163

tests/integration/TestKafkaConsumer.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
#include "gtest/gtest.h"
77

8-
#include <boost/algorithm/string.hpp>
9-
108
#include <atomic>
119
#include <chrono>
1210
#include <cstring>

tests/integration/TestKafkaRecoverableProducer.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,11 @@ TEST(KafkaRecoverableProducer, MockFatalError)
104104
{
105105
auto toSend = messagesToSend.front();
106106
{
107-
std::lock_guard<std::mutex> lock(messagesMutex);
107+
const std::lock_guard<std::mutex> lock(messagesMutex);
108108
messagesToSend.pop_front();
109109
}
110110

111-
std::shared_ptr<std::string> payload = std::make_shared<std::string>(std::to_string(toSend));
111+
const std::shared_ptr<std::string> payload = std::make_shared<std::string>(std::to_string(toSend));
112112
auto record = kafka::clients::producer::ProducerRecord(topic, partition,
113113
kafka::NullKey,
114114
kafka::Value(payload->c_str(), payload->size()),
@@ -121,7 +121,7 @@ TEST(KafkaRecoverableProducer, MockFatalError)
121121

122122
// Would resend the message
123123
if (error) {
124-
std::lock_guard<std::mutex> lock(messagesMutex);
124+
const std::lock_guard<std::mutex> lock(messagesMutex);
125125
messagesToSend.push_front(static_cast<kafka::clients::producer::ProducerRecord::Id>(std::stoi(*payload)));
126126
}
127127

@@ -156,7 +156,7 @@ TEST(KafkaRecoverableProducer, MockFatalError)
156156
std::map<kafka::clients::producer::ProducerRecord::Id, int> countMap;
157157
for (const auto& record: records)
158158
{
159-
std::string payload(static_cast<const char*>(record.value().data()), record.value().size());
159+
const std::string payload(static_cast<const char*>(record.value().data()), record.value().size());
160160
++countMap[static_cast<kafka::clients::producer::ProducerRecord::Id>(std::stoi(payload))];
161161
}
162162

tests/robustness/TestAdminClient.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "../utils/TestUtility.h"
22

33
#include "kafka/AdminClient.h"
4+
#include "kafka/Types.h"
5+
#include "kafka/Utility.h"
46

57
#include "gtest/gtest.h"
68

tests/unit/TestBrokerMetadata.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#include "kafka/BrokerMetadata.h"
2+
#include "kafka/Types.h"
23

34
#include "gtest/gtest.h"
45

6+
#include <cstddef>
7+
#include <string>
8+
#include <vector>
9+
510

611
TEST(BrokerMetadata, Node)
712
{

tests/unit/TestKafkaMetrics.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ TEST(KafkaMetrics, FailureCases)
332332
const kafka::KafkaMetrics invalidMetrics("{invalid: 3}");
333333
EXPECT_FALSE(true);
334334
}
335-
catch (const std::runtime_error& e) {}
335+
catch (const std::runtime_error& e) { std::cout << "Exception std::runtime_error(" << e.what() << " caught as expected!" << std::endl; }
336336
catch (...) { EXPECT_FALSE(true); }
337337

338338
const kafka::KafkaMetrics metrics(consumerMetricsSample);
@@ -343,7 +343,7 @@ TEST(KafkaMetrics, FailureCases)
343343
metrics.getInt({"*", "127.0.0.1:29003/2", "stateage"});
344344
EXPECT_FALSE(true);
345345
}
346-
catch (const std::invalid_argument& e) {}
346+
catch (const std::invalid_argument& e) { std::cout << "Exception std::invalid_argument(" << e.what() << ") caught as expected!" << std::endl; }
347347
catch (...) { EXPECT_FALSE(true); }
348348

349349
// Try invalid inputs (end with "*")
@@ -352,7 +352,7 @@ TEST(KafkaMetrics, FailureCases)
352352
metrics.getInt({"brokers", "127.0.0.1:29003/2", "*"});
353353
EXPECT_FALSE(true);
354354
}
355-
catch (const std::invalid_argument& e) {}
355+
catch (const std::invalid_argument& e) { std::cout << "Exception std::invalid_argument(" << e.what() << ") caught as expected!" << std::endl; }
356356
catch (...) { EXPECT_FALSE(true); }
357357

358358
// Try invalid inputs (no keys)
@@ -361,7 +361,7 @@ TEST(KafkaMetrics, FailureCases)
361361
metrics.getInt({});
362362
EXPECT_FALSE(true);
363363
}
364-
catch (const std::invalid_argument& e) {}
364+
catch (const std::invalid_argument& e) { std::cout << "Exception std::invalid_argument(" << e.what() << ") caught as expected!" << std::endl; }
365365
catch (...) { EXPECT_FALSE(true); }
366366

367367
// Try non-exist keys

tests/utils/TestUtility.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ CreateKafkaTopic(const kafka::Topic& topic, int numPartitions, int replicationFa
208208
class JoiningThread {
209209
public:
210210
template <typename F, typename... Args>
211-
explicit JoiningThread(F&& f, Args&&... args): _t(f, args...) {}
211+
explicit JoiningThread(F&& f, Args&&... args): _t(std::forward<F>(f), args...) {}
212212
~JoiningThread() { if (_t.joinable()) _t.join(); }
213213
private:
214214
std::thread _t;

tools/console_clients/KafkaConsoleConsumer.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <atomic>
88
#include <iostream>
9+
#include <map>
910
#include <signal.h>
1011
#include <string>
1112
#include <vector>

0 commit comments

Comments
 (0)