Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c1c11e9
refactor-[]: тестовый комит
Mar 3, 2025
2e7586d
Update main.cpp
AndrewMashkin Mar 3, 2025
3d63221
feat-[]: add gitignore
Mar 6, 2025
da35eed
refactor-[]: приведение проекта к структуре с разделением модулей
Mar 6, 2025
75ed4e0
feat-[]: add unittest
Mar 6, 2025
8310903
refactor-[]: lib -> libs
Mar 6, 2025
8d1fc43
Update release.yml
AndrewMashkin Mar 6, 2025
51cd1ac
refactor-[]: ctest on
Mar 6, 2025
d01656a
Merge branch 'master' of github.com:AndrewMashkin/otus-cpp
Mar 6, 2025
ac40f23
Update release.yml
AndrewMashkin Mar 6, 2025
bfb31cb
Update release.yml
AndrewMashkin Mar 6, 2025
bc54636
Update release.yml
AndrewMashkin Mar 6, 2025
2d3ff9e
Update release.yml
AndrewMashkin Mar 6, 2025
1d9783c
refactor-[]: mv test -> getest_frame_work
Mar 6, 2025
d316f3f
Merge branch 'master' of github.com:AndrewMashkin/otus-cpp
Mar 6, 2025
87b1912
Update release.yml
AndrewMashkin Mar 6, 2025
1ada7c6
Update release.yml
AndrewMashkin Mar 6, 2025
a406ddb
refactor-[]: add cpack name
Mar 6, 2025
ed95d61
Merge branch 'master' of github.com:AndrewMashkin/otus-cpp
Mar 6, 2025
beb491a
Update release.yml
AndrewMashkin Mar 6, 2025
a942736
Update unittest.cmake
AndrewMashkin Mar 6, 2025
d8c951c
refactor-[]: refactor cmake
Mar 7, 2025
b412539
refactor-[]: статическая линковка libc
Mar 7, 2025
5d075a7
refactor-[]: refact cmake
Mar 7, 2025
0b95e48
Update release.yml
AndrewMashkin Mar 7, 2025
ec565d2
Update release.yml
AndrewMashkin Mar 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,37 @@ on:
jobs:
build:
runs-on: ubuntu-latest
container: ubuntu:22.04 # Используем конкретную версию Ubuntu
steps:
- name: Install Git
run: |
apt-get update
apt-get install -y git

- uses: actions/checkout@v2
with:
submodules: true
- run: sudo apt-get update && sudo apt-get install libboost-test-dev -y
- run: cmake . -DPATCH_VERSION=${{ github.run_number }} -DWITH_BOOST_TEST=ON
- run: cmake --build .
- run: cmake --build . --target test
- run: cmake --build . --target package

- name: Install dependencies
run: |
apt-get install -y build-essential cmake libssl-dev

- name: Configure CMake
run: |
cmake . -DPATCH_VERSION=${{ github.run_number }} -DUNITTEST=ON \
-DCMAKE_CXX_FLAGS="-static-libstdc++ -static-libgcc"

- name: Build project
run: cmake --build .

- name: Run tests
run: |
mkdir -p test
ctest -V --output-on-failure

- name: Create DEB package
run: cmake --build . --target package

- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand All @@ -28,6 +50,7 @@ jobs:
release_name: Release ${{ github.run_number }}
draft: false
prerelease: false

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
Expand All @@ -37,4 +60,4 @@ jobs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./helloworld-0.0.${{ github.run_number }}-Linux.deb
asset_name: helloworld-0.0.${{ github.run_number }}-Linux.deb
asset_content_type: application/vnd.debian.binary-package
asset_content_type: application/vnd.debian.binary-package
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.user
90 changes: 12 additions & 78 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,86 +1,20 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.22)

set(PATCH_VERSION "1" CACHE INTERNAL "Patch version")
set(PROJECT_VESRION 0.0.${PATCH_VERSION})
project(otus_home_works)

project(helloworld VERSION ${PROJECT_VESRION})
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

option(WITH_BOOST_TEST "Whether to build Boost test" ON)
option(UNITTEST "on/off unittest" ON)

configure_file(version.h.in version.h)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/)
set(LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(TEST_OUTPUT_PATH ${CMAKE_BINARY_DIR}/test)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc")

add_executable(helloworld_cli main.cpp)
add_library(helloworld lib.cpp)

set_target_properties(helloworld_cli helloworld PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON
)

target_include_directories(helloworld
PRIVATE "${CMAKE_BINARY_DIR}"
)

target_link_libraries(helloworld_cli PRIVATE
helloworld
)

if(WITH_BOOST_TEST)
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
add_executable(test_version test_version.cpp)

set_target_properties(test_version PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON
)

set_target_properties(test_version PROPERTIES
COMPILE_DEFINITIONS BOOST_TEST_DYN_LINK
INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR}
)

target_link_libraries(test_version
${Boost_LIBRARIES}
helloworld
)
endif()

if (MSVC)
target_compile_options(helloworld_cli PRIVATE
/W4
)
target_compile_options(helloworld PRIVATE
/W4
)
if(WITH_BOOST_TEST)
target_compile_options(test_version PRIVATE
/W4
)
endif()
else ()
target_compile_options(helloworld_cli PRIVATE
-Wall -Wextra -pedantic -Werror
)
target_compile_options(helloworld PRIVATE
-Wall -Wextra -pedantic -Werror
)
if(WITH_BOOST_TEST)
target_compile_options(test_version PRIVATE
-Wall -Wextra -pedantic -Werror
)
endif()
if(UNITTEST)
enable_testing()
endif()

install(TARGETS helloworld_cli RUNTIME DESTINATION bin)
add_subdirectory(libs)
add_subdirectory(main)

set(CPACK_GENERATOR DEB)
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
set(CPACK_PACKAGE_CONTACT example@example.com)
include(CPack)

if(WITH_BOOST_TEST)
enable_testing()
add_test(test_version test_version)
endif()
7 changes: 0 additions & 7 deletions lib.cpp

This file was deleted.

4 changes: 0 additions & 4 deletions lib.h

This file was deleted.

7 changes: 7 additions & 0 deletions libs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
project(libs)

if(UNITTEST)
add_subdirectory(gtest_framework)
include(CTest)
endif()

16 changes: 16 additions & 0 deletions libs/gtest_framework/CMakeFiles/CMakeDirectoryInformation.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.22

# Relative path conversion top directories.
set(CMAKE_RELATIVE_PATH_TOP_SOURCE "/home/t1/work/otus/otus-cpp")
set(CMAKE_RELATIVE_PATH_TOP_BINARY "/home/t1/work/otus/otus-cpp")

# Force unix paths in dependencies.
set(CMAKE_FORCE_UNIX_PATHS 1)


# The C and CXX include file regular expressions for this directory.
set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$")
set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$")
set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN})
set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN})
1 change: 1 addition & 0 deletions libs/gtest_framework/CMakeFiles/progress.marks
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4
8 changes: 8 additions & 0 deletions libs/gtest_framework/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
project(gtest_framework)

add_subdirectory(googletest)





7 changes: 7 additions & 0 deletions libs/gtest_framework/CTestTestfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# CMake generated Testfile for
# Source directory: /home/t1/work/otus/otus-cpp/libs/test
# Build directory: /home/t1/work/otus/otus-cpp/libs/test
#
# This file includes the relevant testing commands required for
# testing this directory and lists subdirectories to be tested as well.
subdirs("googletest")
Loading