Skip to content

Commit

Permalink
feat conan: build and test more components
Browse files Browse the repository at this point in the history
Fixes: #664

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

Pull Request resolved: #818
commit_hash:a282d1be391e9cc65fa56e30a0b1cdacb352a7b2
  • Loading branch information
apolukhin committed Jan 6, 2025
1 parent 21f05d1 commit 19324d9
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 14 deletions.
28 changes: 20 additions & 8 deletions .github/workflows/ci-conan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,17 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- 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
sudo apt-get install -y gcc g++ cmake wget git python3 python3-pip python3-venv postgresql redis clang-format
- name: Install MacOS packages
if: matrix.os == 'macos-latest'
run: |
brew update
brew install postgresql
brew install postgresql redis clang-format
brew install libiconv # https://stackoverflow.com/questions/57734434/libiconv-or-iconv-undefined-symbol-on-mac-osx
brew install [email protected]
Expand All @@ -56,9 +54,23 @@ jobs:
- name: Test userver conan package
run: |
mv libraries/easy/samples/3_json samples/
mv scripts/tests/conanfile.py samples/
rm -rf userver/cmake/
cd samples/
USERVER_VERSION=$(conan list -c -v quiet userver/* | tail -n 1)
for SAMPLE in hello_service embedded_files postgres_service grpc_service; do
cp scripts/tests/conanfile.py samples/$SAMPLE/
conan test samples/$SAMPLE/ --build=never -s:a compiler.cppstd=17 -pr:b=default ${{matrix.conanflags}} ${USERVER_VERSION}
rm samples/$SAMPLE/conanfile.py
for SAMPLE in \
3_json \
chaotic_service \
embedded_files \
grpc_service \
hello_service \
postgres_service \
redis_service \
s3api \
; do
mv conanfile.py $SAMPLE/
conan test $SAMPLE/ --build=never -s:a compiler.cppstd=17 -pr:b=default ${{matrix.conanflags}} ${USERVER_VERSION}
mv $SAMPLE/conanfile.py ./
done
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Reuse ccache directory
uses: actions/cache@v4
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
| Core: | [![CI](https://github.com/userver-framework/service_template/actions/workflows/ci.yml/badge.svg) ![Docker build](https://github.com/userver-framework/service_template/actions/workflows/docker.yaml/badge.svg)](https://github.com/userver-framework/service_template/) | [[]](https://github.com/userver-framework/service_template/tree/v2.0) | [[]](https://github.com/userver-framework/service_template/tree/v1.0.0) |
| PostgreSQL: | [![CI](https://github.com/userver-framework/pg_service_template/actions/workflows/ci.yml/badge.svg) ![Docker build](https://github.com/userver-framework/pg_service_template/actions/workflows/docker.yaml/badge.svg)](https://github.com/userver-framework/pg_service_template/) | [[]](https://github.com/userver-framework/pg_service_template/tree/v2.0) | [[]](https://github.com/userver-framework/pg_service_template/tree/v1.0.0) |
| gRPC+PostgreSQL: | [![CI](https://github.com/userver-framework/pg_grpc_service_template/actions/workflows/ci.yml/badge.svg) ![Docker build](https://github.com/userver-framework/pg_grpc_service_template/actions/workflows/docker.yaml/badge.svg)](https://github.com/userver-framework/pg_grpc_service_template)| [[]](https://github.com/userver-framework/pg_grpc_service_template/tree/v2.0) | [[]](https://github.com/userver-framework/pg_grpc_service_template/tree/v1.0.0) |
| gRPC+Mongo: | [![CI](https://github.com/userver-framework/mongo_grpc_service_template/actions/workflows/ci.yml/badge.svg) ![Docker build](https://github.com/userver-framework/mongo_grpc_service_template/actions/workflows/docker.yaml/badge.svg)](https://github.com/userver-framework/mongo_grpc_service_template)|||

**userver** is an open source asynchronous framework with a rich set of abstractions
for fast and comfortable creation of C++ microservices, services and utilities.
Expand Down
6 changes: 5 additions & 1 deletion cmake/install/userver-s3api-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ find_package(userver REQUIRED COMPONENTS
core
)

include("${USERVER_CMAKE_DIR}/modules/FindPugixml.cmake")
if(USERVER_CONAN)
find_package(pugixml REQUIRED CONFIG)
else()
include("${USERVER_CMAKE_DIR}/modules/FindPugixml.cmake")
endif()

set(userver_s3api_FOUND TRUE)

6 changes: 4 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class UserverConan(ConanFile):
'with_kafka': True,
'with_otlp': True,
'with_easy': True,
'with_s3api': False,
'with_grpc_reflection': False,
'with_s3api': True,
'with_grpc_reflection': True,
'namespace': 'userver',
'namespace_begin': 'namespace userver {',
'namespace_end': '}',
Expand Down Expand Up @@ -159,6 +159,8 @@ def requirements(self):
)
if self.options.with_kafka:
self.requires('librdkafka/2.6.0')
if self.options.with_s3api:
self.requires('pugixml/1.14')

def build_requirements(self):
self.tool_requires('protobuf/5.27.0')
Expand Down
2 changes: 2 additions & 0 deletions libraries/easy/samples/0_hello_world/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
project(userver-easy-samples-hello-world CXX)

find_package(userver COMPONENTS easy REQUIRED)

add_executable(${PROJECT_NAME} "main.cpp")
target_link_libraries(${PROJECT_NAME} userver::easy)

Expand Down
2 changes: 2 additions & 0 deletions libraries/easy/samples/1_hi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
project(userver-easy-samples-hi CXX)

find_package(userver COMPONENTS easy REQUIRED)

add_executable(${PROJECT_NAME} "main.cpp")
target_link_libraries(${PROJECT_NAME} userver::easy)

Expand Down
2 changes: 2 additions & 0 deletions libraries/easy/samples/2_key_value/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
project(userver-easy-samples-key-value CXX)

find_package(userver COMPONENTS easy REQUIRED)

add_executable(${PROJECT_NAME} "main.cpp")
target_link_libraries(${PROJECT_NAME} userver::easy)

Expand Down
3 changes: 3 additions & 0 deletions libraries/easy/samples/3_json/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 3.14)
project(userver-easy-samples-json CXX)

find_package(userver COMPONENTS easy chaotic REQUIRED)

file(GLOB_RECURSE SCHEMAS ${CMAKE_CURRENT_SOURCE_DIR}/schemas/*.yaml)
userver_target_generate_chaotic(${PROJECT_NAME}-chgen
ARGS
Expand Down
2 changes: 2 additions & 0 deletions libraries/easy/samples/4_custom_dependency/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
project(userver-easy-samples-custom-dependency CXX)

find_package(userver COMPONENTS easy REQUIRED)

add_executable(${PROJECT_NAME} "main.cpp")
target_link_libraries(${PROJECT_NAME} userver::easy)

Expand Down
2 changes: 2 additions & 0 deletions libraries/easy/samples/5_pg_service_template/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
project(userver-easy-samples-pg-service-template CXX)

find_package(userver COMPONENTS easy REQUIRED)

add_executable(${PROJECT_NAME} "src/main.cpp")
target_link_libraries(${PROJECT_NAME} userver::easy)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
project(userver-easy-samples-pg-service-template-no-http-with CXX)

find_package(userver COMPONENTS easy REQUIRED)

add_executable(${PROJECT_NAME} "src/main.cpp")
target_link_libraries(${PROJECT_NAME} userver::easy)

Expand Down
7 changes: 7 additions & 0 deletions libraries/easy/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ project(userver-easy-samples CXX)

add_custom_target(${PROJECT_NAME})

# Imitate an installed userver in samples.
file(WRITE "${CMAKE_BINARY_DIR}/package_stubs/userverConfig.cmake")

add_subdirectory(0_hello_world)
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}-hello-world)

Expand All @@ -22,3 +25,7 @@ add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}-pg-service-template)

add_subdirectory(6_pg_service_template_no_http_with)
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}-pg-service-template-no-http-with)

# Clean up fake userver installation above to avoid messing
# with find_package(userver) in the parent project.
file(REMOVE "${CMAKE_BINARY_DIR}/package_stubs/userverConfig.cmake")
7 changes: 6 additions & 1 deletion libraries/s3api/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
project(userver-s3api CXX)

find_package(Pugixml REQUIRED)
if(USERVER_CONAN)
find_package(pugixml REQUIRED CONFIG)
add_library(Pugixml ALIAS pugixml::pugixml)
else()
find_package(Pugixml REQUIRED)
endif()

userver_module(s3api
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
Expand Down

0 comments on commit 19324d9

Please sign in to comment.