From 7daac09dda0fd20e500ebbae3008c76e41f96646 Mon Sep 17 00:00:00 2001 From: "Yash Pandey (YP)" Date: Tue, 15 Jun 2021 00:27:29 +0530 Subject: [PATCH 1/5] feat: Added CTest Signed-off-by: Yash Pandey (YP) --- CMakeLists.txt | 16 +++++++++++++++ casbin/CMakeLists.txt | 7 +++++++ casbin/casbin.h | 3 +++ cmake/modules/FindExtPackages.cmake | 15 ++++++++++++++ cmake/modules/Findgoogletest.cmake | 8 ++++++++ tests/CMakeLists.txt | 16 +++++++++++++++ tests/main.cpp | 0 tests/test_enforcer.cpp | 32 +++++++++++++++++++++++++++++ 8 files changed, 97 insertions(+) create mode 100644 casbin/casbin.h create mode 100644 cmake/modules/FindExtPackages.cmake create mode 100644 cmake/modules/Findgoogletest.cmake create mode 100644 tests/CMakeLists.txt create mode 100644 tests/main.cpp create mode 100644 tests/test_enforcer.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 6da0a7b1..63372375 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,10 @@ cmake_minimum_required(VERSION 3.19) +set(CMAKE_MODULE_PATH + ${CMAKE_MODULE_PATH} + ${CMAKE_SOURCE_DIR}/cmake/modules +) + set(CMAKE_WARN_DEPRECATED ON) if(APPLE AND NOT DEFINED CMAKE_OSX_DEPLOYMENT_TARGET) @@ -34,6 +39,9 @@ if(NOT DEFINED CMAKE_INSTALL_MESSAGE) set(CMAKE_INSTALL_MESSAGE "NEVER") endif() +enable_testing() +add_subdirectory(tests) + # Change the path max size to avoid problem on Windows. if(NOT DEFINED CMAKE_OBJECT_PATH_MAX) set(CMAKE_OBJECT_PATH_MAX 300) @@ -42,4 +50,12 @@ endif() # Setting to C++ standard to C++17 set(CMAKE_CXX_STANDARD 17) +############################################################################### +# Find or install external dependencies +# Some required targets may be created by third-party CMake configs, which +# don't generally produce global targets. To guarantee all imported targets are +# global, this module is included at the project root level. + +include(FindExtPackages) + add_subdirectory(casbin) diff --git a/casbin/CMakeLists.txt b/casbin/CMakeLists.txt index 37ca1be3..132ae8ac 100644 --- a/casbin/CMakeLists.txt +++ b/casbin/CMakeLists.txt @@ -7,9 +7,16 @@ include_directories(${CMAKE_SOURCE_DIR}/casbin) target_precompile_headers(casbin PUBLIC "pch.h") +set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}) + set_target_properties(casbin PROPERTIES PREFIX "") if(WIN32 OR MSVC) set_target_properties(casbin PROPERTIES SUFFIX ".lib") elseif(UNIX) set_target_properties(casbin PROPERTIES SUFFIX ".a") endif() + +install( + TARGETS casbin + DESTINATION lib +) diff --git a/casbin/casbin.h b/casbin/casbin.h new file mode 100644 index 00000000..e0c94491 --- /dev/null +++ b/casbin/casbin.h @@ -0,0 +1,3 @@ +#include "enforcer.h" +#include "enforcer_cached.h" +#include "enforcer_synced.h" diff --git a/cmake/modules/FindExtPackages.cmake b/cmake/modules/FindExtPackages.cmake new file mode 100644 index 00000000..45225ee9 --- /dev/null +++ b/cmake/modules/FindExtPackages.cmake @@ -0,0 +1,15 @@ +############################################################################### +### Global package options ### + +set(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY ON CACHE BOOL + "Disable CMake User Package Registry when finding packages") + +set(CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY ON CACHE BOOL + "Disable CMake System Package Registry when finding packages") + +############################################################################### +### Packages and versions ### + +# googletest +# https://github.com/google/googletest +find_package(googletest 1.11.0 REQUIRED) diff --git a/cmake/modules/Findgoogletest.cmake b/cmake/modules/Findgoogletest.cmake new file mode 100644 index 00000000..e0187da7 --- /dev/null +++ b/cmake/modules/Findgoogletest.cmake @@ -0,0 +1,8 @@ +include(FetchContent) +FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip +) +# For Windows: Prevent overriding the parent project's compiler/linker settings +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +FetchContent_MakeAvailable(googletest) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..95e7b55d --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,16 @@ +add_executable( + casbintest + test_enforcer.cpp + main.cpp +) + +target_include_directories(casbintest PUBLIC ${CMAKE_SOURCE_DIR}) + +target_link_libraries( + casbintest + gtest_main + casbin +) + +include(GoogleTest) +gtest_discover_tests(casbintest) diff --git a/tests/main.cpp b/tests/main.cpp new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_enforcer.cpp b/tests/test_enforcer.cpp new file mode 100644 index 00000000..bf5ebc2a --- /dev/null +++ b/tests/test_enforcer.cpp @@ -0,0 +1,32 @@ +#include +#include + +TEST(TestEnforcer, TestFourParams) { + std::string model = "../../examples/rbac_with_domains_model.conf"; + std::string policy = "../../examples/rbac_with_domains_policy.csv"; + casbin::Enforcer e = casbin::Enforcer(model, policy); + + ASSERT_EQ(e.Enforce({ "alice", "domain1", "data1", "read" }), true); + ASSERT_EQ(e.Enforce({ "alice", "domain1", "data1", "write" }), true); + ASSERT_EQ(e.Enforce({ "alice", "domain1", "data2", "read" }), false); + ASSERT_EQ(e.Enforce({ "alice", "domain1", "data2", "write" }), false); + ASSERT_EQ(e.Enforce({ "bob", "domain2", "data1", "read" }), false); + ASSERT_EQ(e.Enforce({ "bob", "domain2", "data1", "write" }), false); + ASSERT_EQ(e.Enforce({ "bob", "domain2", "data2", "read" }), true); + ASSERT_EQ(e.Enforce({ "bob", "domain2", "data2", "write" }), true); +} + +TEST(TestEnforcer, TestThreeParams) { + std::string model = "../../examples/basic_model_without_spaces.conf"; + std::string policy = "../../examples/basic_policy.csv"; + casbin::Enforcer e(model, policy); + + ASSERT_EQ(e.Enforce({ "alice", "data1", "read" }), true); + ASSERT_EQ(e.Enforce({ "alice", "data1", "write" }), false); + ASSERT_EQ(e.Enforce({ "alice", "data2", "read" }), false); + ASSERT_EQ(e.Enforce({ "alice", "data2", "write" }), false); + ASSERT_EQ(e.Enforce({ "bob", "data1", "read" }), false); + ASSERT_EQ(e.Enforce({ "bob", "data1", "write" }), false); + ASSERT_EQ(e.Enforce({ "bob", "data2", "read" }), false); + ASSERT_EQ(e.Enforce({ "bob", "data2", "write" }), true); +} From bbfdd66229fff5b6446de4bfa5e930b4cd889d6f Mon Sep 17 00:00:00 2001 From: "Yash Pandey (YP)" Date: Wed, 16 Jun 2021 10:26:05 +0530 Subject: [PATCH 2/5] feat: Added more tests Signed-off-by: Yash Pandey (YP) --- CMakeLists.txt | 14 +++++++++ casbin/casbin.h | 19 +++++++++++++ tests/CMakeLists.txt | 14 +++++++++ tests/test_enforcer.cpp | 63 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 63372375..6a238b0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2020 The casbin Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + cmake_minimum_required(VERSION 3.19) set(CMAKE_MODULE_PATH diff --git a/casbin/casbin.h b/casbin/casbin.h index e0c94491..34775be4 100644 --- a/casbin/casbin.h +++ b/casbin/casbin.h @@ -1,3 +1,22 @@ +/* +* Copyright 2020 The casbin Authors. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* This file is the root header which is to be included by the client to use +* casbin in C++ environment +*/ + #include "enforcer.h" #include "enforcer_cached.h" #include "enforcer_synced.h" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 95e7b55d..7cd927d9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,3 +1,17 @@ +# Copyright 2020 The casbin Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + add_executable( casbintest test_enforcer.cpp diff --git a/tests/test_enforcer.cpp b/tests/test_enforcer.cpp index bf5ebc2a..562feca2 100644 --- a/tests/test_enforcer.cpp +++ b/tests/test_enforcer.cpp @@ -1,3 +1,21 @@ +/* +* Copyright 2020 The casbin Authors. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* This is a test file showcasing the workflow of casbin::Enforcer +*/ + #include #include @@ -30,3 +48,48 @@ TEST(TestEnforcer, TestThreeParams) { ASSERT_EQ(e.Enforce({ "bob", "data2", "read" }), false); ASSERT_EQ(e.Enforce({ "bob", "data2", "write" }), true); } + +TEST(TestEnforcer, TestVectorParams) { + std::string model = "../../examples/basic_model_without_spaces.conf"; + std::string policy = "../../examples/basic_policy.csv"; + casbin::Enforcer e(model, policy); + + ASSERT_EQ(e.Enforce({ "alice", "data1", "read" }), true); + ASSERT_EQ(e.Enforce({ "alice", "data1", "write" }), false); + ASSERT_EQ(e.Enforce({ "alice", "data2", "read" }), false); + ASSERT_EQ(e.Enforce({ "alice", "data2", "write" }), false); + ASSERT_EQ(e.Enforce({ "bob", "data1", "read" }), false); + ASSERT_EQ(e.Enforce({ "bob", "data1", "write" }), false); + ASSERT_EQ(e.Enforce({ "bob", "data2", "read" }), false); + ASSERT_EQ(e.Enforce({ "bob", "data2", "write" }), true); +} + +TEST(TestEnforcer, TestMapParams) { + std::string model = "../../examples/basic_model_without_spaces.conf"; + std::string policy = "../../examples/basic_policy.csv"; + casbin::Enforcer e(model, policy); + + std::unordered_map params = {{"sub", "alice"}, {"obj", "data1"}, {"act", "read"}}; + ASSERT_EQ(e.Enforce(params), true); + + params = { {"sub","alice"},{"obj","data1"},{"act","write"} }; + ASSERT_EQ(e.Enforce(params), false); + + params = { {"sub","alice"},{"obj","data2"},{"act","read"} }; + ASSERT_EQ(e.Enforce(params), false); + + params = { {"sub","alice"},{"obj","data2"},{"act","write"} }; + ASSERT_EQ(e.Enforce(params), false); + + params = { {"sub","bob"},{"obj","data1"},{"act","read"} }; + ASSERT_EQ(e.Enforce(params), false); + + params = { {"sub","bob"},{"obj","data1"},{"act","write"} }; + ASSERT_EQ(e.Enforce(params), false); + + params = { {"sub","bob"},{"obj","data2"},{"act","read"} }; + ASSERT_EQ(e.Enforce(params), false); + + params = { {"sub","bob"},{"obj","data2"},{"act","write"} }; + ASSERT_EQ(e.Enforce(params), true); +} From 5f73b844d58e6db5ca3815edef5941d5a869538d Mon Sep 17 00:00:00 2001 From: "Yash Pandey (YP)" Date: Wed, 16 Jun 2021 21:44:46 +0530 Subject: [PATCH 3/5] test: Added Enforcer tests Signed-off-by: Yash Pandey (YP) --- casbin/CMakeLists.txt | 20 +++++- casbin/enforcer_synced.cpp | 2 +- casbin/util/ticker.h | 2 +- tests/CMakeLists.txt | 7 +- tests/enforcer_cached_test.cpp | 46 +++++++++++++ tests/enforcer_synced_test.cpp | 68 +++++++++++++++++++ .../{test_enforcer.cpp => enforcer_test.cpp} | 0 tests/main.cpp | 0 8 files changed, 140 insertions(+), 5 deletions(-) create mode 100644 tests/enforcer_cached_test.cpp create mode 100644 tests/enforcer_synced_test.cpp rename tests/{test_enforcer.cpp => enforcer_test.cpp} (100%) delete mode 100644 tests/main.cpp diff --git a/casbin/CMakeLists.txt b/casbin/CMakeLists.txt index 132ae8ac..c05ba401 100644 --- a/casbin/CMakeLists.txt +++ b/casbin/CMakeLists.txt @@ -1,4 +1,16 @@ -set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) +# Copyright 2020 The casbin Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. FILE(GLOB_RECURSE SRC_FILES "*.cpp" "*.h") @@ -20,3 +32,9 @@ install( TARGETS casbin DESTINATION lib ) + +install( + DIRECTORY ${CMAKE_SOURCE_DIR}/casbin + DESTINATION ${CMAKE_SOURCE_DIR}/lib + FILES_MATCHING PATTERN "*.h" +) diff --git a/casbin/enforcer_synced.cpp b/casbin/enforcer_synced.cpp index 4a5daab4..54f8e9d8 100644 --- a/casbin/enforcer_synced.cpp +++ b/casbin/enforcer_synced.cpp @@ -110,7 +110,7 @@ void SyncedEnforcer ::StartAutoLoadPolicy(std::chrono::duration(new Ticker(onTick, t)); + ticker = std::make_unique(onTick, t); n = 1; ticker->start(); } diff --git a/casbin/util/ticker.h b/casbin/util/ticker.h index 3725df06..b6a8363f 100644 --- a/casbin/util/ticker.h +++ b/casbin/util/ticker.h @@ -44,7 +44,7 @@ class Ticker { void timer_loop(); on_tick_t _onTick; tick_interval_t _tickInterval; - std::atomic_bool _running; + std::atomic_bool _running; std::mutex _tickIntervalMutex; future_vec _futures1; future_vec _futures2; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7cd927d9..5623e96e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -12,10 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +set(CMAKE_CXX_STANDARD 17) + add_executable( casbintest - test_enforcer.cpp - main.cpp + enforcer_test.cpp + enforcer_cached_test.cpp + enforcer_synced_test.cpp ) target_include_directories(casbintest PUBLIC ${CMAKE_SOURCE_DIR}) diff --git a/tests/enforcer_cached_test.cpp b/tests/enforcer_cached_test.cpp new file mode 100644 index 00000000..6242c0b9 --- /dev/null +++ b/tests/enforcer_cached_test.cpp @@ -0,0 +1,46 @@ +/* +* Copyright 2020 The casbin Authors. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* This is a test file showcasing the workflow of casbin::CachedEnforcer +*/ + +#include +#include + +TEST(TestEnforcerCached, TestCache) { + std::string model = "../../examples/basic_model.conf"; + std::string policy = "../../examples/basic_policy.csv"; + casbin::CachedEnforcer e(model, policy); + ASSERT_EQ(e.Enforce({ "alice", "data1", "read" }), true); + ASSERT_EQ(e.Enforce({ "alice", "data1", "write" }), false); + ASSERT_EQ(e.Enforce({ "alice", "data2", "read" }), false); + ASSERT_EQ(e.Enforce({ "alice", "data2", "write" }), false); + + // The cache is enabled, so even if we remove a policy rule, the decision + // for ("alice", "data1", "read") will still be true, as it uses the cached result. + e.RemovePolicy({ "alice", "data1", "read" }); + ASSERT_EQ(e.Enforce({ "alice", "data1", "read" }), true); + ASSERT_EQ(e.Enforce({ "alice", "data1", "write" }), false); + ASSERT_EQ(e.Enforce({ "alice", "data2", "read" }), false); + ASSERT_EQ(e.Enforce({ "alice", "data2", "write" }), false); + + // Now we invalidate the cache, then all first-coming Enforce() has to be evaluated in real-time. + // The decision for ("alice", "data1", "read") will be false now. + e.InvalidateCache(); + ASSERT_EQ(e.Enforce({ "alice", "data1", "read" }), false); + ASSERT_EQ(e.Enforce({ "alice", "data1", "write" }), false); + ASSERT_EQ(e.Enforce({ "alice", "data2", "read" }), false); + ASSERT_EQ(e.Enforce({ "alice", "data2", "write" }), false); +} \ No newline at end of file diff --git a/tests/enforcer_synced_test.cpp b/tests/enforcer_synced_test.cpp new file mode 100644 index 00000000..327bd6ae --- /dev/null +++ b/tests/enforcer_synced_test.cpp @@ -0,0 +1,68 @@ +/* +* Copyright 2020 The casbin Authors. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* This is a test file showcasing the workflow of casbin::CachedEnforcer +*/ + +#include +#include + +// TEST(TestEnforcerSynced, TestSync) { +// std::string model = "../../examples/basic_model.conf"; +// std::string policy = "../../examples/basic_policy.csv"; +// casbin::SyncedEnforcer e(model, policy); + +// using namespace std::literals::chrono_literals; +// auto time1 = 200ms; +// e.StartAutoLoadPolicy(time1); + +// EXPECT_TRUE(e.Enforce({ "alice", "data1", "read" })); +// EXPECT_FALSE(e.Enforce({ "alice", "data1", "write" })); +// EXPECT_FALSE(e.Enforce({ "alice", "data2", "read" })); +// EXPECT_FALSE(e.Enforce({ "alice", "data2", "write" })); +// EXPECT_FALSE(e.Enforce({ "bob", "data1", "read" })); +// EXPECT_FALSE(e.Enforce({ "bob", "data1", "write" })); +// EXPECT_FALSE(e.Enforce({ "bob", "data2", "read" })); +// EXPECT_TRUE(e.Enforce({ "bob", "data2", "write" })); + +// e.StopAutoLoadPolicy(); +// } + +// TEST(TestEnforcerSynced, TestStopLoadPolicy) { +// std::string model = "../../examples/basic_model.conf"; +// std::string policy = "../../examples/basic_policy.csv"; +// casbin::SyncedEnforcer e(model, policy); + +// using namespace std::literals::chrono_literals; +// std::chrono::duration t = 5ms; + +// e.StartAutoLoadPolicy(t); + +// EXPECT_EQ(e.IsAutoLoadingRunning(), true); + +// ASSERT_EQ(e.Enforce({ "alice", "data1", "read" }), true); +// ASSERT_EQ(e.Enforce({ "alice", "data1", "write" }), false); +// ASSERT_EQ(e.Enforce({ "alice", "data2", "read" }), false); +// ASSERT_EQ(e.Enforce({ "alice", "data2", "write" }), false); +// ASSERT_EQ(e.Enforce({ "bob", "data1", "read" }), false); +// ASSERT_EQ(e.Enforce({ "bob", "data1", "write" }), false); +// ASSERT_EQ(e.Enforce({ "bob", "data2", "read" }), false); +// ASSERT_EQ(e.Enforce({ "bob", "data2", "write" }), true); + +// e.StopAutoLoadPolicy(); +// std::this_thread::sleep_for(10ms); + +// EXPECT_EQ(e.IsAutoLoadingRunning(), false); +// } diff --git a/tests/test_enforcer.cpp b/tests/enforcer_test.cpp similarity index 100% rename from tests/test_enforcer.cpp rename to tests/enforcer_test.cpp diff --git a/tests/main.cpp b/tests/main.cpp deleted file mode 100644 index e69de29b..00000000 From fbad4263d9bad180bae389f1d211e1d7da88ae5c Mon Sep 17 00:00:00 2001 From: "Yash Pandey (YP)" Date: Wed, 16 Jun 2021 21:48:21 +0530 Subject: [PATCH 4/5] fix: Fixed CI Signed-off-by: Yash Pandey (YP) --- .github/workflows/ci.yml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa92a0e4..9de9dbde 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,12 @@ jobs: - name: Building library id: building-lib run: | - cd build && cmake --build . --config Debug --target all -j 10 -- + cd build && cmake --build . --config Debug --target all install -j 10 -- + - name: Tests + id: test-lib + run: | + cd build + ctest -j10 -C Debug -T test --output-on-failure -T test --output-on-failure - name: Cleanup id: clean-up run: | @@ -55,12 +60,16 @@ jobs: id: building-lib run: | cd build - cmake --build . --config Release --target casbin -j 10 -- + cmake --build . --config Debug --target casbin gtest gtest_main gmock gmock_main casbintest -j 10 -- + - name: Tests + id: test-lib + run: | + cd build + ctest -j10 -C Debug -T test --output-on-failure -T test --output-on-failure - name: Cleanup id: clean-up run: | rm -r build - rm -r lib macos: name: "macOS Catalina 10.15 (AppleClang 12.0)" @@ -76,7 +85,12 @@ jobs: - name: Building library id: building-lib run: | - cd build && cmake --build . --config Debug --target all -j 10 -- + cd build && cmake --build . --config Debug --target all install -j 10 -- + - name: Tests + id: test-lib + run: | + cd build + ctest -j10 -C Debug -T test --output-on-failure -T test --output-on-failure - name: Cleanup id: clean-up run: | From ee306b2b0e69214dc274b94386a0948749663e47 Mon Sep 17 00:00:00 2001 From: "Yash Pandey (YP)" Date: Wed, 16 Jun 2021 22:18:01 +0530 Subject: [PATCH 5/5] fix: Linux sudo error Signed-off-by: Yash Pandey (YP) --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9de9dbde..da315ff2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: - name: Building library id: building-lib run: | - cd build && cmake --build . --config Debug --target all install -j 10 -- + cd build && cmake --build . --config Debug --target all -j 10 -- - name: Tests id: test-lib run: | @@ -41,7 +41,7 @@ jobs: - name: Cleanup id: clean-up run: | - rm -r build lib + rm -r build windows: name: "Windows 10 (MSVC 19.29)"