Skip to content

Commit 6c95be2

Browse files
committed
Build the Google storage sample file on the CI
This is just to check that the CI builds ok. TODO: revert this commit before merging
1 parent e8c865b commit 6c95be2

File tree

6 files changed

+45
-3
lines changed

6 files changed

+45
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ if (CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE_UC STREQUAL "RELWIT
159159
endif()
160160

161161
option(ENABLE_TESTS "Provide unit_test_dbms target with Google.Test unit tests" ON)
162-
option(ENABLE_EXAMPLES "Build all example programs in 'examples' subdirectories" OFF)
162+
option(ENABLE_EXAMPLES "Build all example programs in 'examples' subdirectories" ON)
163163
option(ENABLE_BENCHMARKS "Build all benchmark programs in 'benchmarks' subdirectories" OFF)
164164

165165
if (OS_LINUX AND (ARCH_AMD64 OR ARCH_AARCH64) AND NOT USE_MUSL)

ci/jobs/build_clickhouse.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ def main():
172172
run_shell("clang-tidy-cache stats", "clang-tidy-cache --show-stats")
173173
else:
174174
targets = "clickhouse-bundle"
175+
176+
targets += " gcs"
175177
results.append(
176178
Result.from_commands_run(
177179
name="Build ClickHouse",

ci/jobs/scripts/check_style/check_cpp.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
LC_ALL="en_US.UTF-8"
1616
ROOT_PATH="."
17-
EXCLUDE='build/|integration/|widechar_width/|glibc-compatibility/|poco/|memcpy/|consistent-hashing|benchmark|tests/.*.cpp|programs/keeper-bench/example.yaml|base/base/openpty.h'
17+
EXCLUDE='build/|integration/|widechar_width/|glibc-compatibility/|poco/|memcpy/|consistent-hashing|benchmark|tests/.*.cpp|programs/keeper-bench/example.yaml|base/base/openpty.h|gcs.cpp'
1818
EXCLUDE_DOCS='Settings\.cpp|FormatFactorySettings\.h'
1919

2020
# From [1]:

contrib/google-cloud-cpp-cmake/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(ENABLE_GOOGLE_CLOUD_CPP_DEFAULT OFF)
1+
set(ENABLE_GOOGLE_CLOUD_CPP_DEFAULT ON)
22

33
if(ENABLE_LIBRARIES AND CLICKHOUSE_CLOUD AND OS_LINUX)
44
set(ENABLE_GOOGLE_CLOUD_CPP_DEFAULT ON)

src/Core/examples/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ target_link_libraries (field PRIVATE dbms)
66

77
clickhouse_add_executable (string_ref_hash string_ref_hash.cpp)
88
target_link_libraries (string_ref_hash PRIVATE clickhouse_common_io clickhouse_common_config)
9+
10+
clickhouse_add_executable (gcs gcs.cpp)
11+
target_link_libraries (gcs PRIVATE clickhouse_common_io clickhouse_common_config dbms)

src/Core/examples/gcs.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <google/cloud/storage/client.h>
2+
#include <iostream>
3+
#include <string>
4+
5+
int main(int argc, char* argv[]) {
6+
if (argc != 2) {
7+
std::cerr << "Missing bucket name.\n";
8+
std::cerr << "Usage: quickstart <bucket-name>\n";
9+
return 1;
10+
}
11+
std::string const bucket_name = argv[1];
12+
13+
// Create a client to communicate with Google Cloud Storage. This client
14+
// uses the default configuration for authentication and project id.
15+
auto client = google::cloud::storage::Client();
16+
17+
auto writer = client.WriteObject(bucket_name, "quickstart.txt");
18+
writer << "Hello World!";
19+
writer.Close();
20+
if (!writer.metadata()) {
21+
std::cerr << "Error creating object: " << writer.metadata().status()
22+
<< "\n";
23+
return 1;
24+
}
25+
std::cout << "Successfully created object: " << *writer.metadata() << "\n";
26+
27+
auto reader = client.ReadObject(bucket_name, "quickstart.txt");
28+
if (!reader) {
29+
std::cerr << "Error reading object: " << reader.status() << "\n";
30+
return 1;
31+
}
32+
33+
std::string contents{std::istreambuf_iterator<char>{reader}, {}};
34+
std::cout << contents << "\n";
35+
36+
return 0;
37+
}

0 commit comments

Comments
 (0)