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

Adding a second Dockerfile supporting C++20 for cmake C++20 tests #211

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
1 change: 1 addition & 0 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ADD install_bazelisk.sh /setup-ci
ADD install_protobuf.sh /setup-ci
ADD install_format_tools.sh /setup-ci


RUN /setup-ci/setup_ci_environment.sh \
&& /setup-ci/setup_cmake.sh \
&& /setup-ci/install_gcc48.sh \
Expand Down
5 changes: 4 additions & 1 deletion ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ CI tests can be run on docker by invoking the script `./ci/run_docker.sh ./ci/do
* `code.coverage`: build cmake targets and run tests. Then upload coverage report to [codecov.io](https://codecov.io/).

Additionally, `./ci/run_docker.sh` can be invoked with no arguments to get a docker shell where tests
can be run manually.
can be run manually, except for `cmake.c++20.test`.

Note that `cmake.c++20.test` can only run in a Ubuntu version 20+ container, as earlier versions of Ubuntu do not support C++20 or g++-10.
To run said test, you must run it in the specified Ubuntu 20.04 container by invoking `./ci/run_docker.sh ./ci/do_ci.sh cmake.c++20.test`.
20 changes: 20 additions & 0 deletions ci/cpp20/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ubuntu:20.04

WORKDIR /setup-ci

ADD setup_ci_environment.sh /setup-ci
ADD setup_cmake.sh /setup-ci
ADD install_format_tools.sh /setup-ci

ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN true

RUN echo "tzdata tzdata/Areas select US" > /tmp/preseed.txt; \
echo "tzdata tzdata/Zones/US select Chicago" >> /tmp/preseed.txt; \
debconf-set-selections /tmp/preseed.txt && \
apt-get update && \
apt-get install -y tzdata

RUN /setup-ci/setup_ci_environment.sh \
&& /setup-ci/setup_cmake.sh \
&& /setup-ci/install_format_tools.sh
8 changes: 8 additions & 0 deletions ci/cpp20/install_format_tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -e

apt install -y clang-format-8 python3-pip git curl
pip3 install cmake_format==0.6.5
curl -L -o /usr/local/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/2.2.1/buildifier
chmod +x /usr/local/bin/buildifier
11 changes: 11 additions & 0 deletions ci/cpp20/setup_ci_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

set -e
apt-get update
apt-get install --no-install-recommends --no-install-suggests -y \
build-essential \
ca-certificates \
wget \
git \
g++-10
apt-get install -y lcov
16 changes: 16 additions & 0 deletions ci/cpp20/setup_cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e

apt-get install --no-install-recommends --no-install-suggests -y \
cmake \
libbenchmark-dev \
libgtest-dev

# Follows these instructions for setting up gtest
# https://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/
pushd /usr/src/gtest
cmake CMakeLists.txt
make
cp *.a /usr/lib || cp lib/*.a /usr/lib
popd
1 change: 1 addition & 0 deletions ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ if [[ "$1" == "cmake.test" ]]; then
make test
exit 0
elif [[ "$1" == "cmake.c++20.test" ]]; then
echo "${BUILD_DIR}"
cd "${BUILD_DIR}"
rm -rf *
cmake -DCMAKE_BUILD_TYPE=Debug \
Expand Down
22 changes: 15 additions & 7 deletions ci/run_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
set -e

BUILD_IMAGE=opentelemetry-cpp-build
docker image inspect "$BUILD_IMAGE" &> /dev/null || {
docker build -t "$BUILD_IMAGE" ci
}
BUILD_IMAGEcpp20=opentelemetry-cpp20-build

if [[ $# -ge 1 ]]; then
docker run -v "$PWD":/src -w /src -it "$BUILD_IMAGE" "$@"
if [[ $2 == cmake.c++20.test ]]; then
docker image inspect "$BUILD_IMAGEcpp20" &> /dev/null || {
docker build -t "$BUILD_IMAGEcpp20" ci/cpp20
}
docker run -v "$PWD":/src -w /src -it "$BUILD_IMAGEcpp20" "$@"
else
docker run -v "$PWD":/src -w /src --privileged -it "$BUILD_IMAGE" /bin/bash -l
fi
docker image inspect "$BUILD_IMAGE" &> /dev/null || {
docker build -t "$BUILD_IMAGE" ci
}
if [[ $# -ge 1 ]]; then
docker run -v "$PWD":/src -w /src -it "$BUILD_IMAGE" "$@"
else
docker run -v "$PWD":/src -w /src --privileged -it "$BUILD_IMAGE" /bin/bash -l
fi
fi