Skip to content

Commit

Permalink
feat conan: do not use CPM in conan, test more services
Browse files Browse the repository at this point in the history
------------------------
Note: by creating a PR or an issue you automatically agree to the CLA. See [CONTRIBUTING.md](https://github.com/userver-framework/userver/blob/develop/CONTRIBUTING.md). Feel free to remove this note, the agreement holds.

Tests: протестировано CI

Pull Request resolved: #835
commit_hash:893bb174d88f39bf2fdbcb76c6f74c51ca300036
  • Loading branch information
fdr400 committed Jan 20, 2025
1 parent cca0c66 commit 39f5100
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 16 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/ci-conan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,29 @@ jobs:
- name: Install Ubuntu packages
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get install -y gcc g++ cmake wget git python3 python3-pip python3-venv postgresql redis clang-format
sudo apt update
sudo apt install -y \
gcc g++ cmake wget git clang-format \
python3 python3-pip python3-venv
- name: Install test dependencies
if: matrix.os == 'ubuntu-22.04'
run: |
wget -qO- https://pgp.mongodb.com/server-7.0.asc | sudo gpg --dearmor | sudo tee /usr/share/keyrings/mongodb-server-7.0.gpg >/dev/null
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" \
| sudo tee -a /etc/apt/sources.list.d/mongodb-org-7.0.list
sudo apt update
sudo apt install -y postgresql redis mongodb-org mongodb-mongosh
sudo ./scripts/kafka/ubuntu_install_kafka.sh
./scripts/rabbitmq/ubuntu_install_rabbitmq_server.sh
- name: Install MacOS packages
if: matrix.os == 'macos-latest'
run: |
brew update
brew install postgresql redis clang-format
brew tap mongodb/brew
brew install clang-format postgresql redis kafka rabbitmq mongodb-community
brew install [email protected]
- name: Install common packages
Expand All @@ -64,9 +80,14 @@ jobs:
chaotic_service \
embedded_files \
grpc_service \
otlp_service \
hello_service \
https_service \
postgres_service \
redis_service \
kafka_service \
rabbitmq_service \
mongo_service \
s3api \
; do
mv conanfile.py $SAMPLE/
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,6 @@ jobs:
| sudo tee -a /etc/apt/sources.list.d/mongodb-org-7.0.list
# Mongo is not officially supported on Ubuntu 24.04, so install it from jammy
# Install Kafka
sudo apt install -y default-jre
curl https://dlcdn.apache.org/kafka/3.8.0/kafka_2.13-3.8.0.tgz -o kafka.tgz
sudo mkdir -p /etc/kafka
sudo tar xf kafka.tgz --directory=/etc/kafka
sudo cp -r /etc/kafka/kafka_2.13-3.8.0/* /etc/kafka/
sudo rm -rf /etc/kafka/kafka_2.13-3.8.0
ls -lha /etc/kafka
- name: Install common deps
run: |
sudo apt update
Expand Down Expand Up @@ -234,6 +225,10 @@ jobs:
run: |
sudo apt install --allow-downgrades -y g++-8
- name: Install Kafka
run: |
sudo ./scripts/kafka/ubuntu_install_kafka.sh
- name: Install RabbitMQ packages
run: |
./scripts/rabbitmq/ubuntu_install_rabbitmq_server.sh
Expand Down
1 change: 1 addition & 0 deletions .mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -3651,6 +3651,7 @@
"scripts/grpc/templates/service.usrv.hpp.jinja":"taxi/uservices/userver/scripts/grpc/templates/service.usrv.hpp.jinja",
"scripts/grpc/templates/utils.inc.jinja":"taxi/uservices/userver/scripts/grpc/templates/utils.inc.jinja",
"scripts/human_logs.py":"taxi/uservices/userver/scripts/human_logs.py",
"scripts/kafka/ubuntu_install_kafka.sh":"taxi/uservices/userver/scripts/kafka/ubuntu_install_kafka.sh",
"scripts/migrate_from_legacy_redis_ns.sh":"taxi/uservices/userver/scripts/migrate_from_legacy_redis_ns.sh",
"scripts/perf-blocking-syscall":"taxi/uservices/userver/scripts/perf-blocking-syscall",
"scripts/postgres/pg_sql_codes.py":"taxi/uservices/userver/scripts/postgres/pg_sql_codes.py",
Expand Down
4 changes: 4 additions & 0 deletions cmake/DownloadUsingCPM.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
include_guard()

if(USERVER_CONAN)
message(FATAL_ERROR "Do not use CPM in Conan")
endif()

if(NOT DEFINED CPM_USE_NAMED_CACHE_DIRECTORIES)
set(CPM_USE_NAMED_CACHE_DIRECTORIES ON)
endif()
Expand Down
6 changes: 4 additions & 2 deletions cmake/SetupGoogleProtoApis.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ if (NOT api-common-protos_SOURCE_DIR)
endif()

include(UserverGrpcTargets)
file(GLOB_RECURSE SOURCES
${api-common-protos_SOURCE_DIR}/*.proto)
file(GLOB SOURCES
${api-common-protos_SOURCE_DIR}/google/api/*.proto
${api-common-protos_SOURCE_DIR}/google/rpc/*.proto
)

userver_generate_grpc_files(
PROTOS ${SOURCES}
Expand Down
2 changes: 1 addition & 1 deletion cmake/UserverGrpcTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function(userver_generate_grpc_files)
foreach(proto_file ${GEN_RPC_PROTOS})
get_filename_component(proto_file "${proto_file}" REALPATH BASE_DIR "${root_path}")
get_filename_component(path "${proto_file}" DIRECTORY)
get_filename_component(name_base "${proto_file}" NAME_WE)
get_filename_component(name_base "${proto_file}" NAME_WLE)
file(RELATIVE_PATH path_base "${root_path}" "${path}/${name_base}")
list(APPEND proto_abs_paths "${proto_file}")
list(APPEND proto_rel_paths "${path_base}")
Expand Down
2 changes: 1 addition & 1 deletion cmake/install/userver-otlp-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if(userver_otlp_FOUND)
endif()

find_package(userver REQUIRED COMPONENTS
core
core grpc
)

set(userver_otlp_FOUND TRUE)
15 changes: 15 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ def requirements(self):
'protobuf/5.27.0',
transitive_headers=True,
transitive_libs=True,
force=True,
)
self.requires('googleapis/cci.20230501')
if self.options.with_postgresql:
self.requires('libpq/14.5')
if self.options.with_mongodb or self.options.with_kafka:
Expand Down Expand Up @@ -162,6 +164,8 @@ def requirements(self):
self.requires('librdkafka/2.6.0')
if self.options.with_s3api:
self.requires('pugixml/1.14')
if self.options.with_otlp:
self.requires('opentelemetry-proto/1.3.0')

def build_requirements(self):
self.tool_requires('protobuf/5.27.0')
Expand Down Expand Up @@ -206,6 +210,17 @@ def generate(self):
tool_ch.variables['USERVER_FEATURE_EASY'] = self.options.with_easy
tool_ch.variables['USERVER_FEATURE_S3API'] = self.options.with_s3api
tool_ch.variables['USERVER_FEATURE_GRPC_REFLECTION'] = self.options.with_grpc_reflection

if self.options.with_grpc:
tool_ch.variables['USERVER_GOOGLE_COMMON_PROTOS'] = (
self.dependencies['googleapis'].cpp_info.components['google_rpc_status_proto'].resdirs[0]
)

if self.options.with_otlp:
tool_ch.variables['USERVER_OPENTELEMETRY_PROTO'] = self.dependencies['opentelemetry-proto'].conf_info.get(
'user.opentelemetry-proto:proto_root'
)

tool_ch.generate()

CMakeDeps(self).generate()
Expand Down
2 changes: 1 addition & 1 deletion grpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ _userver_directory_install(COMPONENT grpc
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/..
)
if (DEFINED api-common-proto_LIBRARY)
if(DEFINED api-common-proto_LIBRARY)
target_link_libraries(${PROJECT_NAME}-internal PUBLIC ${api-common-proto_LIBRARY})
_userver_install_targets(COMPONENT grpc TARGETS ${api-common-proto_LIBRARY})
endif()
Expand Down
3 changes: 3 additions & 0 deletions samples/otlp_service/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 3.14)
project(userver-samples-otlp_service CXX)

find_package(userver COMPONENTS otlp REQUIRED)

add_executable(${PROJECT_NAME} "otlp_service.cpp")
target_link_libraries(${PROJECT_NAME} userver::otlp)

Expand Down
10 changes: 10 additions & 0 deletions scripts/kafka/ubuntu_install_kafka.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

sudo apt install -y default-jre

curl https://dlcdn.apache.org/kafka/3.8.0/kafka_2.13-3.8.0.tgz -o kafka.tgz
mkdir -p /etc/kafka
tar xf kafka.tgz --directory=/etc/kafka
cp -r /etc/kafka/kafka_2.13-3.8.0/* /etc/kafka/
rm -rf /etc/kafka/kafka_2.13-3.8.0
rm kafka.tgz

0 comments on commit 39f5100

Please sign in to comment.