Skip to content

Commit 24e1b32

Browse files
committed
init commit
0 parents  commit 24e1b32

35 files changed

+435
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/cpp/.devcontainer/base.Dockerfile
2+
# [Choice] Debian / Ubuntu version (use Debian 11/9, Ubuntu 18.04/21.04 on local arm64/Apple Silicon): debian-11, debian-10, debian-9, ubuntu-21.04, ubuntu-20.04, ubuntu-18.04
3+
ARG VARIANT=ubuntu-22.04
4+
FROM mcr.microsoft.com/devcontainers/cpp:0-${VARIANT}
5+
6+
# [Optional] Uncomment this section to install additional packages.
7+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
8+
&& apt-get -y install --no-install-recommends clang clang-format clangd libgtest-dev
9+
10+
COPY first-run-notice.txt /tmp/scripts/

.devcontainer/devcontainer.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/cpp
3+
{
4+
"name": "C++",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
// Update 'VARIANT' to pick an Debian / Ubuntu OS version: debian-11, debian-10, debian-9, ubuntu-21.04, ubuntu-20.04, ubuntu-18.04
8+
// Use Debian 11, Debian 9, Ubuntu 18.04 or Ubuntu 21.04 on local arm64/Apple Silicon
9+
"args": {
10+
"VARIANT": "ubuntu-22.04"
11+
}
12+
},
13+
"runArgs": [
14+
"--cap-add=SYS_PTRACE",
15+
"--security-opt",
16+
"seccomp=unconfined"
17+
],
18+
// Configure tool-specific properties.
19+
"customizations": {
20+
// Configure properties specific to VS Code.
21+
"vscode": {
22+
// Set *default* container specific settings.json values on container create.
23+
"settings": {
24+
"C_Cpp.clang_format_fallbackStyle": "Google",
25+
"C_Cpp.clang_format_path": "clang-format",
26+
"C_Cpp.clang_format_style": "file",
27+
"C_Cpp.formatting": "clangFormat",
28+
"clang-format.executable": "clang-format",
29+
"clang-format.fallbackStyle": "Google",
30+
"clang-format.language.cpp.enable": true,
31+
"clang.executable": "clang",
32+
"editor.formatOnSave": true
33+
},
34+
// Add the IDs of extensions you want installed when the container is created.
35+
"extensions": [
36+
"llvm-vs-code-extensions.vscode-clangd",
37+
"ms-vscode.cpptools",
38+
"xaver.clang-format"
39+
]
40+
}
41+
},
42+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
43+
// "forwardPorts": [],
44+
// Use 'postCreateCommand' to run commands after the container is created.
45+
// "postCreateCommand": "gcc -v",
46+
// Comment out this line to run as root instead.
47+
"remoteUser": "vscode"
48+
}

.devcontainer/first-run-notice.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
👋 Welcome to Homework!

.github/workflows/clang-format.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: clang-format-check
2+
3+
# You can be more specific, but it currently only works on pull requests
4+
on: [pull_request]
5+
6+
jobs:
7+
formatting-check:
8+
name: Formatting Check
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Run clang-format style check for C/C++/Protobuf programs.
16+
uses: jidicula/[email protected]
17+
with:
18+
clang-format-version: "14"
19+
check-path: "src"
20+
fallback-style: "Google"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: clang-tidy-post
2+
3+
on:
4+
workflow_run:
5+
# The name field of the lint action
6+
workflows: ['clang-tidy-review']
7+
types:
8+
- completed
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
# Downloads the artifact uploaded by the lint action
16+
- name: 'Download artifact'
17+
uses: actions/github-script@v6
18+
with:
19+
script: |
20+
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
21+
owner: context.repo.owner,
22+
repo: context.repo.repo,
23+
run_id: ${{github.event.workflow_run.id }},
24+
});
25+
const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
26+
return artifact.name == "clang-tidy-review"
27+
})[0];
28+
const download = await github.rest.actions.downloadArtifact({
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
artifact_id: matchArtifact.id,
32+
archive_format: 'zip',
33+
});
34+
const fs = require('fs');
35+
fs.writeFileSync('${{github.workspace}}/clang-tidy-review.zip', Buffer.from(download.data));
36+
- name: 'Unzip artifact'
37+
run: unzip clang-tidy-review.zip
38+
39+
- uses: ZedThree/clang-tidy-review/[email protected]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: clang-tidy-review
2+
3+
# You can be more specific, but it currently only works on pull requests
4+
on: [pull_request]
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v3
12+
13+
# Optionally generate compile_commands.json
14+
15+
- uses: ZedThree/[email protected]
16+
with:
17+
clang_tidy_checks: '-*,performance-*,bugprone-*,clang-analyzer-*,cppcoreguidelines-*,mpi-*,misc-*,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-avoid-magic-numbers,-clang-diagnostic-error,-misc-no-recursion,-cppcoreguidelines-owning-memory,-bugprone-narrowing-conversions,-bugprone-easily-swappable-parameters,-misc-non-private-member-variables-in-classes,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-special-member-functions,-cppcoreguidelines-init-variables'
18+
split_workflow: true
19+
20+
- uses: actions/upload-artifact@v3
21+
with:
22+
name: clang-tidy-review
23+
path: |
24+
clang-tidy-review-output.json
25+
clang-tidy-review-metadata.json

.github/workflows/tests.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Tests
2+
3+
on:
4+
push: {}
5+
pull_request:
6+
branches: ["main"]
7+
8+
env:
9+
BUILD_TYPE: Release
10+
11+
jobs:
12+
build_and_test:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Install gtest manually
17+
run: sudo apt-get install libgtest-dev
18+
19+
- uses: actions/checkout@v3
20+
21+
- name: run cmake
22+
working-directory: ${{github.workspace}}/
23+
run: cmake -B./build .
24+
25+
- name: make
26+
working-directory: ${{github.workspace}}/build
27+
run: make

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CMakeLists.txt.user
2+
CMakeCache.txt
3+
CMakeFiles
4+
CMakeScripts
5+
Testing
6+
Makefile
7+
cmake_install.cmake
8+
install_manifest.txt
9+
compile_commands.json
10+
CTestTestfile.cmake
11+
_deps
12+
13+
.cache/*
14+
.vscode/*
15+
build/*

CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
project(homeworks)
4+
5+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib)
6+
7+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/sandbox)
8+
9+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/additional_tasks)
10+
11+
file(GLOB_RECURSE tasks_dirs LIST_DIRECTORIES true ".")
12+
13+
foreach(dir ${tasks_dirs})
14+
IF(IS_DIRECTORY ${dir})
15+
IF(${dir} MATCHES "task_0[0-9]$" AND NOT ${dir} MATCHES "build")
16+
add_subdirectory(${dir})
17+
ENDIF()
18+
ELSE()
19+
CONTINUE()
20+
ENDIF()
21+
endforeach()

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 DafeMipt212
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Домашнее задание для 1 семестра алгоритмов и структур данных
2+
3+
### Для удобства можно пользоваться папкой lib, все файлы из этой папки будут подключаться к любой задаче
4+
5+
### Можно получить дополнительные баллы, если добавить интересные текстовые задачи. Необходимы текст задачи, решение и тесты.
6+
7+
### Можно получить дополнительные баллы, если добавить теорию в папку doc. Делается в отдельном ПР

additional_tasks/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
project(additional_tasks)
4+
5+
file(GLOB_RECURSE tasks_dirs LIST_DIRECTORIES true ".")
6+
7+
foreach(dir ${tasks_dirs})
8+
IF(IS_DIRECTORY ${dir})
9+
IF(NOT ${dir} MATCHES ".*src.*")
10+
add_subdirectory(${dir})
11+
ENDIF()
12+
ELSE()
13+
CONTINUE()
14+
ENDIF()
15+
endforeach()
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
4+
string(REPLACE " " "_" PROJECT_NAME ${PROJECT_NAME})
5+
project(${PROJECT_NAME} C CXX)
6+
7+
set(CMAKE_CXX_STANDARD 20)
8+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
9+
10+
file(GLOB_RECURSE source_list "src/*.cpp" "src/*.hpp")
11+
file(GLOB_RECURSE lib_source_list "../../lib/src/*.cpp" "../../lib/src/*.hpp")
12+
file(GLOB_RECURSE main_source_list "src/main.cpp")
13+
file(GLOB_RECURSE test_source_list "src/*.cpp")
14+
file(GLOB_RECURSE test_list "src/*test.cpp")
15+
16+
list(REMOVE_ITEM test_source_list ${main_source_list})
17+
list(REMOVE_ITEM source_list ${test_list})
18+
19+
include_directories(${PROJECT_NAME} PUBLIC src)
20+
21+
add_executable(${PROJECT_NAME} ${source_list} ${lib_source_list})
22+
23+
# Locate GTest
24+
enable_testing()
25+
find_package(GTest REQUIRED)
26+
include_directories(${GTEST_INCLUDE_DIRS})
27+
28+
# Link runTests with what we want to test and the GTest and pthread library
29+
add_executable(${PROJECT_NAME}_tests ${test_source_list})
30+
target_link_libraries(
31+
${PROJECT_NAME}_tests
32+
GTest::gtest_main
33+
)
34+
35+
include(GoogleTest)
36+
gtest_discover_tests(${PROJECT_NAME}_tests)

additional_tasks/template/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Задача на количество дней перед потеплением
2+
3+
Написать функцию в которую передается темепература за каждый день в определенный момент день, нужно вернуть количество дней до повышения температуры для каждого дня, если температура не повысится, то для этого дня поставить в результирующий массив 0.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include <iostream>
2+
3+
int main() { return 0; }
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
#include <gtest/gtest.h>
3+
4+
#include <stack>
5+
6+
#include "utils.hpp"
7+
8+
TEST(Template, Simple) { ASSERT_EQ(true, true); }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "utils.hpp"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#pragma once

doc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Теория по алгоритмам:

lib/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
file(GLOB_RECURSE lib_source_list "src/*.cpp" "src/*.hpp")
4+
5+
add_library(Utils ${lib_source_list})
6+
7+
target_include_directories(Utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

lib/src/util.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "util.hpp"

lib/src/util.hpp

Whitespace-only changes.

sandbox/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
project(sendbox)
4+
5+
file(GLOB_RECURSE tasks_dirs LIST_DIRECTORIES true ".")
6+
7+
foreach(dir ${tasks_dirs})
8+
IF(IS_DIRECTORY ${dir})
9+
IF(NOT ${dir} MATCHES ".*src.*")
10+
add_subdirectory(${dir})
11+
ENDIF()
12+
ELSE()
13+
CONTINUE()
14+
ENDIF()
15+
endforeach()

sandbox/template/CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
cmake_minimum_required(VERSION 3.10)
2+
3+
get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
4+
string(REPLACE " " "_" PROJECT_NAME ${PROJECT_NAME})
5+
project(${PROJECT_NAME} C CXX)
6+
7+
set(CMAKE_CXX_STANDARD 20)
8+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
9+
10+
file(GLOB_RECURSE source_list "src/*.cpp" "src/*.hpp")
11+
file(GLOB_RECURSE lib_source_list "../../lib/src/*.cpp" "../../lib/src/*.hpp")
12+
file(GLOB_RECURSE main_source_list "src/main.cpp")
13+
file(GLOB_RECURSE test_source_list "src/*.cpp")
14+
file(GLOB_RECURSE test_list "src/*test.cpp")
15+
16+
list(REMOVE_ITEM test_source_list ${main_source_list})
17+
list(REMOVE_ITEM source_list ${test_list})
18+
19+
include_directories(${PROJECT_NAME} PUBLIC src)
20+
include_directories(${PROJECT_NAME} PUBLIC ../lib/src)
21+
22+
add_executable(${PROJECT_NAME} ${source_list})
23+
target_link_libraries(${PROJECT_NAME} PUBLIC Utils)
24+
25+
# Locate GTest
26+
enable_testing()
27+
find_package(GTest REQUIRED)
28+
include_directories(${GTEST_INCLUDE_DIRS})
29+
30+
# Link runTests with what we want to test and the GTest and pthread library
31+
add_executable(${PROJECT_NAME}_tests ${test_source_list})
32+
target_link_libraries(
33+
${PROJECT_NAME}_tests
34+
GTest::gtest_main
35+
Utils
36+
)
37+
38+
include(GoogleTest)
39+
gtest_discover_tests(${PROJECT_NAME}_tests)

sandbox/template/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Шаблон для песочницы
2+
3+
Принеобходимости просто скопировать папку и переименовать

sandbox/template/src/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include <iostream>
2+
3+
int main() { return 0; }

0 commit comments

Comments
 (0)