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

Lrpc 9 use pylint #17

Merged
merged 73 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
d808dfd
LRPC-13 Add Python client
invalid-email-address May 13, 2024
8418e13
LRPC-13 Add Python client
invalid-email-address May 13, 2024
28b808a
LRPC-13 Add Python client
invalid-email-address May 13, 2024
433dd74
LRPC-13 Add Python client
invalid-email-address May 13, 2024
67be54d
LRPC-13 Add Python client
invalid-email-address May 13, 2024
940838a
LRPC-13 Add Python client
invalid-email-address May 13, 2024
39dcaf7
LRPC-13 Add Python client
invalid-email-address May 15, 2024
2ac32d0
LRPC-13 Add Python Client
May 22, 2024
36eaed9
LRPC-13 Add Python client
Jun 2, 2024
cd30b8a
LRPC-13 Add Python client
Jun 3, 2024
3d6bb90
LRPC-13 Add Python client
Jun 9, 2024
c542d53
LRPC-13 Add Python client
Jun 21, 2024
07f50d0
LRPC-13 Add Python client
Jul 5, 2024
7d31394
LRPC-13 Add Python client
Jul 5, 2024
73cea75
LRPC-13 Add Python client
Jul 6, 2024
f29c528
LRPC-13 Add Python client
Jul 6, 2024
1b80573
LRPC-13 Add Python client
Jul 6, 2024
cff731b
LRPC-13 Add Python client
Jul 6, 2024
a11b903
LRPC-13 Add Python client
Jul 6, 2024
f639407
LRPC-13 Add Python client
Jul 6, 2024
85b23a1
LRPC-13 Add Python client
Jul 6, 2024
d652143
LRPC-13 Add Python client
Aug 4, 2024
1d5c79c
LRPC-13 Add Python client
Aug 4, 2024
29fe2f7
LRPC-13 Add Python client
Aug 4, 2024
c3cf1d8
LRPC-13 Add Python client
Aug 4, 2024
23a0868
LRPC-9 Use PyLint
invalid-email-address Sep 12, 2024
2bb5596
LRPC-9 Use PyLint
invalid-email-address Sep 12, 2024
85e4a78
LRPC-9 Use PyLint
invalid-email-address Sep 12, 2024
7de3a5e
Merge branch 'main' into LRPC-9-use-pylint
invalid-email-address Sep 18, 2024
f915b73
LRPC-9 Use PyLint
invalid-email-address Sep 18, 2024
da564bf
LRPC-9 Use PyLint
invalid-email-address Sep 18, 2024
d9b99f6
LRPC-9 Use PyLint
invalid-email-address Sep 18, 2024
6a61e83
LRPC-9 Use PyLint
invalid-email-address Sep 18, 2024
5a52338
LRPC-9 Use PyLint
invalid-email-address Sep 18, 2024
4f387fd
LRPC-9 Use PyLint
invalid-email-address Sep 18, 2024
180c644
LRPC-9 Use PyLint
invalid-email-address Sep 18, 2024
eb3891d
LRPC-9 Use PyLint
invalid-email-address Sep 18, 2024
5618082
LRPC-9 Use PyLint
invalid-email-address Sep 19, 2024
1c1bd7d
LRPC-9 Use PyLint
invalid-email-address Sep 22, 2024
a9f8d16
LRPC-9 Use PyLint
invalid-email-address Sep 22, 2024
937a255
LRPC-9 Use PyLint
invalid-email-address Sep 22, 2024
57dcd0b
LRPC-9 Use PyLint
invalid-email-address Sep 23, 2024
9d2d8d5
LRPC-9 Use PyLint
invalid-email-address Sep 23, 2024
20821ae
LRPC-9 Use PyLint
invalid-email-address Sep 23, 2024
e5cc285
LRPC-9 Use PyLint
invalid-email-address Sep 23, 2024
193f31d
LRPC-9 Use PyLint
invalid-email-address Sep 23, 2024
4d83b22
LRPC-9 Use PyLint
invalid-email-address Sep 23, 2024
42b82e1
LRPC-9 Use PyLint
invalid-email-address Sep 23, 2024
320cdff
LRPC-9 Use PyLint
invalid-email-address Sep 23, 2024
dcabe1b
LRPC-9 Use PyLint
invalid-email-address Sep 23, 2024
de06992
LRPC-9 Use PyLint
invalid-email-address Sep 23, 2024
35a6097
LRPC-9 Use PyLint
invalid-email-address Sep 24, 2024
106793b
LRPC-9 Use PyLint
invalid-email-address Sep 25, 2024
5b54198
LRPC-9 Use PyLint
invalid-email-address Sep 25, 2024
68acc4e
LRPC-9 Use PyLint
invalid-email-address Sep 26, 2024
e7387ce
LRPC-9 Use PyLint
invalid-email-address Sep 26, 2024
6b9c169
LRPC-9 Use PyLint
invalid-email-address Sep 26, 2024
d8b9ee8
LRPC-9 Use PyLint
invalid-email-address Sep 27, 2024
e1ece16
LRPC-9 Use PyLint
invalid-email-address Sep 27, 2024
8d1a30c
LRPC-9 Use PyLint
invalid-email-address Sep 27, 2024
b386a01
LRPC-9 Use PyLint
invalid-email-address Sep 27, 2024
c63682c
Merge branch 'main' into LRPC-9-use-pylint
invalid-email-address Sep 27, 2024
a9e603d
LotusRPC
invalid-email-address Sep 27, 2024
6197823
LRPC-9 Use PyLint
invalid-email-address Sep 27, 2024
9fa0355
LRPC-9 Use PyLint
invalid-email-address Sep 27, 2024
32f83bf
LRPC-9 Use PyLint
invalid-email-address Sep 30, 2024
ce321e0
LRPC-9 Use PyLint
invalid-email-address Sep 30, 2024
e6d0bb4
LRPC-9 Use PyLint
invalid-email-address Oct 1, 2024
2dc0351
LRPC-9 Use PyLint
invalid-email-address Oct 1, 2024
dc0095f
LRPC-9 Use PyLint
invalid-email-address Oct 5, 2024
f49d2f3
LRPC-9 Use PyLint
invalid-email-address Oct 5, 2024
c516922
LRPC-9 Use PyLint
invalid-email-address Oct 10, 2024
c07a31c
LRPC-9 Use PyLint
invalid-email-address Oct 10, 2024
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
8 changes: 7 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/setup-python@v5
with:
python-version: '3.9'

- name: Checkout
uses: actions/[email protected]
with:
submodules: "true"

- name: Install Python requirements
run: pip install -r requirements.txt
run: |
pip install -r requirements/package.txt
pip install -r requirements/dev.txt

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/msvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ jobs:
with:
submodules: "true"

- name: Install Python requirements
run: |
pip install -r requirements/package.txt
pip install -r requirements/dev.txt

- name: Configure CMake
run: cmake -B ${{ env.build }}

Expand All @@ -53,6 +58,8 @@ jobs:
cmakeBuildDirectory: ${{ env.build }}
# Ruleset file that will determine what checks will be run
ruleset: NativeRecommendedRules.ruleset
ignoredIncludePaths: external
ignoreSystemHeaders: true

# Upload SARIF file to GitHub Code Scanning Alerts
- name: Upload SARIF to GitHub
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Reviewdog
on: [pull_request]
jobs:
Reviewdog:
name: Reviewdog
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install mypy
run: pip install mypy
- name: Install requirements
run: pip install -r requirements/dev.txt
- name: Run MyPy
uses: tsuyoshicho/action-mypy@v4
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: error
fail_on_error: false
- name: Run PyLint
uses: dciborow/[email protected]
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: error
glob_pattern: "package"
fail_on_error: false
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

[![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=tzijnge_LotusRpc)](https://sonarcloud.io/summary/new_code?id=tzijnge_LotusRpc)

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

# LotusRpc
RPC framework for embedded systems based on [ETL](https://github.com/ETLCPP/etl). Generates C++ code with no dynamic memory allocations, no exceptions, no RTTI, etc.

Expand Down
12 changes: 9 additions & 3 deletions language/cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project(UnitTests VERSION 0.1.0)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
set(BUILD_GMOCK ON)
set(gtest_force_shared_crt on)

Expand Down Expand Up @@ -54,9 +54,15 @@ add_executable(UnitTests

target_include_directories(UnitTests PRIVATE .)
target_include_directories(UnitTests PRIVATE ../include)
target_include_directories(UnitTests PRIVATE ../../../external/etl/include)
target_include_directories(UnitTests SYSTEM PRIVATE ../../../external/etl/include)

target_compile_options(UnitTests PRIVATE -Werror -Wall -Wextra)
if(MSVC)
target_compile_options(UnitTests PRIVATE /W4)
else()
target_compile_options(UnitTests PRIVATE -Wall -Wextra)
endif()

set_property(TARGET UnitTests PROPERTY COMPILE_WARNING_AS_ERROR OFF)

target_link_libraries(
UnitTests
Expand Down
16 changes: 8 additions & 8 deletions language/cpp/tests/TestEtlRwExtensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ TEST(TestEtlRwExtensions, readArithmetic)
EXPECT_TRUE(lrpc::read_unchecked<bool>(reader));
EXPECT_EQ(0x02, lrpc::read_unchecked<uint8_t>(reader));
EXPECT_EQ(0x0403, lrpc::read_unchecked<uint16_t>(reader));
EXPECT_FLOAT_EQ(123.456, lrpc::read_unchecked<float>(reader));
EXPECT_FLOAT_EQ(123.456F, lrpc::read_unchecked<float>(reader));
}

TEST(TestEtlRwExtensions, readAutoString)
Expand Down Expand Up @@ -160,7 +160,7 @@ TEST(TestEtlRwExtensions, copyString)

TEST(TestEtlRwExtensions, copyArrayOfString)
{
etl::array<etl::string_view, 2> source {"T1", "T2"};
etl::array<etl::string_view, 2> source{"T1", "T2"};
etl::array<etl::string<2>, 2> dest;
lrpc::copy<etl::array<etl::string<2>, 2>>(source, dest);
EXPECT_EQ("T1", dest[0]);
Expand All @@ -169,13 +169,13 @@ TEST(TestEtlRwExtensions, copyArrayOfString)

TEST(TestEtlRwExtensions, copyOptionalString)
{
etl::optional<etl::string_view> source1 {"T1"};
etl::optional<etl::string_view> source1{"T1"};
etl::optional<etl::string<2>> dest1;
lrpc::copy<etl::optional<etl::string<2>>>(source1, dest1);
ASSERT_TRUE(dest1.has_value());
EXPECT_EQ("T1", dest1.value());

etl::optional<etl::string<2>> dest2 {"~~"};
etl::optional<etl::string<2>> dest2{"~~"};
lrpc::copy<etl::optional<etl::string<2>>>(source1, dest2);
ASSERT_TRUE(dest2.has_value());
EXPECT_EQ("T1", dest2.value());
Expand All @@ -194,7 +194,7 @@ TEST(TestEtlRwExtensions, writeArithmetic)
lrpc::write_unchecked<bool>(writer, true);
lrpc::write_unchecked<uint8_t>(writer, 0x02);
lrpc::write_unchecked<uint16_t>(writer, 0x0403);
lrpc::write_unchecked<float>(writer, 123.456);
lrpc::write_unchecked<float>(writer, 123.456F);

auto written = writer.used_data();
ASSERT_EQ(9, written.size());
Expand Down Expand Up @@ -248,11 +248,11 @@ TEST(TestEtlRwExtensions, writeArray)
etl::array<uint8_t, 10> storage;
etl::byte_stream_writer writer(storage.begin(), storage.end(), etl::endian::little);

etl::array<uint8_t, 2> t2 {0x01, 0x02};
etl::array<uint8_t, 2> t2{0x01, 0x02};
lrpc::write_unchecked<etl::array<uint8_t, 2>>(writer, t2);

auto written = writer.used_data();
ASSERT_EQ(2, written.size());
ASSERT_EQ(2, written.size());
EXPECT_EQ(0x01, written[0]);
EXPECT_EQ(0x02, written[1]);
}
Expand All @@ -262,7 +262,7 @@ TEST(TestEtlRwExtensions, writeArrayOfString)
etl::array<uint8_t, 10> storage;
etl::byte_stream_writer writer(storage.begin(), storage.end(), etl::endian::little);

etl::array<etl::string<2>, 2> a {"T1", "T2"};
etl::array<etl::string<2>, 2> a{"T1", "T2"};
lrpc::write_unchecked<etl::array<etl::string<2>, 2>>(writer, a);

auto written = writer.used_data();
Expand Down
27 changes: 20 additions & 7 deletions language/cpp/tests/TestServer1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ class TestServer1 : public ::testing::Test
const etl::span<const uint8_t> s(bytes.begin(), bytes.end());

lrpc::Service::Reader reader(s.begin(), s.end(), etl::endian::little);
lrpc::Service::Writer writer(response.begin(), response.end(), etl::endian::little);
lrpc::Service::Writer writer(responseBuffer.begin(), responseBuffer.end(), etl::endian::little);
s0Service.invoke(reader, writer);

return { response.begin(), writer.size_bytes()};
return {responseBuffer.begin(), writer.size_bytes()};
}

void EXPECT_RESPONSE(const std::vector<uint8_t> &expected, const etl::span<uint8_t> actual)
{
std::vector<uint8_t> actualVec {actual.begin(), actual.end()};
std::vector<uint8_t> actualVec{actual.begin(), actual.end()};
EXPECT_EQ(expected, actualVec);
}

private:
etl::array<uint8_t, 256> response;
etl::array<uint8_t, 256> responseBuffer;
};

static_assert(std::is_same<ts1::Server1, lrpc::Server<0, 100, 200>>::value, "RX and/or TX buffer size are unequal to the definition file");
Expand Down Expand Up @@ -117,15 +117,15 @@ TEST_F(TestServer1, decodeF3)
// Decode function f4 with float arg
TEST_F(TestServer1, decodeF4)
{
EXPECT_CALL(s0Service, f4(123.456));
EXPECT_CALL(s0Service, f4(123.456F));
auto response = receive({4, 0x79, 0xE9, 0xF6, 0x42});
EXPECT_RESPONSE({4}, response);
}

// Decode function f5 with array of uint16_t arg
TEST_F(TestServer1, decodeF5)
{
std::vector<uint16_t> expected {0xBBAA, 0xDDCC};
std::vector<uint16_t> expected{0xBBAA, 0xDDCC};
EXPECT_CALL(s0Service, f5(SPAN_EQ(expected)));
auto response = receive({5, 0xAA, 0xBB, 0xCC, 0xDD});
EXPECT_RESPONSE({5}, response);
Expand Down Expand Up @@ -278,7 +278,20 @@ TEST_F(TestServer1, decodef22)

EXPECT_CALL(s0Service, f22(arg1, arg2)).WillOnce(Return(std::tuple<etl::string<4>, etl::string<4>>{ret1, ret2}));
auto response = receive({22, 'a', 'r', 'g', '1', '\0', 'a', 'r', 'g', '2', '\0'});
EXPECT_RESPONSE({22, 'r','e','t','1','\0','r','e','t','2','\0',}, response);
EXPECT_RESPONSE({
22,
'r',
'e',
't',
'1',
'\0',
'r',
'e',
't',
'2',
'\0',
},
response);
}

// Decode function f6 with string arg
Expand Down
8 changes: 4 additions & 4 deletions language/cpp/tests/TestServer2_s0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ class TestServer2 : public ::testing::Test
const etl::span<const uint8_t> s(bytes.begin(), bytes.end());

lrpc::Service::Reader reader(s.begin(), s.end(), etl::endian::little);
lrpc::Service::Writer writer(response.begin(), response.end(), etl::endian::little);
lrpc::Service::Writer writer(responseBuffer.begin(), responseBuffer.end(), etl::endian::little);
service.invoke(reader, writer);

return { response.begin(), writer.size_bytes()};
return {responseBuffer.begin(), writer.size_bytes()};
}

void EXPECT_RESPONSE(const std::vector<uint8_t> &expected, const etl::span<uint8_t> actual)
{
std::vector<uint8_t> actualVec {actual.begin(), actual.end()};
std::vector<uint8_t> actualVec{actual.begin(), actual.end()};
EXPECT_EQ(expected, actualVec);
}

private:
etl::array<uint8_t, 256> response;
etl::array<uint8_t, 256> responseBuffer;
};

static_assert(std::is_same<Server2, lrpc::Server<1, 100, 256>>::value, "RX and/or TX buffer size are unequal to the definition file");
Expand Down
15 changes: 7 additions & 8 deletions language/cpp/tests/TestServer2_s1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ MATCHER_P(SPAN_EQ, e, "Equality matcher for etl::span")
}
}
return true;

}

class MockS01Service : public s01ServiceShim
Expand All @@ -44,20 +43,20 @@ class TestServer2_s1 : public ::testing::Test
const etl::span<const uint8_t> s(bytes.begin(), bytes.end());

lrpc::Service::Reader reader(s.begin(), s.end(), etl::endian::little);
lrpc::Service::Writer writer(response.begin(), response.end(), etl::endian::little);
lrpc::Service::Writer writer(responseBuffer.begin(), responseBuffer.end(), etl::endian::little);
service.invoke(reader, writer);

return { response.begin(), writer.size_bytes()};
return {responseBuffer.begin(), writer.size_bytes()};
}

void EXPECT_RESPONSE(const std::vector<uint8_t> &expected, const etl::span<uint8_t> actual)
{
std::vector<uint8_t> actualVec {actual.begin(), actual.end()};
std::vector<uint8_t> actualVec{actual.begin(), actual.end()};
EXPECT_EQ(expected, actualVec);
}

private:
etl::array<uint8_t, 256> response;
etl::array<uint8_t, 256> responseBuffer;
};

// Decode void function with array of strings param
Expand All @@ -82,7 +81,7 @@ TEST_F(TestServer2_s1, decodeF0WithStringShorterThanMax)
// Decode function that returns array of strings
TEST_F(TestServer2_s1, decodeF1)
{
etl::array<etl::string<2>, 2> retVal {"T1", "T2"};
etl::array<etl::string<2>, 2> retVal{"T1", "T2"};
EXPECT_CALL(service, f1()).WillOnce(Return(retVal));
auto response = receive({1});
EXPECT_RESPONSE({1, 'T', '1', '\0', 'T', '2', '\0'}, response);
Expand Down Expand Up @@ -144,8 +143,8 @@ TEST_F(TestServer2_s1, decodeF6)
// Decode function that takes auto string argument and returns fixed size string
TEST_F(TestServer2_s1, decodeF7)
{
etl::string<5> retVal {"T1234"};
etl::string_view expected {"T0"};
etl::string<5> retVal{"T1234"};
etl::string_view expected{"T0"};
EXPECT_CALL(service, f7(expected)).WillOnce(Return(retVal));
auto response = receive({7, 'T', '0', '\0'});
EXPECT_RESPONSE({7, 'T', '1', '2', '3', '4', '\0'}, response);
Expand Down
5 changes: 5 additions & 0 deletions language/cpp/tests/etl_profile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#ifdef _MSC_VER
#define ETL_ENDIAN_NATIVE 0
#endif
Empty file.
Loading
Loading