Skip to content

Commit

Permalink
Drop submodule (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
sabudilovskiy authored Apr 11, 2024
1 parent 5eb2327 commit 7b05fee
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 28 deletions.
30 changes: 20 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,28 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: init submdule userver
- name: install based dependencies
run: |
sudo git submodule update --init --recursive
sudo apt install cmake
sudo apt install ninja-build
sudo make install-compiler compiler=${{matrix.compiler}} version=${{matrix.version}}
- name: add Postgres package repository
run: |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
- name: Fetch userver
continue-on-error: true
run: >
cmake
-B cmake_build
-G Ninja
-DCMAKE_BUILD_TYPE=${{matrix.type}}
-DCMAKE_C_COMPILER=$(make find-c-compiler compiler=${{matrix.compiler}} version=${{matrix.version}})
-DCMAKE_CXX_COMPILER=$(make find-cxx-compiler compiler=${{matrix.compiler}} version=${{matrix.version}})
- name: Install packages
run: |
sudo apt update
sudo apt install --allow-downgrades -y pep8 $(cat uopenapi/userver/scripts/docs/en/deps/${{matrix.os}}.md | tr '\n' ' ')
- name: install compiler
run: |
sudo make install-compiler compiler=${{matrix.compiler}} version=${{matrix.version}}
sudo apt install --allow-downgrades -y pep8 $(cat cmake_build/_deps/userver-src/scripts/docs/en/deps/${{matrix.os}}.md | tr '\n' ' ')
- name: run codegen
run: |
sudo make gen-queries
Expand All @@ -84,11 +92,13 @@ jobs:
run: |
ccache -M 2.0GB
ccache -s
- name: Drom cmake build folder
run: |
rm -rf cmake_build
- name: Configure cmake project
run: >
cmake
-B cmake_build_main
-B cmake_build
-G Ninja
-DCMAKE_BUILD_TYPE=${{matrix.type}}
-DCMAKE_C_COMPILER=$(make find-c-compiler compiler=${{matrix.compiler}} version=${{matrix.version}})
Expand All @@ -97,10 +107,10 @@ jobs:
- name: Build project
run: >
cmake
--build cmake_build_main
--build cmake_build
--target all
- name: Run tests
run: |
cd cmake_build_main
cd cmake_build
(test -t 1 && GTEST_COLOR=1 PYTEST_ADDOPTS="--color=yes" ctest -V) || ctest -V
18 changes: 10 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,27 @@ set(CMAKE_CXX_STANDARD 20)

set(openapi-extension-userver_BUILD_UNIT_TESTS false)
set(openapi-extension-userver_BUILD_TEST_SERVICES false)
set(USERVER_LTO OFF)

add_subdirectory(uopenapi)

include(uopenapi/CMake/CreatePart.cmake)
set(USERVER_FEATURE_POSTGRESQL ON)

enable_testing()
include(FetchContent)
FetchContent_Declare(
uopenapi
GIT_REPOSITORY https://github.com/sabudilovskiy/userver-openapi-extension
GIT_TAG "26b3160c9a3317fe15b7c569de70f1e3fbc70592"
)
FetchContent_MakeAvailable(uopenapi)

CreateTrivialPart(
name "src"
path "/src"
)

target_link_libraries(${src_module} PUBLIC openapi-extension-userver_library)
target_link_libraries(${src_module} PUBLIC userver-postgresql)
target_compile_options(${src_module} PUBLIC "-Wno-missing-field-initializers")

add_executable(service service/main.cpp)

target_link_libraries(service PUBLIC ${src_module})

include(uopenapi/userver/cmake/UserverTestsuite.cmake)
SET(USERVER_PYTHON "python3")
userver_testsuite_add_simple()
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ find-c-compiler:

.PHONY: format
format:
python3.10 uopenapi/scripts/generate_all_headers.py library/uopenapi uopenapi
python3.10 uopenapi/scripts/format_includes.py library boost uopenapi checks
python3.10 scripts/format_includes.py library boost uopenapi checks
find checks -name '*pp' -type f | xargs clang-format-17 -i
find library -name '*pp' -type f | xargs clang-format-17 -i
make add-eol P=tests
Expand Down
5 changes: 3 additions & 2 deletions configs/static_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,16 @@ components_manager:
blocking_task_processor: fs-task-processor
dns_resolver: async
sync-start: true
openapi-descriptor:
schema-storage:
servers:
- description: stable
url: http://51.250.86.220
load-enabled: true
path: /openapi
info:
title: Some Server Doc
description: Some server
version: 1.0.0
schema-http-distributor:
path: /openapi
method: GET
task_processor: main-task-processor
56 changes: 56 additions & 0 deletions scripts/format_includes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import os
import sys

def check_line(line: str, words):
index_include: int = line.find("#include")
if index_include == -1:
return False
index_include += len('#include')
line_after_include = line[index_include:]
index: int = line_after_include.find("\"") + 1
if (index == 0):
return False
file = line_after_include[index:]
for word in words:
if (file.startswith(word)):
return True
return False


def format_line(line: str):
return line.replace("\"", "<", 1).replace("\"", ">", 1)



def format_file(input_path, words):
with open(input_path, 'r') as file:
content = file.readlines()

formatted_content = []
for line in content:
if check_line(line, words):
formatted_content.append(format_line(line))
else:
formatted_content.append(line)

with open(input_path, 'w') as file:
file.writelines(formatted_content)

def format_directory(directory, words):
for root, _, files in os.walk(directory):
for file_name in files:
if file_name.endswith(('.hpp', '.cpp')):
file_path = os.path.join(root, file_name)
format_file(file_path, words)
def main():
if len(sys.argv) < 3:
print('Usage: python3 format_includes.py <directory> start_words...')
return

input_path = sys.argv[1]
words = sys.argv[2:]
format_directory(input_path, words)


if __name__ == '__main__':
main()
6 changes: 4 additions & 2 deletions service/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include <userver/utils/daemon_run.hpp>
#include <views/login/handler_fwd.hpp>
#include <views/register/handler_fwd.hpp>
#include <uopenapi/http/openapi_descriptor.h>
#include <uopenapi/components/schema/schema_storage.hpp>
#include <uopenapi/components/schema/schema_http_distributor.hpp>
#include <userver/storages/postgres/component.hpp>

int main(int argc, char* argv[]) {
Expand All @@ -17,7 +18,8 @@ int main(int argc, char* argv[]) {
.Append<userver::components::HttpClient>()
.Append<userver::clients::dns::Component>()
.Append<userver::server::handlers::TestsControl>();
component_list.Append<uopenapi::http::openapi_descriptor>();
component_list.Append<uopenapi::components::schema_storage>();
component_list.Append<uopenapi::components::schema_http_distributor>();
component_list.Append<userver::components::Postgres>("todo_db");
views::login::Append(component_list);
views::Register::Append(component_list);
Expand Down
2 changes: 1 addition & 1 deletion src/models/error_response.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include <string>
#include <uopenapi/enum/declare.hpp>
#include <uopenapi/enum_helpers/declare.hpp>

namespace models{
UOPENAPI_DECLARE_ENUM(ErrorCode,
Expand Down
2 changes: 1 addition & 1 deletion src/views/login/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <userver/formats/serialize/boost_uuid.hpp>

namespace views::login{
using base = uopenapi::http::openapi_handler<Request,Response200,Response400 >;
using base = uopenapi::components::openapi_handler<Request,Response200,Response400 >;
struct handler : base{
static constexpr std::string_view kName = "login_handler";
handler(const userver::components::ComponentConfig& cfg,
Expand Down
2 changes: 1 addition & 1 deletion src/views/register/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <userver/formats/serialize/boost_uuid.hpp>

namespace views::Register{
using base = uopenapi::http::openapi_handler<Request,Response200,Response400 >;
using base = uopenapi::components::openapi_handler<Request,Response200,Response400 >;
struct handler : base{
static constexpr std::string_view kName = "register_handler";
handler(const userver::components::ComponentConfig& cfg,
Expand Down
1 change: 0 additions & 1 deletion uopenapi
Submodule uopenapi deleted from 87b98f

0 comments on commit 7b05fee

Please sign in to comment.