Skip to content

Commit c2e7aa6

Browse files
authored
[CI] Add CI for instrumentation/log4cxx (#426)
1 parent 6217b44 commit c2e7aa6

File tree

4 files changed

+110
-5
lines changed

4 files changed

+110
-5
lines changed

.github/workflows/log4cxx.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: log4cxx
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
path:
8+
- 'instrumentation/log4cxx/**'
9+
- '.github/workflows/log4cxx.yml'
10+
pull_request:
11+
branches: [main]
12+
paths:
13+
- 'instrumentation/log4cxx/**'
14+
- '.github/workflows/log4cxx.yml'
15+
16+
jobs:
17+
cmake_linux:
18+
name: CMake Linux
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: checkout googletest
22+
uses: actions/checkout@v3
23+
with:
24+
repository: "google/googletest"
25+
ref: "release-1.12.1"
26+
path: "googletest"
27+
- name: checkout logging-log4cxx
28+
uses: actions/checkout@v3
29+
with:
30+
repository: "apache/logging-log4cxx"
31+
ref: "rel/v1.2.0"
32+
path: "logging-log4cxx"
33+
- name: checkout opentelemetry-cpp-contrib
34+
uses: actions/checkout@v3
35+
with:
36+
path: opentelemetry-cpp-contrib
37+
- name: checkout opentelemetry-cpp
38+
uses: actions/checkout@v3
39+
with:
40+
repository: "open-telemetry/opentelemetry-cpp"
41+
ref: "v1.14.2"
42+
path: "opentelemetry-cpp"
43+
submodules: "recursive"
44+
- name: setup dependencies
45+
run: |
46+
sudo apt update -y
47+
sudo apt install -y --no-install-recommends --no-install-suggests \
48+
build-essential \
49+
cmake \
50+
ninja-build \
51+
libssl-dev \
52+
libcurl4-openssl-dev \
53+
libprotobuf-dev \
54+
protobuf-compiler \
55+
libgmock-dev \
56+
libgtest-dev \
57+
libbenchmark-dev \
58+
liblog4cxx-dev
59+
60+
# This is needed because libgmock-dev libgtest-dev installs 1.11,
61+
# and v1.12 is required
62+
- name: build googletest 1.12
63+
run: |
64+
mkdir -p "${GITHUB_WORKSPACE}/googletest/build"
65+
cd "${GITHUB_WORKSPACE}/googletest/build"
66+
cmake .. -G Ninja
67+
cmake --build . -j$(nproc)
68+
cmake --install . --prefix="${GITHUB_WORKSPACE}/sandbox"
69+
70+
# This is needed because liblog4cxx-dev installs 0.12.1-4,
71+
# and v1.0.0 is required
72+
- name: build logging-log4cxx
73+
run: |
74+
mkdir -p "${GITHUB_WORKSPACE}/logging-log4cxx/build"
75+
cd "${GITHUB_WORKSPACE}/logging-log4cxx/build"
76+
cmake .. -G Ninja
77+
cmake --build . -j$(nproc)
78+
cmake --install . --prefix="${GITHUB_WORKSPACE}/sandbox"
79+
80+
- name: build opentelemetry-cpp
81+
run: |
82+
mkdir -p "${GITHUB_WORKSPACE}/opentelemetry-cpp/build"
83+
cd "${GITHUB_WORKSPACE}/opentelemetry-cpp/build"
84+
cmake .. -G Ninja -DBUILD_TESTING=OFF -DWITH_BENCHMARK=OFF -DOPENTELEMETRY_INSTALL=ON
85+
cmake --build . -j$(nproc)
86+
cmake --install . --prefix="${GITHUB_WORKSPACE}/sandbox"
87+
88+
- name: build instrumentation/log4cxx contrib
89+
run: |
90+
mkdir -p "${GITHUB_WORKSPACE}/instrumentation-log4cxx/build"
91+
cd "${GITHUB_WORKSPACE}/instrumentation-log4cxx/build"
92+
cmake ../../opentelemetry-cpp-contrib/instrumentation/log4cxx \
93+
-G Ninja \
94+
-DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/sandbox" \
95+
-DBUILD_TESTING=ON \
96+
-DWITH_EXAMPLES=ON \
97+
-DOPENTELEMETRY_INSTALL=ON
98+
cmake --build . -j$(nproc)
99+
ctest -j1 --output-on-failure
100+
cmake --install . --prefix="${GITHUB_WORKSPACE}/sandbox"
101+

instrumentation/log4cxx/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ if(OPENTELEMETRY_INSTALL)
8484
endif() # OPENTELEMETRY_INSTALL
8585

8686
if(BUILD_TESTING)
87+
find_package(GTest 1.12 REQUIRED)
88+
89+
enable_testing()
90+
8791
set(testname appender_test)
8892

8993
include(GoogleTest)
@@ -97,9 +101,9 @@ if(BUILD_TESTING)
97101
)
98102

99103
target_link_libraries(${testname} PRIVATE
100-
gmock
101-
gtest
102-
gtest_main
104+
GTest::gmock
105+
GTest::gtest
106+
GTest::gtest_main
103107
log4cxx
104108
opentelemetry-cpp::ostream_log_record_exporter
105109
${this_target}

instrumentation/log4cxx/include/opentelemetry/instrumentation/log4cxx/appender.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,4 @@ class OpenTelemetryAppender : public AppenderSkeleton
6666
void append(const spi::LoggingEventPtr &event, helpers::Pool &) override;
6767
};
6868

69-
IMPLEMENT_LOG4CXX_OBJECT(OpenTelemetryAppender)
70-
7169
} // namespace log4cxx

instrumentation/log4cxx/src/appender.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
namespace log4cxx
1212
{
1313

14+
IMPLEMENT_LOG4CXX_OBJECT(OpenTelemetryAppender)
15+
1416
void OpenTelemetryAppender::append(const spi::LoggingEventPtr &event, helpers::Pool &)
1517
{
1618
static constexpr auto kLibraryName = "log4cxx";

0 commit comments

Comments
 (0)