Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Commit aefb8c9

Browse files
author
Takashi Matsuo
authored
Add ci scripts (#1)
* Add ci scripts * Move config files to ci/kokoro/docker * Remove dump-logs etc * Simplified grpc installation * Add Ubuntu 16.04 kokoro config * Address code review
1 parent 620940a commit aefb8c9

26 files changed

+834
-49
lines changed

CMakeLists.txt

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ set(GOOGLE_CLOUD_CPP_GOOGLEAPIS_SHA256
4545
"6b8a9b2bcb4476e9a5a9872869996f0d639c8d5df76dd8a893e79201f211b1cf")
4646

4747
include(ExternalProject)
48-
externalproject_add(googleapis_download
48+
ExternalProject_Add(googleapis_download
4949
EXCLUDE_FROM_ALL ON
5050
PREFIX "${CMAKE_BINARY_DIR}/external/googleapis"
5151
URL ${GOOGLE_CLOUD_CPP_GOOGLEAPIS_URL}
@@ -54,7 +54,7 @@ externalproject_add(googleapis_download
5454
BUILD_COMMAND ""
5555
INSTALL_COMMAND ""
5656
LOG_DOWNLOAD OFF)
57-
externalproject_get_property(googleapis_download SOURCE_DIR)
57+
ExternalProject_Get_Property(googleapis_download SOURCE_DIR)
5858
set(GOOGLEAPIS_CPP_SOURCE "${SOURCE_DIR}")
5959

6060
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
@@ -267,23 +267,21 @@ install(TARGETS ${googleapis_cpp_installed_libraries_list}
267267

268268
foreach (target ${googleapis_cpp_installed_libraries_list})
269269
google_cloud_cpp_install_proto_library_headers("${target}")
270-
google_cloud_cpp_install_proto_library_protos("${target}" "${GOOGLEAPIS_CPP_SOURCE}")
270+
google_cloud_cpp_install_proto_library_protos("${target}"
271+
"${GOOGLEAPIS_CPP_SOURCE}")
271272
endforeach ()
272273

273274
# Export the CMake targets to make it easy to create configuration files.
274275
install(EXPORT googleapis-targets
275276
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/googleapis")
276277

277278
# Setup global variables used in the following *.in files.
278-
set(
279-
GOOGLE_CLOUD_CPP_CONFIG_VERSION_MAJOR ${GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR}
280-
)
281-
set(
282-
GOOGLE_CLOUD_CPP_CONFIG_VERSION_MINOR ${GOOGLEAPIS_CPP_PROTOS_VERSION_MINOR}
283-
)
284-
set(
285-
GOOGLE_CLOUD_CPP_CONFIG_VERSION_PATCH ${GOOGLEAPIS_CPP_PROTOS_VERSION_PATCH}
286-
)
279+
set(GOOGLE_CLOUD_CPP_CONFIG_VERSION_MAJOR
280+
${GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR})
281+
set(GOOGLE_CLOUD_CPP_CONFIG_VERSION_MINOR
282+
${GOOGLEAPIS_CPP_PROTOS_VERSION_MINOR})
283+
set(GOOGLE_CLOUD_CPP_CONFIG_VERSION_PATCH
284+
${GOOGLEAPIS_CPP_PROTOS_VERSION_PATCH})
287285

288286
# Use a function to create a scope for the variables.
289287
function (googleapis_cpp_install_pc target)
@@ -322,8 +320,8 @@ function (googleapis_cpp_install_pc target)
322320
string(CONCAT GOOGLE_CLOUD_CPP_PC_REQUIRES ${_target_pc_requires})
323321
set(GOOGLE_CLOUD_CPP_PC_LIBS "-l${target}")
324322
configure_file("cmake/config.pc.in" "${target}.pc" @ONLY)
325-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${target}.pc" DESTINATION
326-
"${CMAKE_INSTALL_LIBDIR}/pkgconfig")
323+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${target}.pc"
324+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
327325
endfunction ()
328326

329327
# Create and install the pkg-config files.
@@ -355,8 +353,8 @@ string(CONCAT GOOGLE_CLOUD_CPP_PC_REQUIRES
355353
" libcares")
356354
set(GOOGLE_CLOUD_CPP_PC_LIBS "")
357355
configure_file("cmake/config.pc.in" "googleapis.pc" @ONLY)
358-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/googleapis.pc" DESTINATION
359-
"${CMAKE_INSTALL_LIBDIR}/pkgconfig")
356+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/googleapis.pc"
357+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
360358

361359
# Create and install the CMake configuration files.
362360
configure_file("cmake/config.cmake.in" "googleapis-config.cmake" @ONLY)
@@ -367,5 +365,4 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/googleapis-config.cmake"
367365
"${PROJECT_SOURCE_DIR}/cmake/FindgRPC.cmake"
368366
"${PROJECT_SOURCE_DIR}/cmake/FindProtobufTargets.cmake"
369367
"${PROJECT_SOURCE_DIR}/cmake/CompileProtos.cmake"
370-
DESTINATION
371-
"${CMAKE_INSTALL_LIBDIR}/cmake/googleapis")
368+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/googleapis")

ci/check-style.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2019 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -eu
17+
18+
if [[ "${CHECK_STYLE}" != "yes" ]]; then
19+
echo "Skipping code style check as it is disabled for this build."
20+
exit 0
21+
fi
22+
23+
# This script assumes it is running the top-level google-cloud-cpp directory.
24+
25+
readonly BINDIR="$(dirname "$0")"
26+
27+
# Build paths to ignore in find(1) commands by reading .gitignore.
28+
declare -a ignore=( -path ./.git )
29+
if [[ -f .gitignore ]]; then
30+
while read -r line; do
31+
case "${line}" in
32+
[^#]*/*) ignore+=( -o -path "./$(expr "${line}" : '\(.*\)/')" ) ;;
33+
[^#]*) ignore+=( -o -name "${line}" ) ;;
34+
esac
35+
done < .gitignore
36+
fi
37+
38+
replace_original_if_changed() {
39+
if [[ $# != 2 ]]; then
40+
return 1
41+
fi
42+
43+
local original="$1"
44+
local reformatted="$2"
45+
46+
if cmp -s "${original}" "${reformatted}"; then
47+
rm -f "${reformatted}"
48+
else
49+
chmod --reference="${original}" "${reformatted}"
50+
mv -f "${reformatted}" "${original}"
51+
fi
52+
}
53+
54+
# Apply cmake_format to all the CMake list files.
55+
# https://github.com/cheshirekow/cmake_format
56+
find . \( "${ignore[@]}" \) -prune -o \
57+
\( -name 'CMakeLists.txt' -o -name '*.cmake' \) \
58+
-print0 |
59+
while IFS= read -r -d $'\0' file; do
60+
cmake-format "${file}" >"${file}.tmp"
61+
replace_original_if_changed "${file}" "${file}.tmp"
62+
done
63+
64+
# Apply buildifier to fix the BUILD and .bzl formatting rules.
65+
# https://github.com/bazelbuild/buildtools/tree/master/buildifier
66+
find . \( "${ignore[@]}" \) -prune -o \
67+
\( -name BUILD -o -name '*.bzl' \) \
68+
-print0 |
69+
xargs -0 buildifier -mode=fix
70+
71+
# Apply shellcheck(1) to emit warnings for common scripting mistakes.
72+
find . \( "${ignore[@]}" \) -prune -o \
73+
-iname '*.sh' -exec shellcheck \
74+
--exclude=SC1090 \
75+
--exclude=SC2034 \
76+
--exclude=SC2153 \
77+
--exclude=SC2181 \
78+
'{}' \;
79+
80+
# Report any differences created by running the formatting tools.
81+
git diff --ignore-submodules=all --color --exit-code .

ci/colors.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2019 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
if [ -z "${COLOR_RESET+x}" ]; then
17+
if type tput >/dev/null 2>&1; then
18+
readonly COLOR_RED="$(tput setaf 1)"
19+
readonly COLOR_GREEN="$(tput setaf 2)"
20+
readonly COLOR_YELLOW="$(tput setaf 3)"
21+
readonly COLOR_RESET="$(tput sgr0)"
22+
else
23+
readonly COLOR_RED=""
24+
readonly COLOR_GREEN=""
25+
readonly COLOR_YELLOW=""
26+
readonly COLOR_RESET=""
27+
fi
28+
fi

ci/install-grpc.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2019 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -eu
17+
18+
mkdir -p /var/tmp/Downloads
19+
cd /var/tmp/Downloads
20+
21+
# Install protobuf
22+
wget -q https://github.com/google/protobuf/archive/v3.8.0.tar.gz
23+
tar -xf v3.8.0.tar.gz
24+
(cd protobuf-3.8.0/cmake;
25+
cmake \
26+
-DCMAKE_BUILD_TYPE=Release \
27+
-DBUILD_SHARED_LIBS=yes \
28+
-Dprotobuf_BUILD_TESTS=OFF \
29+
-H. -Bcmake-out
30+
cmake --build cmake-out --target install -- -j "$(nproc)"
31+
ldconfig
32+
)
33+
34+
# Install grpc
35+
wget -q https://github.com/grpc/grpc/archive/v1.22.0.tar.gz
36+
tar -xf v1.22.0.tar.gz
37+
(cd grpc-1.22.0;
38+
make -j "$(nproc)"
39+
make install
40+
ldconfig
41+
)

ci/kokoro/Dockerfile.centos

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2019 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ARG DISTRO_VERSION=7
16+
FROM centos:${DISTRO_VERSION}
17+
18+
# Add /usr/local/lib
19+
20+
# Search paths tweak for the build
21+
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig
22+
ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64
23+
ENV PATH=/usr/local/bin:${PATH}
24+
25+
# First install the development tools and OpenSSL. The development tools
26+
# distributed with CentOS (notably CMake) are too old to build
27+
# `google-cloud-cpp`. In these instructions, we use `cmake3` obtained from
28+
# [Software Collections](https://www.softwarecollections.org/).
29+
30+
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
31+
RUN yum install -y centos-release-scl
32+
RUN yum-config-manager --enable rhel-server-rhscl-7-rpms
33+
RUN yum makecache && \
34+
yum install -y automake cmake3 curl-devel gcc gcc-c++ git libtool \
35+
make openssl-devel pkgconfig tar wget which zlib-devel
36+
RUN ln -sf /usr/bin/cmake3 /usr/bin/cmake && ln -sf /usr/bin/ctest3 /usr/bin/ctest
37+
38+
# Install c-ares
39+
RUN mkdir -p /var/tmp/Downloads; \
40+
cd /var/tmp/Downloads; \
41+
wget -q https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz; \
42+
tar -xf cares-1_15_0.tar.gz; \
43+
cd /var/tmp/Downloads/c-ares-cares-1_15_0; \
44+
./buildconf && ./configure && make -j $(nproc); \
45+
make install; \
46+
ldconfig
47+
48+
# Install grpc from source
49+
WORKDIR /var/tmp/ci
50+
COPY install-grpc.sh /var/tmp/ci
51+
RUN /var/tmp/ci/install-grpc.sh
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright 2019 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ARG DISTRO_VERSION=30
16+
FROM fedora:${DISTRO_VERSION}
17+
18+
# Fedora includes packages for gRPC, libcurl, and OpenSSL that are recent enough
19+
# for `google-cloud-cpp`. Install these packages and additional development
20+
# tools to compile the dependencies:
21+
RUN dnf makecache && \
22+
dnf install -y clang clang-tools-extra cmake doxygen findutils gcc-c++ git \
23+
grpc-devel grpc-plugins libcxx-devel libcxxabi-devel libcurl-devel \
24+
make openssl-devel pkgconfig protobuf-compiler python-pip ShellCheck \
25+
tar wget zlib-devel
26+
27+
# Install the the buildifier tool, which does not compile with the default
28+
# golang compiler for Ubuntu 16.04 and Ubuntu 18.04.
29+
RUN wget -q -O /usr/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/0.17.2/buildifier
30+
RUN chmod 755 /usr/bin/buildifier
31+
32+
# Install cmake_format to automatically format the CMake list files.
33+
# https://github.com/cheshirekow/cmake_format
34+
# Pin this to an specific version because the formatting changes when the
35+
# "latest" version is updated, and we do not want the builds to break just
36+
# because some third party changed something.
37+
RUN pip install --upgrade pip
38+
RUN pip install numpy cmake_format==0.5.2

0 commit comments

Comments
 (0)