Skip to content

Commit a3dfca2

Browse files
authored
Merge pull request #10 from DataDog/david.goffredo/ci
Add CI checks via CircleCI
2 parents 88a1acf + f78b333 commit a3dfca2

File tree

8 files changed

+160
-11
lines changed

8 files changed

+160
-11
lines changed

.circleci/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Circle CI
2+
=========
3+
This directory contains the [configuration](config.yml) for this project's
4+
[continuous integration setup][4].
5+
6+
The following jobs are defined:
7+
- `format` checks that the C++ source is formatted per `clang-format-14
8+
--style=file`.
9+
- `build-bazel` builds the library using [bazel][1].
10+
- Based on the `toolchain` parameter, the build will use either g++ or
11+
clang++.
12+
- `test-cmake` builds the library using [CMake][2] and runs the unit tests.
13+
- Based on the `toolchain` parameter, the build will use either g++ or
14+
clang++.
15+
- Based on the `sanitize` parameter, the build might use [AddressSanitizer and
16+
MemorySanitizer][3].
17+
18+
[1]: https://bazel.build/
19+
[2]: https://cmake.org/
20+
[3]: https://github.com/google/sanitizers
21+
[4]: https://app.circleci.com/pipelines/github/DataDog/dd-trace-cpp

.circleci/config.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
version: 2.1
2+
3+
jobs:
4+
format:
5+
docker:
6+
- image: "datadog/docker-library:dd-trace-cpp-ci"
7+
resource_class: small
8+
steps:
9+
- checkout
10+
- run: bin/check-format
11+
12+
build-bazel:
13+
parameters:
14+
toolchain:
15+
type: string
16+
docker:
17+
- image: "datadog/docker-library:dd-trace-cpp-ci"
18+
resource_class: xlarge
19+
environment:
20+
MAKE_JOB_COUNT: 8
21+
steps:
22+
- checkout
23+
- run: bin/with-toolchain << parameters.toolchain >> bazelisk build --jobs $MAKE_JOB_COUNT dd_trace_cpp
24+
25+
test-cmake:
26+
parameters:
27+
toolchain:
28+
type: string
29+
sanitize:
30+
type: string
31+
docker:
32+
- image: "datadog/docker-library:dd-trace-cpp-ci"
33+
resource_class: xlarge
34+
environment:
35+
MAKE_JOB_COUNT: 8
36+
steps:
37+
- checkout
38+
- run: mkdir .build
39+
- run: cd .build && ../bin/with-toolchain << parameters.toolchain >> cmake .. -DBUILD_TESTING=1 -DSANITIZE=<< parameters.sanitize >>
40+
- run: cd .build && make -j $MAKE_JOB_COUNT VERBOSE=1
41+
- run: cd .build && test/tests
42+
43+
workflows:
44+
pull-request:
45+
jobs:
46+
- format
47+
- test-cmake:
48+
matrix:
49+
parameters:
50+
toolchain: ["gnu", "llvm"]
51+
sanitize: ["on", "off"]
52+
- build-bazel:
53+
matrix:
54+
parameters:
55+
toolchain: ["gnu", "llvm"]

CMakeLists.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ include(ProcessorCount)
1818
ProcessorCount(NUM_PROCESSORS)
1919
set(MAKE_JOB_COUNT ${NUM_PROCESSORS} CACHE STRING "Number of jobs to use when building libcurl")
2020

21+
if (SANITIZE)
22+
add_compile_options(-fsanitize=address)
23+
add_link_options(-fsanitize=address)
24+
add_compile_options(-fsanitize=undefined)
25+
add_link_options(-fsanitize=undefined)
26+
# Thread sanitizer fails with "unexpected memory mapping".
27+
endif()
28+
2129
include (ExternalProject)
2230
ExternalProject_Add(curl
2331
URL "https://github.com/curl/curl/releases/download/curl-7_85_0/curl-7.85.0.tar.gz"
@@ -34,19 +42,11 @@ if (MSVC)
3442
add_compile_options(/W4 /WX)
3543
else()
3644
add_compile_options(-Wall -Wextra -pedantic -Werror)
37-
if(BUILD_COVERAGE)
45+
if (BUILD_COVERAGE)
3846
add_compile_options(-g -O0 -fprofile-arcs -ftest-coverage)
3947
endif()
4048
endif()
4149

42-
# TODO: The sanitizers have been giving me "fatal errors" and other chicanery.
43-
# add_compile_options(-fsanitize=address)
44-
# add_link_options(-fsanitize=address)
45-
# add_compile_options(-fsanitize=undefined)
46-
# add_link_options(-fsanitize=undefined)
47-
# add_compile_options(-fsanitize=thread)
48-
# add_link_options(-fsanitize=thread)
49-
5050
if(BUILD_COVERAGE)
5151
set(COVERAGE_LIBRARIES gcov)
5252
endif()

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This is the image used to build and test the library in CircleCI.
2+
# See .circleci/ for more information.
3+
4+
from ubuntu:22.04
5+
6+
# Don't issue blocking prompts during installation (sometimes an installer
7+
# prompts for the current time zone).
8+
env DEBIAN_FRONTEND=noninteractive
9+
10+
# Update the package lists and upgrade already-installed software.
11+
run apt-get update && apt-get upgrade --yes
12+
13+
# Install build tooling:
14+
# GCC, clang, make, coverage report generator, debugger, formatter, and miscellanea
15+
run apt-get install --yes wget build-essential clang sed lcov gdb clang-format
16+
# bazelisk, a launcher for bazel. `bazelisk --help` will cause the latest
17+
# version to be downloaded.
18+
run wget -O/usr/local/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/v1.15.0/bazelisk-linux-amd64 \
19+
&& chmod +x /usr/local/bin/bazelisk \
20+
&& bazelisk --help
21+
# CMake, by downloading a recent release from their website.
22+
copy bin/install-cmake /tmp/install-cmake
23+
run chmod +x /tmp/install-cmake && /tmp/install-cmake && rm /tmp/install-cmake

bin/README.md

100644100755
File mode changed.

bin/check-format

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
find src/ example/ test/ -type f \( -name '*.h' -o -name '*.cpp' \) -print0 | \
4+
xargs -0 clang-format-14 --style=file --dry-run -Werror

bin/with-toolchain

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/sh
2+
3+
usage() {
4+
cat <<'END_USAGE'
5+
with-toolchain: Run a command using a specific C++ build toolchain.
6+
7+
usage:
8+
with-toolchain gnu [COMMAND ...]
9+
with-toolchain llvm [COMMAND ...]
10+
Execute COMMAND in an environment that uses either GNU's compilers (gcc
11+
and g++) or LLVM's compilers (clang and clang++).
12+
13+
with-toolchain --help
14+
with-toolchain -h
15+
Print this message.
16+
17+
example:
18+
$ ../bin/with-toolchain llvm cmake .. -DBUILD_TESTING=1
19+
END_USAGE
20+
}
21+
22+
if [ "$#" -eq 0 ]; then
23+
>&2 usage
24+
exit 1
25+
fi
26+
27+
case "$1" in
28+
-h|--help)
29+
usage
30+
exit ;;
31+
gnu)
32+
toolchain=gnu ;;
33+
llvm)
34+
toolchain=llvm ;;
35+
*)
36+
>&2 echo "Invalid toolchain value \"$1\". Expected \"gnu\" or \"llvm\"."
37+
exit 2 ;;
38+
esac
39+
40+
shift
41+
case "$toolchain" in
42+
gnu)
43+
CC=gcc CXX=g++ "$@" ;;
44+
llvm)
45+
CC=clang CXX=clang++ "$@" ;;
46+
esac

src/datadog/version.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace datadog {
44
namespace tracing {
55

6-
const char* const tracer_version = "v0.1.2";
7-
const char* const tracer_version_string = "[dd-trace-cpp version v0.1.2]";
6+
const char* const tracer_version = "v0.1.5";
7+
const char* const tracer_version_string = "[dd-trace-cpp version v0.1.5]";
88

99
} // namespace tracing
1010
} // namespace datadog

0 commit comments

Comments
 (0)