diff --git a/ci/README.md b/ci/README.md index 6695c8b134..d95ebbe69f 100644 --- a/ci/README.md +++ b/ci/README.md @@ -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`. diff --git a/ci/cpp20/Dockerfile b/ci/cpp20/Dockerfile new file mode 100644 index 0000000000..93d27c196e --- /dev/null +++ b/ci/cpp20/Dockerfile @@ -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/Europe 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 diff --git a/ci/cpp20/install_format_tools.sh b/ci/cpp20/install_format_tools.sh new file mode 100755 index 0000000000..c589250168 --- /dev/null +++ b/ci/cpp20/install_format_tools.sh @@ -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 diff --git a/ci/cpp20/setup_ci_environment.sh b/ci/cpp20/setup_ci_environment.sh new file mode 100755 index 0000000000..b5ef8da358 --- /dev/null +++ b/ci/cpp20/setup_ci_environment.sh @@ -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 diff --git a/ci/cpp20/setup_cmake.sh b/ci/cpp20/setup_cmake.sh new file mode 100755 index 0000000000..0ab9be37fd --- /dev/null +++ b/ci/cpp20/setup_cmake.sh @@ -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 diff --git a/ci/run_docker.sh b/ci/run_docker.sh index d28a8c5199..e4a9831fe1 100755 --- a/ci/run_docker.sh +++ b/ci/run_docker.sh @@ -2,18 +2,18 @@ set -e -BUILD_IMAGE=opentelemetry-cpp-build -BUILD_IMAGE2=opentelemetry-cpp-build2 -docker image inspect "$BUILD_IMAGE" &> /dev/null || { - docker build -t "$BUILD_IMAGE" ci -} -docker image inspect "$BUILD_IMAGE2" &> /dev/null || { - docker build -t "$BUILD_IMAGE2" ci/cpp20 -} +BUILD_IMAGE=opentelemetry-cpp-build6 +BUILD_IMAGEcpp20=opentelemetry-cpp20-build6 -if [ $2 == cmake.c++20.test ]; then - docker run -v "$PWD":/src -w /src -it "$BUILD_IMAGE2" "$@" +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 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 diff --git a/ci/setup_ci_environment.sh b/ci/setup_ci_environment.sh index b5ef8da358..9d7df6a1d5 100755 --- a/ci/setup_ci_environment.sh +++ b/ci/setup_ci_environment.sh @@ -6,6 +6,5 @@ apt-get install --no-install-recommends --no-install-suggests -y \ build-essential \ ca-certificates \ wget \ - git \ - g++-10 + git apt-get install -y lcov