From 08ce6e0109451db91254b3ff82fee32289cf28e5 Mon Sep 17 00:00:00 2001 From: Takashi Matsuo Date: Tue, 16 Jul 2019 12:31:19 -0400 Subject: Add install test (#8) * Add first install test * Fix style * Split the test into spanner and bigtable * Correct indentation * Add other distros, shared lib test, and kokoro configs * Fix style --- ci/kokoro/install/Dockerfile.centos-7 | 105 +++++++++++++++++++ ci/kokoro/install/Dockerfile.fedora-30 | 58 +++++++++++ ci/kokoro/install/Dockerfile.fedora-30-shared | 58 +++++++++++ ci/kokoro/install/Dockerfile.opensuse-leap | 114 +++++++++++++++++++++ ci/kokoro/install/Dockerfile.opensuse-tumbleweed | 54 ++++++++++ ci/kokoro/install/Dockerfile.ubuntu-16.04 | 100 ++++++++++++++++++ ci/kokoro/install/Dockerfile.ubuntu-18.04 | 84 +++++++++++++++ ci/kokoro/install/build.sh | 106 +++++++++++++++++++ ci/kokoro/install/centos-7-presubmit.cfg | 0 ci/kokoro/install/centos-7.cfg | 0 ci/kokoro/install/common.cfg | 17 +++ ci/kokoro/install/fedora-30-presubmit.cfg | 0 ci/kokoro/install/fedora-30-shared-presubmit.cfg | 0 ci/kokoro/install/fedora-30-shared.cfg | 0 ci/kokoro/install/fedora-30.cfg | 0 ci/kokoro/install/opensuse-leap-presubmit.cfg | 0 ci/kokoro/install/opensuse-leap.cfg | 0 .../install/opensuse-tumbleweed-presubmit.cfg | 0 ci/kokoro/install/opensuse-tumbleweed.cfg | 0 ci/kokoro/install/ubuntu-16.04-presubmit.cfg | 0 ci/kokoro/install/ubuntu-16.04.cfg | 0 ci/kokoro/install/ubuntu-18.04-presubmit.cfg | 0 ci/kokoro/install/ubuntu-18.04.cfg | 0 ci/test-install/bigtable/CMakeLists.txt | 28 +++++ ci/test-install/bigtable/main.cc | 22 ++++ ci/test-install/compile-test-projects.sh | 36 +++++++ ci/test-install/spanner/CMakeLists.txt | 28 +++++ ci/test-install/spanner/main.cc | 22 ++++ 28 files changed, 832 insertions(+) create mode 100644 ci/kokoro/install/Dockerfile.centos-7 create mode 100644 ci/kokoro/install/Dockerfile.fedora-30 create mode 100644 ci/kokoro/install/Dockerfile.fedora-30-shared create mode 100644 ci/kokoro/install/Dockerfile.opensuse-leap create mode 100644 ci/kokoro/install/Dockerfile.opensuse-tumbleweed create mode 100644 ci/kokoro/install/Dockerfile.ubuntu-16.04 create mode 100644 ci/kokoro/install/Dockerfile.ubuntu-18.04 create mode 100755 ci/kokoro/install/build.sh create mode 100644 ci/kokoro/install/centos-7-presubmit.cfg create mode 100644 ci/kokoro/install/centos-7.cfg create mode 100644 ci/kokoro/install/common.cfg create mode 100644 ci/kokoro/install/fedora-30-presubmit.cfg create mode 100644 ci/kokoro/install/fedora-30-shared-presubmit.cfg create mode 100644 ci/kokoro/install/fedora-30-shared.cfg create mode 100644 ci/kokoro/install/fedora-30.cfg create mode 100644 ci/kokoro/install/opensuse-leap-presubmit.cfg create mode 100644 ci/kokoro/install/opensuse-leap.cfg create mode 100644 ci/kokoro/install/opensuse-tumbleweed-presubmit.cfg create mode 100644 ci/kokoro/install/opensuse-tumbleweed.cfg create mode 100644 ci/kokoro/install/ubuntu-16.04-presubmit.cfg create mode 100644 ci/kokoro/install/ubuntu-16.04.cfg create mode 100644 ci/kokoro/install/ubuntu-18.04-presubmit.cfg create mode 100644 ci/kokoro/install/ubuntu-18.04.cfg create mode 100644 ci/test-install/bigtable/CMakeLists.txt create mode 100644 ci/test-install/bigtable/main.cc create mode 100755 ci/test-install/compile-test-projects.sh create mode 100644 ci/test-install/spanner/CMakeLists.txt create mode 100644 ci/test-install/spanner/main.cc (limited to 'ci') diff --git a/ci/kokoro/install/Dockerfile.centos-7 b/ci/kokoro/install/Dockerfile.centos-7 new file mode 100644 index 000000000000..21b8908134d4 --- /dev/null +++ b/ci/kokoro/install/Dockerfile.centos-7 @@ -0,0 +1,105 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM centos:7 AS devtools + +# Please keep the formatting in these commands, it is optimized to cut & paste +# into the INSTALL.md file. + +## [START INSTALL.md] + +# First install the development tools and OpenSSL. The development tools +# distributed with CentOS (notably CMake) are too old to build +# `cpp-cmakefiles`. In these instructions, we use `cmake3` obtained from +# [Software Collections](https://www.softwarecollections.org/). + +# ```bash +RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm +RUN yum install -y centos-release-scl +RUN yum-config-manager --enable rhel-server-rhscl-7-rpms +RUN yum makecache && \ + yum install -y automake cmake3 curl-devel gcc gcc-c++ git libtool \ + make openssl-devel pkgconfig tar wget which zlib-devel +RUN ln -sf /usr/bin/cmake3 /usr/bin/cmake && ln -sf /usr/bin/ctest3 /usr/bin/ctest +# ``` + +# #### Protobuf + +# Likewise, manually install protobuf: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/google/protobuf/archive/v3.9.0.tar.gz +RUN tar -xf v3.9.0.tar.gz +WORKDIR /var/tmp/build/protobuf-3.9.0/cmake +RUN cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=yes \ + -Dprotobuf_BUILD_TESTS=OFF \ + -H. -Bcmake-out +RUN cmake --build cmake-out --target install -- -j $(nproc) +RUN ldconfig +# ``` + +# #### c-ares + +# Recent versions of gRPC require c-ares >= 1.11, while CentOS-7 +# distributes c-ares-1.10. Manually install a newer version: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz +RUN tar -xf cares-1_15_0.tar.gz +WORKDIR /var/tmp/build/c-ares-cares-1_15_0 +RUN ./buildconf && ./configure && make -j $(nproc) +RUN make install +RUN ldconfig +# ``` + +# #### gRPC + +# Can be manually installed using: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/grpc/grpc/archive/v1.22.0.tar.gz +RUN tar -xf v1.22.0.tar.gz +WORKDIR /var/tmp/build/grpc-1.22.0 +ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig +ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 +ENV PATH=/usr/local/bin:${PATH} +RUN make -j $(nproc) +RUN make install +RUN ldconfig +# ``` + +FROM devtools AS install + +# #### googleapis + +# Finally we can install `googleapis`. + +# ```bash +WORKDIR /home/build/cpp-cmakefiles +COPY . /home/build/cpp-cmakefiles +RUN cmake -H. -Bcmake-out +RUN cmake --build cmake-out -- -j $(nproc) +WORKDIR /home/build/cpp-cmakefiles/cmake-out +RUN cmake --build . --target install +# ``` + +## [END INSTALL.md] + +# Verify that the installed files are actually usable +RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh diff --git a/ci/kokoro/install/Dockerfile.fedora-30 b/ci/kokoro/install/Dockerfile.fedora-30 new file mode 100644 index 000000000000..d6e57b91e232 --- /dev/null +++ b/ci/kokoro/install/Dockerfile.fedora-30 @@ -0,0 +1,58 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM fedora:30 AS devtools + +# Please keep the formatting below, it is used by `extract-install.md` +# to generate the contents of the top-level INSTALL.md. + +## [START INSTALL.md] + +# Install the minimal development tools: + +# ```bash +RUN dnf makecache && \ + dnf install -y cmake gcc-c++ git make openssl-devel pkgconfig \ + zlib-devel +# ``` + +# Fedora includes packages for gRPC, libcurl, and OpenSSL that are recent enough +# for `cpp-cmakefiles`. Install these packages and additional development +# tools to compile the dependencies: + +# ```bash +RUN dnf makecache && \ + dnf install -y grpc-devel grpc-plugins \ + libcurl-devel protobuf-compiler tar wget zlib-devel +# ``` + +FROM devtools AS install + +# #### googleapis + +# We can now compile and install `googleapis`. + +# ```bash +WORKDIR /home/build/cpp-cmakefiles +COPY . /home/build/cpp-cmakefiles +RUN cmake -H. -Bcmake-out +RUN cmake --build cmake-out -- -j $(nproc) +WORKDIR /home/build/cpp-cmakefiles/cmake-out +RUN cmake --build . --target install +# ``` + +## [END INSTALL.md] + +# Verify that the installed files are actually usable +RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh diff --git a/ci/kokoro/install/Dockerfile.fedora-30-shared b/ci/kokoro/install/Dockerfile.fedora-30-shared new file mode 100644 index 000000000000..3a0accf7026c --- /dev/null +++ b/ci/kokoro/install/Dockerfile.fedora-30-shared @@ -0,0 +1,58 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM fedora:30 AS devtools + +# Please keep the formatting below, it is used by `extract-install.md` +# to generate the contents of the top-level INSTALL.md. + +## [START INSTALL.md] + +# Install the minimal development tools: + +# ```bash +RUN dnf makecache && \ + dnf install -y cmake gcc-c++ git make openssl-devel pkgconfig \ + zlib-devel +# ``` + +# Fedora includes packages for gRPC, libcurl, and OpenSSL that are recent enough +# for `cpp-cmakefiles`. Install these packages and additional development +# tools to compile the dependencies: + +# ```bash +RUN dnf makecache && \ + dnf install -y grpc-devel grpc-plugins \ + libcurl-devel protobuf-compiler tar wget zlib-devel +# ``` + +FROM devtools AS install + +# #### googleapis + +# We can now compile and install `googleapis` as shared library. + +# ```bash +WORKDIR /home/build/cpp-cmakefiles +COPY . /home/build/cpp-cmakefiles +RUN cmake -H. -Bcmake-out -DBUILD_SHARED_LIBS=yes +RUN cmake --build cmake-out -- -j $(nproc) +WORKDIR /home/build/cpp-cmakefiles/cmake-out +RUN cmake --build . --target install +# ``` + +## [END INSTALL.md] + +# Verify that the installed files are actually usable +RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh diff --git a/ci/kokoro/install/Dockerfile.opensuse-leap b/ci/kokoro/install/Dockerfile.opensuse-leap new file mode 100644 index 000000000000..ea2dda5ec4e6 --- /dev/null +++ b/ci/kokoro/install/Dockerfile.opensuse-leap @@ -0,0 +1,114 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM opensuse/leap:latest AS devtools + +## [START INSTALL.md] + +# Install the minimal development tools: + +# ```bash +RUN zypper refresh && \ + zypper install --allow-downgrade -y cmake gcc gcc-c++ git gzip \ + libcurl-devel libopenssl-devel make tar wget +# ``` + +# #### Protobuf + +# OpenSUSE Leap includes a package for protobuf-2.6, but this is too old to +# support the Google Cloud Platform proto files, or to support gRPC for that +# matter. Manually install protobuf: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/google/protobuf/archive/v3.9.0.tar.gz +RUN tar -xf v3.9.0.tar.gz +WORKDIR /var/tmp/build/protobuf-3.9.0/cmake +RUN cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=yes \ + -Dprotobuf_BUILD_TESTS=OFF \ + -H. -Bcmake-out +RUN cmake --build cmake-out --target install -- -j $(nproc) +RUN ldconfig +# ``` + +# #### c-ares + +# Recent versions of gRPC require c-ares >= 1.11, while OpenSUSE Leap +# distributes c-ares-1.9. We need some additional development tools to compile +# this library: + +# ```bash +RUN zypper refresh && \ + zypper install -y automake libtool +# ``` + +# Manually install a newer version: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz +RUN tar -xf cares-1_15_0.tar.gz +WORKDIR /var/tmp/build/c-ares-cares-1_15_0 +RUN ./buildconf && ./configure && make -j $(nproc) +RUN make install +RUN ldconfig +# ``` + +# #### gRPC + +# The gRPC Makefile uses `which` to determine whether the compiler is available. +# Install this command for the extremely rare case where it may be missing from +# your workstation or build server: + +# ```bash +RUN zypper refresh && \ + zypper install -y which +# ``` + +# Then gRPC can be manually installed using: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/grpc/grpc/archive/v1.22.0.tar.gz +RUN tar -xf v1.22.0.tar.gz +WORKDIR /var/tmp/build/grpc-1.22.0 +ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig +ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 +ENV PATH=/usr/local/bin:${PATH} +RUN make -j $(nproc) +RUN make install +RUN ldconfig +# ``` + +FROM devtools AS install + +# #### googleapis + +# We can now compile and install `googleapis`. + +# ```bash +WORKDIR /home/build/cpp-cmakefiles +COPY . /home/build/cpp-cmakefiles +RUN cmake -H. -Bcmake-out +RUN cmake --build cmake-out -- -j $(nproc) +WORKDIR /home/build/cpp-cmakefiles/cmake-out +RUN cmake --build . --target install +# ``` + +## [END INSTALL.md] + +# Verify that the installed files are actually usable +RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh diff --git a/ci/kokoro/install/Dockerfile.opensuse-tumbleweed b/ci/kokoro/install/Dockerfile.opensuse-tumbleweed new file mode 100644 index 000000000000..0c466697ca91 --- /dev/null +++ b/ci/kokoro/install/Dockerfile.opensuse-tumbleweed @@ -0,0 +1,54 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM opensuse/tumbleweed:latest AS devtools + +## [START INSTALL.md] + +# Install the minimal development tools: + +# ```bash +RUN zypper refresh && \ + zypper install --allow-downgrade -y cmake gcc gcc-c++ git gzip \ + libcurl-devel libopenssl-devel make tar wget zlib-devel +# ``` + +# OpenSUSE:tumbleweed provides packages for gRPC, libcurl, and protobuf, and the +# versions of these packages are recent enough to support the Google Cloud +# Platform proto files. + +# ```bash +RUN zypper refresh && \ + zypper install -y grpc-devel gzip libcurl-devel pkg-config tar wget +# ``` + +FROM devtools AS install + +# #### googleapis + +# We can now compile and install `googleapis`. + +# ```bash +WORKDIR /home/build/cpp-cmakefiles +COPY . /home/build/cpp-cmakefiles +RUN cmake -H. -Bcmake-out +RUN cmake --build cmake-out -- -j $(nproc) +WORKDIR /home/build/cpp-cmakefiles/cmake-out +RUN cmake --build . --target install +# ``` + +## [END INSTALL.md] + +# Verify that the installed files are actually usable +RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh diff --git a/ci/kokoro/install/Dockerfile.ubuntu-16.04 b/ci/kokoro/install/Dockerfile.ubuntu-16.04 new file mode 100644 index 000000000000..030ed4a2aa85 --- /dev/null +++ b/ci/kokoro/install/Dockerfile.ubuntu-16.04 @@ -0,0 +1,100 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM ubuntu:16.04 AS devtools + +# Please keep the formatting in these commands, it is optimized to cut & paste +# into the README.md file. + +## [START INSTALL.md] + +# Install the minimal development tools: + +# ```bash +RUN apt update && \ + apt install -y automake build-essential cmake git gcc g++ cmake \ + libcurl4-openssl-dev libssl-dev libtool make pkg-config tar wget \ + zlib1g-dev +# ``` + +# #### c-ares + +# Recent versions of gRPC require c-ares >= 1.11, while Ubuntu-16.04 +# distributes c-ares-1.10. We can manually install a newer version +# of c-ares: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz +RUN tar -xf cares-1_15_0.tar.gz +WORKDIR /var/tmp/build/c-ares-cares-1_15_0 +RUN ./buildconf && ./configure && make -j $(nproc) +RUN make install +RUN ldconfig +# ``` + +# #### Protobuf + +# While protobuf-3.0 is distributed with Ubuntu, the Google Cloud Plaform proto +# files require more recent versions (circa 3.4.x). To manually install a more +# recent version use: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/google/protobuf/archive/v3.9.0.tar.gz +RUN tar -xf v3.9.0.tar.gz +WORKDIR /var/tmp/build/protobuf-3.9.0/cmake +RUN cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=yes \ + -Dprotobuf_BUILD_TESTS=OFF \ + -H. -Bcmake-out +RUN cmake --build cmake-out --target install -- -j $(nproc) +RUN ldconfig +# ``` + +# #### gRPC + +# Likewise, Ubuntu has packages for grpc-1.3.x, but this version is too old for +# the Google Cloud Platform APIs: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/grpc/grpc/archive/v1.22.0.tar.gz +RUN tar -xf v1.22.0.tar.gz +WORKDIR /var/tmp/build/grpc-1.22.0 +RUN make -j $(nproc) +RUN make install +RUN ldconfig +# ``` + +FROM devtools AS install + +# #### googleapis + +# Finally we can install `googleapis`. + +# ```bash +WORKDIR /home/build/cpp-cmakefiles +COPY . /home/build/cpp-cmakefiles +RUN cmake -H. -Bcmake-out +RUN cmake --build cmake-out -- -j $(nproc) +WORKDIR /home/build/cpp-cmakefiles/cmake-out +RUN cmake --build . --target install +# ``` + +## [END INSTALL.md] + +# Verify that the installed files are actually usable +RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh diff --git a/ci/kokoro/install/Dockerfile.ubuntu-18.04 b/ci/kokoro/install/Dockerfile.ubuntu-18.04 new file mode 100644 index 000000000000..486d24aa47db --- /dev/null +++ b/ci/kokoro/install/Dockerfile.ubuntu-18.04 @@ -0,0 +1,84 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM ubuntu:18.04 AS devtools + +# Please keep the formatting in these commands, it is optimized to cut & paste +# into the README.md file. + +## [START INSTALL.md] + +# Install the minimal development tools: + +# ```bash +RUN apt update && \ + apt install -y build-essential cmake git gcc g++ cmake \ + libc-ares-dev libc-ares2 libcurl4-openssl-dev libssl-dev make \ + pkg-config tar wget zlib1g-dev +# ``` + +# #### Protobuf + +# While protobuf-3.0 is distributed with Ubuntu, the Google Cloud Plaform proto +# files require more recent versions (circa 3.4.x). To manually install a more +# recent version use: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/google/protobuf/archive/v3.9.0.tar.gz +RUN tar -xf v3.9.0.tar.gz +WORKDIR /var/tmp/build/protobuf-3.9.0/cmake +RUN cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=yes \ + -Dprotobuf_BUILD_TESTS=OFF \ + -H. -Bcmake-out +RUN cmake --build cmake-out --target install -- -j $(nproc) +RUN ldconfig +# ``` + +# #### gRPC + +# Likewise, Ubuntu has packages for grpc-1.3.x, but this version is too old for +# the Google Cloud Platform APIs: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/grpc/grpc/archive/v1.22.0.tar.gz +RUN tar -xf v1.22.0.tar.gz +WORKDIR /var/tmp/build/grpc-1.22.0 +RUN make -j $(nproc) +RUN make install +RUN ldconfig +# ``` + +FROM devtools AS install + +# #### googleapis + +# Finally we can install `googleapis`. + +# ```bash +WORKDIR /home/build/cpp-cmakefiles +COPY . /home/build/cpp-cmakefiles +RUN cmake -H. -Bcmake-out +RUN cmake --build cmake-out -- -j $(nproc) +WORKDIR /home/build/cpp-cmakefiles/cmake-out +RUN cmake --build . --target install +# ``` + +## [END INSTALL.md] + +# Verify that the installed files are actually usable +RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh diff --git a/ci/kokoro/install/build.sh b/ci/kokoro/install/build.sh new file mode 100755 index 000000000000..42e85f39b6fc --- /dev/null +++ b/ci/kokoro/install/build.sh @@ -0,0 +1,106 @@ +#!/usr/bin/env bash +# +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu + +if [[ $# -eq 1 ]]; then + export TEST_TARGET="${1}" +elif [[ -n "${KOKORO_JOB_NAME:-}" ]]; then + # Kokoro injects the KOKORO_JOB_NAME environment variable, the value of this + # variable is cloud-cpp/spanner/ (or more + # generally ). By convention we name these + # files `$foo.cfg` for continuous builds and `$foo-presubmit.cfg` for + # presubmit builds. Here we extract the value of "foo" and use it as the build + # name. + TEST_TARGET="$(basename "${KOKORO_JOB_NAME}" "-presubmit")" + export TEST_TARGET +else + echo "Aborting build as the distribution name is not defined." + echo "If you are invoking this script via the command line use:" + echo " $0 " + echo + echo "If this script is invoked by Kokoro, the CI system is expected to set" + echo "the KOKORO_JOB_NAME environment variable." + exit 1 +fi + +echo "================================================================" +echo "Change working directory to project root $(date)." +cd "$(dirname "$0")/../../.." + +if [[ -z "${PROJECT_ID+x}" ]]; then + readonly PROJECT_ID="cloud-devrel-kokoro-resources" +fi + +readonly DEV_IMAGE="gcr.io/${PROJECT_ID}/cpp-cmakefiles/test-install-dev-${TEST_TARGET}" +readonly IMAGE="gcr.io/${PROJECT_ID}/cpp-cmakefiles/test-install-${TEST_TARGET}" + +has_cache="false" + +# We download the cached dev image for pull requests on kokoro. For continuous +# jobs, we don't download the cached image. This means we build from scratch and +# upload the image for future builds for pull requests. +if [[ -n "${KOKORO_JOB_NAME:-}" ]] \ + && [[ -n "${KOKORO_GITHUB_PULL_REQUEST_NUMBER:-}" ]]; then + echo "================================================================" + echo "Download existing image (if available) for ${TEST_TARGET} $(date)." + if docker pull "${DEV_IMAGE}:latest"; then + echo "Existing image successfully downloaded." + has_cache="true" + fi + echo "================================================================" +fi + +echo "================================================================" +echo "Build base image with minimal development tools for ${TEST_TARGET} $(date)." +update_cache="false" + +devtools_flags=( + # Only build up to the stage that installs the minimal development tools, but + # does not compile any of our code. + "--target" "devtools" + # Create the image with the same tag as the cache we are using, so we can + # upload it. + "-t" "${DEV_IMAGE}:latest" + "-f" "ci/kokoro/install/Dockerfile.${TEST_TARGET}" +) + +if "${has_cache}"; then + devtools_flags+=("--cache-from=${DEV_IMAGE}:latest") +fi + +echo "Running docker build with " "${devtools_flags[@]}" +if docker build "${devtools_flags[@]}" ci; then + update_cache="true" +fi + +# We upload the cached image for continuous builds. +if "${update_cache}" && [[ -z "${KOKORO_GITHUB_PULL_REQUEST_NUMBER:-}" ]] \ + && [[ -n "${KOKORO_JOB_NAME:-}" ]]; then + echo "================================================================" + echo "Uploading updated base image for ${TEST_TARGET} $(date)." + # Do not stop the build on a failure to update the cache. + docker push "${DEV_IMAGE}:latest" || true +fi + +echo "================================================================" +echo "Run validation script for INSTALL instructions on ${TEST_TARGET}." +docker build \ + "--cache-from=${DEV_IMAGE}:latest" \ + "--target=install" \ + -t "${IMAGE}" \ + -f "ci/kokoro/install/Dockerfile.${TEST_TARGET}" . +echo "================================================================" diff --git a/ci/kokoro/install/centos-7-presubmit.cfg b/ci/kokoro/install/centos-7-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci/kokoro/install/centos-7.cfg b/ci/kokoro/install/centos-7.cfg new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci/kokoro/install/common.cfg b/ci/kokoro/install/common.cfg new file mode 100644 index 000000000000..77a3a1f9fefe --- /dev/null +++ b/ci/kokoro/install/common.cfg @@ -0,0 +1,17 @@ +# Format: //devtools/kokoro/config/proto/build.proto +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +build_file: "cpp-cmakefiles/ci/kokoro/install/build.sh" +timeout_mins: 120 diff --git a/ci/kokoro/install/fedora-30-presubmit.cfg b/ci/kokoro/install/fedora-30-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci/kokoro/install/fedora-30-shared-presubmit.cfg b/ci/kokoro/install/fedora-30-shared-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci/kokoro/install/fedora-30-shared.cfg b/ci/kokoro/install/fedora-30-shared.cfg new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci/kokoro/install/fedora-30.cfg b/ci/kokoro/install/fedora-30.cfg new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci/kokoro/install/opensuse-leap-presubmit.cfg b/ci/kokoro/install/opensuse-leap-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci/kokoro/install/opensuse-leap.cfg b/ci/kokoro/install/opensuse-leap.cfg new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci/kokoro/install/opensuse-tumbleweed-presubmit.cfg b/ci/kokoro/install/opensuse-tumbleweed-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci/kokoro/install/opensuse-tumbleweed.cfg b/ci/kokoro/install/opensuse-tumbleweed.cfg new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci/kokoro/install/ubuntu-16.04-presubmit.cfg b/ci/kokoro/install/ubuntu-16.04-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci/kokoro/install/ubuntu-16.04.cfg b/ci/kokoro/install/ubuntu-16.04.cfg new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci/kokoro/install/ubuntu-18.04-presubmit.cfg b/ci/kokoro/install/ubuntu-18.04-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci/kokoro/install/ubuntu-18.04.cfg b/ci/kokoro/install/ubuntu-18.04.cfg new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/ci/test-install/bigtable/CMakeLists.txt b/ci/test-install/bigtable/CMakeLists.txt new file mode 100644 index 000000000000..7aed05ff1d8d --- /dev/null +++ b/ci/test-install/bigtable/CMakeLists.txt @@ -0,0 +1,28 @@ +# ~~~ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ~~~ + +cmake_minimum_required(VERSION 3.5) + +project(utilize-googleapis CXX C) + +# Configure the compiler options, we will be using C++11 features. +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(googleapis REQUIRED) + +add_executable(utilize-googleapis main.cc) +target_link_libraries(utilize-googleapis googleapis-c++::bigtable_protos) diff --git a/ci/test-install/bigtable/main.cc b/ci/test-install/bigtable/main.cc new file mode 100644 index 000000000000..08fce3c7bc68 --- /dev/null +++ b/ci/test-install/bigtable/main.cc @@ -0,0 +1,22 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +int main() { + auto creds = grpc::InsecureChannelCredentials(); + auto channel = grpc::CreateChannel("localhost:12345", creds); + auto stub = google::bigtable::v2::Bigtable::NewStub(channel); +} diff --git a/ci/test-install/compile-test-projects.sh b/ci/test-install/compile-test-projects.sh new file mode 100755 index 000000000000..12487ef54862 --- /dev/null +++ b/ci/test-install/compile-test-projects.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Compile projects that utilize the cpp-cmakefiles header files and libraries +# installed to the system. This script expects that the entire source tree is +# copied to /home/build/cpp-cmakefiles. Don't try to run this locally. + +set -eu + +# For bigtable protos +cp -R /home/build/cpp-cmakefiles/ci/test-install/bigtable \ + /home/build/test-install-bigtable +cd /home/build/test-install-bigtable +cmake -H. -Bcmake-out +cmake --build cmake-out -- -j "$(nproc)" +cmake-out/utilize-googleapis + +# For spanner protos +cp -R /home/build/cpp-cmakefiles/ci/test-install/spanner \ + /home/build/test-install-spanner +cd /home/build/test-install-spanner +cmake -H. -Bcmake-out +cmake --build cmake-out -- -j "$(nproc)" +cmake-out/utilize-googleapis diff --git a/ci/test-install/spanner/CMakeLists.txt b/ci/test-install/spanner/CMakeLists.txt new file mode 100644 index 000000000000..2a4577ace91f --- /dev/null +++ b/ci/test-install/spanner/CMakeLists.txt @@ -0,0 +1,28 @@ +# ~~~ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ~~~ + +cmake_minimum_required(VERSION 3.5) + +project(utilize-googleapis CXX C) + +# Configure the compiler options, we will be using C++11 features. +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(googleapis REQUIRED) + +add_executable(utilize-googleapis main.cc) +target_link_libraries(utilize-googleapis googleapis-c++::spanner_protos) diff --git a/ci/test-install/spanner/main.cc b/ci/test-install/spanner/main.cc new file mode 100644 index 000000000000..f1866655ac7f --- /dev/null +++ b/ci/test-install/spanner/main.cc @@ -0,0 +1,22 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +int main() { + auto creds = grpc::InsecureChannelCredentials(); + auto channel = grpc::CreateChannel("localhost:12345", creds); + auto stub = google::spanner::v1::Spanner::NewStub(channel); +} -- cgit 1.4.1