Skip to content
Open

Main #24

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a9cdaec
Update main.cpp
oshkines Feb 28, 2026
2d62d5f
Update main.cpp
oshkines Feb 28, 2026
de47e1b
FileIgnore
oshkines Mar 4, 2026
d90317c
Lesson2
oshkines Mar 5, 2026
5802d73
Update release.yml
oshkines Mar 5, 2026
54c7558
Update main.cpp
oshkines Mar 5, 2026
2ed0fe9
Update release.yml
oshkines Mar 5, 2026
0eeecc3
Trigger Actions
oshkines Mar 5, 2026
38392f5
Update releaseAddMain.yml
oshkines Mar 5, 2026
04384be
Update release.yml
oshkines Mar 5, 2026
317a1bf
Update release.yml
oshkines Mar 5, 2026
d52f3db
Update CMakeLists.txt
oshkines Mar 5, 2026
5a106fc
Lesson6: Actual version
oshkines Mar 28, 2026
130a928
Lesson6: Actual version v.2
oshkines Mar 28, 2026
42eaa5c
correct name project Lesson6 for Update release.yml
oshkines Mar 28, 2026
37aa355
Lesson7: SFINAE + Doxygen
oshkines Apr 11, 2026
3425b3c
Merge branch 'main' of https://github.com/oshkines/otus-cpp-prof
oshkines Apr 11, 2026
5386d0a
Update release.yml
oshkines Apr 11, 2026
18d8e84
Lesson7: SFINAE + Doxygen v2.0
oshkines Apr 11, 2026
83e4ce0
Merge branch 'main' of https://github.com/oshkines/otus-cpp-prof
oshkines Apr 11, 2026
1fc4db9
Update CMakeLists.txt
oshkines Apr 11, 2026
ddb5e3b
Lesson7: SFINAE + Doxygen v3.0
oshkines Apr 11, 2026
587c363
Merge branch 'main' of https://github.com/oshkines/otus-cpp-prof
oshkines Apr 11, 2026
bda5f6c
Add Docker build and CI/CD workflow
oshkines Apr 13, 2026
f778027
Add Pages deployment
oshkines Apr 13, 2026
a3f7738
Fix documentation path in workflow
oshkines Apr 13, 2026
2461782
Finish Homework Editor
oshkines Apr 14, 2026
5b98733
Fix diagrams visibility on GH Pages
oshkines Apr 14, 2026
64a29f9
Fix diagrams visibility on GH Pages 2
oshkines Apr 14, 2026
510d2da
Fix diagrams visibility on GH Pages 3
oshkines Apr 14, 2026
bb8889e
Fix diagrams visibility on GH Pages 4
oshkines Apr 14, 2026
cf34f76
Fix diagrams visibility on GH Pages 5
oshkines Apr 14, 2026
7e9fcf9
Fix diagrams visibility on GH Pages 6
oshkines Apr 14, 2026
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
68 changes: 39 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,50 @@
name: 'C++ CI'
name: Build and Release

on:
push:
branches:
- master
- feature/github_actions
tags:
- 'v*'

jobs:
build:
release:
runs-on: ubuntu-latest
permissions:
contents: write
pages: write
id-token: write
steps:
- 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: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4

- name: Build in Docker
run: |
# 1. Собираем образ
docker build -t builder .

# 2. Создаем временный контейнер для копирования файлов
docker create --name extractor builder

# 3. Подготавливаем папки на сервере GitHub
mkdir -p dist

# 4. Копируем .deb пакет из папки /output контейнера
docker cp extractor:/output/. ./dist/

# 5. Копируем документацию.
# Путь /build/docs/html так как в Doxyfile OUTPUT_DIRECTORY = docs
docker cp extractor:/build/docs/html/. ./dist-docs

# 6. Удаляем контейнер
docker rm extractor

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.run_number }}
release_name: Release ${{ github.run_number }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
files: dist/*.deb
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
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
folder: dist-docs
branch: gh-pages
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
**/.idea/
**/.settings/
**/.vscode/
**/build/
**/debug/
**/release/
html/
latex/
*.deb
dist/
output/
87 changes: 5 additions & 82 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,86 +1,9 @@
cmake_minimum_required(VERSION 3.12)
project(editor)

set(PATCH_VERSION "1" CACHE INTERNAL "Patch version")
set(PROJECT_VESRION 0.0.${PATCH_VERSION})
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

project(helloworld VERSION ${PROJECT_VESRION})
add_executable(editor main.cpp)

option(WITH_BOOST_TEST "Whether to build Boost test" ON)

configure_file(version.h.in version.h)

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()
endif()

install(TARGETS helloworld_cli RUNTIME DESTINATION bin)

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()
install(TARGETS editor DESTINATION bin)
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM ubuntu:22.04

# Ставим зависимости: компилятор, cmake, doxygen и инструменты сборки пакетов
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
doxygen \
graphviz \
devscripts \
debhelper \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /build
COPY . .

# 1. Генерируем документацию
RUN doxygen Doxyfile

# 2. Собираем проект и упаковываем в .deb
# Команда ниже запустит процесс создания пакета из папки debian
#RUN dpkg-buildpackage -b -us -uc
#RUN mkdir -p /output
#RUN dpkg-buildpackage -b -us -uc && cp /editor*.deb /output/
#RUN dpkg-buildpackage -b -us -uc && cp ../editor*.deb /output/
# Пакет окажется на уровень выше, в / (корне) или в /build_parent

# Устанавливаем дополнительные утилиты для исправления строк
RUN apt-get update && apt-get install -y dos2unix

WORKDIR /build
COPY . .

# Исправляем концы строк, права доступа и создаем папку для вывода
RUN dos2unix debian/rules && \
chmod +x debian/rules && \
mkdir -p /output

# Запускаем сборку
RUN dpkg-buildpackage -b -us -uc && cp ../editor*.deb /output/

24 changes: 24 additions & 0 deletions Document.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#pragma once
#include <vector>
#include <string>
#include "Shape.h"

class Document {
private:
// Храним вектор умных указателей на фигуры
std::vector<std::unique_ptr<Shape>> shapes;

public:
void addShape(std::unique_ptr<Shape> shape) {
shapes.push_back(std::move(shape)); // Передаем владение в вектор
}

void removeLastShape() {
if (!shapes.empty()) shapes.pop_back();
}

void save(const std::string& path) { std::cout << "Документ сохранен в: " << path << "\n"; }
void load(const std::string& path) { std::cout << "Документ загружен из: " << path << "\n"; }

const std::vector<std::unique_ptr<Shape>>& getShapes() const { return shapes; }
};
Loading