File tree Expand file tree Collapse file tree 14 files changed +208
-3
lines changed Expand file tree Collapse file tree 14 files changed +208
-3
lines changed Original file line number Diff line number Diff line change
1
+ # This is a composite to allow sharing these steps into other workflows.
2
+ # It isn't a shared workflow, because then it isn't convenient to add
3
+ # additional package-specific steps.
4
+
5
+ # The CMake project should follow a convention where the test project is
6
+ # gtest_LIBNAME for instance gtest_launchdarkly-cpp-common.
7
+ name : Shared CI Workflow
8
+ description : ' Shared CI workflow used by C++ packages.'
9
+ inputs :
10
+ cmake_target :
11
+ description : ' The name of the CMake target. i.e. launchdarkly-cpp-common'
12
+ required : true
13
+
14
+ runs :
15
+ using : composite
16
+ steps :
17
+ - name : Install boost
18
+
19
+ id : install-boost
20
+ with :
21
+ boost_version : 1.81.0
22
+ platform_version : 22.04
23
+ boost_install_dir : /home/runner/boost
24
+ - name : Build Library
25
+ shell : bash
26
+ run : ./scripts/build.sh ${{ inputs.cmake_target }} ON
27
+ env :
28
+ BOOST_ROOT : ${{ steps.install-boost.outputs.BOOST_ROOT }}
29
+ - name : Build Tests
30
+ shell : bash
31
+ run : ./scripts/build.sh gtest_${{ inputs.cmake_target }} ON
32
+ env :
33
+ BOOST_ROOT : ${{ steps.install-boost.outputs.BOOST_ROOT }}
34
+ - name : Run Tests
35
+ shell : bash
36
+ # This uses the binary, versus "make tests" because the binary
37
+ # has better performance and output.
38
+ run : ./build/gtest_${{ inputs.cmake_target }}
Original file line number Diff line number Diff line change
1
+ name : libs/client-sdk
2
+
3
+ on :
4
+ push :
5
+ branches : [main]
6
+ paths-ignore :
7
+ - ' **.md' # Do not need to run CI for markdown changes.
8
+ pull_request :
9
+ branches : [main]
10
+ paths-ignore :
11
+ - ' **.md'
12
+
13
+ jobs :
14
+ build-test-common :
15
+ runs-on : ubuntu-22.04
16
+ steps :
17
+ - uses : actions/checkout@v3
18
+ - uses : ./.github/actions/ci
19
+ with :
20
+ cmake_target : launchdarkly-cpp-client
Original file line number Diff line number Diff line change
1
+ name : libs/common
2
+
3
+ on :
4
+ push :
5
+ branches : [main]
6
+ paths-ignore :
7
+ - ' **.md' # Do not need to run CI for markdown changes.
8
+ pull_request :
9
+ branches : [main]
10
+ paths-ignore :
11
+ - ' **.md'
12
+
13
+ jobs :
14
+ build-test-common :
15
+ runs-on : ubuntu-22.04
16
+ steps :
17
+ - uses : actions/checkout@v3
18
+ - uses : ./.github/actions/ci
19
+ with :
20
+ cmake_target : launchdarkly-cpp-common
Original file line number Diff line number Diff line change
1
+ name : Lint PR title
2
+
3
+ on :
4
+ pull_request_target :
5
+ types :
6
+ - opened
7
+ - edited
8
+ - synchronize
9
+
10
+ jobs :
11
+ main :
12
+ name : Verify the PR title matches conventional commit spec.
13
+ runs-on : ubuntu-latest
14
+ steps :
15
+ - uses : amannn/action-semantic-pull-request@v5
16
+ env :
17
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
1
+ name : libs/server-sent-events
2
+
3
+ on :
4
+ push :
5
+ branches : [main]
6
+ paths-ignore :
7
+ - ' **.md' # Do not need to run CI for markdown changes.
8
+ pull_request :
9
+ branches : [main]
10
+ paths-ignore :
11
+ - ' **.md'
12
+
13
+ jobs :
14
+ build-test-common :
15
+ runs-on : ubuntu-22.04
16
+ steps :
17
+ - uses : actions/checkout@v3
18
+ - uses : ./.github/actions/ci
19
+ with :
20
+ cmake_target : launchdarkly-sse-client
Original file line number Diff line number Diff line change @@ -29,3 +29,7 @@ include(FetchContent)
29
29
30
30
# Add main SDK sources.
31
31
add_subdirectory (src )
32
+
33
+ if (BUILD_TESTING )
34
+ add_subdirectory (tests )
35
+ endif ()
Original file line number Diff line number Diff line change
1
+ cmake_minimum_required (VERSION 3.10 )
2
+ include (GoogleTest )
3
+
4
+ include_directories ("${PROJECT_SOURCE_DIR} /include" )
5
+
6
+ file (GLOB tests "${PROJECT_SOURCE_DIR} /tests/*.cpp" )
7
+
8
+ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} )
9
+
10
+ add_executable (gtest_${LIBNAME}
11
+ ${tests} )
12
+ target_link_libraries (gtest_${LIBNAME} launchdarkly::client GTest::gtest_main )
13
+
14
+ gtest_discover_tests (gtest_${LIBNAME} )
Original file line number Diff line number Diff line change
1
+ #include < gtest/gtest.h>
2
+
3
+ // Demonstrate some basic assertions.
4
+ TEST (HelloTest, BasicAssertions) {
5
+ // Expect two strings not to be equal.
6
+ EXPECT_STRNE (" hello" , " world" );
7
+ // Expect equality.
8
+ EXPECT_EQ (7 * 6 , 42 );
9
+ }
Original file line number Diff line number Diff line change @@ -5,8 +5,10 @@ include_directories("${PROJECT_SOURCE_DIR}/include")
5
5
6
6
file (GLOB tests "${PROJECT_SOURCE_DIR} /tests/*.cpp" )
7
7
8
- add_executable ("google_tests_common"
8
+ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} )
9
+
10
+ add_executable (gtest_${LIBNAME}
9
11
${tests} )
10
- target_link_libraries (google_tests_common launchdarkly::common GTest::gtest_main )
12
+ target_link_libraries (gtest_${LIBNAME} launchdarkly::common GTest::gtest_main )
11
13
12
- gtest_discover_tests (google_tests_common )
14
+ gtest_discover_tests (gtest_${LIBNAME} )
Original file line number Diff line number Diff line change @@ -42,3 +42,7 @@ message(STATUS "LaunchDarkly: using Boost v${Boost_VERSION}")
42
42
43
43
44
44
add_subdirectory (src )
45
+
46
+ if (BUILD_TESTING )
47
+ add_subdirectory (tests )
48
+ endif ()
Original file line number Diff line number Diff line change
1
+ cmake_minimum_required (VERSION 3.10 )
2
+ include (GoogleTest )
3
+
4
+ include_directories ("${PROJECT_SOURCE_DIR} /include" )
5
+
6
+ file (GLOB tests "${PROJECT_SOURCE_DIR} /tests/*.cpp" )
7
+
8
+ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} )
9
+
10
+ add_executable (gtest_${LIBNAME}
11
+ ${tests} )
12
+ target_link_libraries (gtest_${LIBNAME} launchdarkly::sse GTest::gtest_main )
13
+
14
+ gtest_discover_tests (gtest_${LIBNAME} )
Original file line number Diff line number Diff line change
1
+ #include < gtest/gtest.h>
2
+
3
+ // Demonstrate some basic assertions.
4
+ TEST (HelloTest, BasicAssertions) {
5
+ // Expect two strings not to be equal.
6
+ EXPECT_STRNE (" hello" , " world" );
7
+ // Expect equality.
8
+ EXPECT_EQ (7 * 6 , 42 );
9
+ }
Original file line number Diff line number Diff line change
1
+ #! /bin/bash -e
2
+
3
+ # This script builds a specific cmake target.
4
+ # This script should be ran from the root directory of the project.
5
+ # ./scripts/build.sh my-build-target ON
6
+ #
7
+ # $1 the name of the target. For example "launchdarkly-cpp-common".
8
+ # $2 ON/OFF which enables/disables building in a test configuration.
9
+
10
+ function cleanup {
11
+ cd ..
12
+ }
13
+
14
+ mkdir -p build
15
+ cd build
16
+ # After we enter the directory we want to make sure we always exit it when the
17
+ # script ends.
18
+ trap cleanup EXIT
19
+
20
+ cmake -D BUILD_TESTING=" $2 " ..
21
+
22
+ cmake --build . --target " $1 "
Original file line number Diff line number Diff line change
1
+ #! /bin/bash -e
2
+
3
+ function cleanup {
4
+ cd ..
5
+ }
6
+
7
+ cd build
8
+ # After we enter the directory we want to make sure we always exit it when the
9
+ # script ends.
10
+ trap cleanup EXIT
11
+
12
+ cmake --build . --target clean
You can’t perform that action at this time.
0 commit comments