-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
1,205 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
name: build | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
name: ${{ matrix.config.name }} | ||
runs-on: ${{ matrix.config.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
config: | ||
- { | ||
name: "Windows Latest MSVC", artifact: "Windows.zip", exe_path: "search_engine.exe", | ||
os: windows-latest, | ||
build_type: "Release", cc: "cl", cxx: "cl", | ||
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" | ||
} | ||
- { | ||
name: "Ubuntu Latest GCC", artifact: "Linux.zip", exe_path: "search_engine", | ||
os: ubuntu-latest, | ||
build_type: "Release", cc: "gcc", cxx: "g++" | ||
} | ||
- { | ||
name: "macOS Latest Clang", artifact: "macOS.zip", exe_path: "search_engine", | ||
os: macos-latest, | ||
build_type: "Release", cc: "clang", cxx: "clang++" | ||
} | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Prepare for Conan | ||
run: | | ||
mkdir build | ||
pip3 install conan | ||
- name: Conan | ||
working-directory: build | ||
run: | | ||
conan install .. --build=missing | ||
- name: Configure | ||
shell: cmake -P {0} | ||
run: | | ||
set(ENV{CC} ${{ matrix.config.cc }}) | ||
set(ENV{CXX} ${{ matrix.config.cxx }}) | ||
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") | ||
execute_process( | ||
COMMAND "${{ matrix.config.environment_script }}" && set | ||
OUTPUT_FILE environment_script_output.txt | ||
) | ||
file(STRINGS environment_script_output.txt output_lines) | ||
foreach(line IN LISTS output_lines) | ||
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") | ||
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") | ||
endif() | ||
endforeach() | ||
endif() | ||
execute_process( | ||
COMMAND cmake | ||
-S . | ||
-B build | ||
-D CMAKE_BUILD_TYPE=${{ matrix.config.build_type }} | ||
-D ENABLE_TESTS=ON | ||
RESULT_VARIABLE result | ||
) | ||
if (NOT result EQUAL 0) | ||
message(FATAL_ERROR "Bad exit status") | ||
endif() | ||
- name: Build | ||
shell: cmake -P {0} | ||
run: | | ||
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") | ||
file(STRINGS environment_script_output.txt output_lines) | ||
foreach(line IN LISTS output_lines) | ||
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") | ||
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") | ||
endif() | ||
endforeach() | ||
endif() | ||
execute_process( | ||
COMMAND cmake --build build --config ${{ matrix.config.build_type }} | ||
RESULT_VARIABLE result | ||
) | ||
if (NOT result EQUAL 0) | ||
message(FATAL_ERROR "Bad exit status") | ||
endif() | ||
- name: Run tests | ||
working-directory: build | ||
shell: cmake -P {0} | ||
run: | | ||
if ("${{ runner.os }}" STREQUAL "Windows") | ||
execute_process( | ||
COMMAND bin/search_engine_test.exe | ||
RESULT_VARIABLE result | ||
) | ||
endif() | ||
if (NOT "${{ runner.os }}" STREQUAL "Windows") | ||
execute_process( | ||
COMMAND ./bin/search_engine_test | ||
RESULT_VARIABLE result | ||
) | ||
endif() | ||
if (NOT result EQUAL 0) | ||
message(FATAL_ERROR "Bad exit status ") | ||
endif() | ||
- name: Pack | ||
shell: cmake -P {0} | ||
run: | | ||
if ("${{ runner.os }}" STREQUAL "Windows") | ||
execute_process( | ||
COMMAND cmake -E tar "cfv" ${{ matrix.config.artifact }} --format=zip ${{ matrix.config.exe_path }} | ||
WORKING_DIRECTORY ./build/bin | ||
) | ||
execute_process( | ||
COMMAND mv ./build/bin/${{ matrix.config.artifact }} ${{ matrix.config.artifact }} | ||
) | ||
endif() | ||
if (NOT "${{ runner.os }}" STREQUAL "Windows") | ||
execute_process( | ||
COMMAND cmake -E tar "cfv" ${{ matrix.config.artifact }} --format=zip ${{ matrix.config.exe_path }} | ||
WORKING_DIRECTORY ./build/bin | ||
) | ||
execute_process( | ||
COMMAND mv ./build/bin/${{ matrix.config.artifact }} ./${{ matrix.config.artifact }} | ||
) | ||
endif() | ||
- name: Upload | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
path: ./${{ matrix.config.artifact }} | ||
name: ${{ matrix.config.artifact }} | ||
|
||
release: | ||
if: contains(github.ref, 'tags/v') | ||
runs-on: ubuntu-latest | ||
needs: build | ||
|
||
steps: | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Store Release url | ||
run: | | ||
echo "${{ steps.create_release.outputs.upload_url }}" > ./upload_url | ||
- uses: actions/upload-artifact@v1 | ||
with: | ||
path: ./upload_url | ||
name: upload_url | ||
|
||
publish: | ||
if: contains(github.ref, 'tags/v') | ||
name: ${{ matrix.config.name }} | ||
runs-on: ${{ matrix.config.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
config: | ||
- { | ||
name: "Windows Latest MSVC", artifact: "Windows.zip", exe_path: search_engine.exe, | ||
os: ubuntu-latest | ||
} | ||
- { | ||
name: "Ubuntu Latest GCC", artifact: "Linux.zip", exe_path: search_engine, | ||
os: ubuntu-latest | ||
} | ||
- { | ||
name: "macOS Latest Clang", artifact: "macOS.zip", exe_path: search_engine, | ||
os: ubuntu-latest | ||
} | ||
needs: release | ||
|
||
steps: | ||
- name: Download artifact | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: ${{ matrix.config.artifact }} | ||
path: ./ | ||
|
||
- name: Download URL | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: upload_url | ||
path: ./ | ||
- id: set_upload_url | ||
run: | | ||
upload_url=`cat ./upload_url` | ||
echo ::set-output name=upload_url::$upload_url | ||
- name: Upload to Release | ||
id: upload_to_release | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.set_upload_url.outputs.upload_url }} | ||
asset_path: ./${{ matrix.config.artifact }} | ||
asset_name: ${{ matrix.config.artifact }} | ||
asset_content_type: application/x-gtar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: SonarQube | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
env: | ||
SONAR_SCANNER_VERSION: 4.7.0.2747 | ||
SONAR_SERVER_URL: "https://sonarcloud.io" | ||
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
- name: Download and set up sonar-scanner | ||
env: | ||
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip | ||
run: | | ||
mkdir -p $HOME/.sonar | ||
curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }} | ||
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ | ||
echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH | ||
- name: Download and set up build-wrapper | ||
env: | ||
BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip | ||
run: | | ||
curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }} | ||
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ | ||
echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH | ||
- name: Run build-wrapper | ||
run: | | ||
mkdir build | ||
cd build | ||
pip install conan | ||
conan install .. --build=missing | ||
cd .. | ||
cmake -DENABLE_TESTS=ON -DCMAKE_CXX_FLAGS=--coverage -S . -B build | ||
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config Debug | ||
- name: Run tests | ||
working-directory: build | ||
run: | | ||
./bin/search_engine_test | ||
- name: Collect coverage into one XML report | ||
run: | | ||
sudo apt-get install -y gcovr | ||
gcovr --sonarqube > coverage.xml | ||
- name: Run sonar-scanner | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
run: | | ||
sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" --define sonar.coverageReportPaths=coverage.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
/cmake-build-debug/ | ||
/.idea/.gitignore | ||
/.idea/misc.xml | ||
/.idea/modules.xml | ||
/.idea/search_engine.iml | ||
/.idea/vcs.xml | ||
#/resources/ | ||
/cmake-build-debug-coverage/ | ||
/.idea/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,51 @@ | ||
cmake_minimum_required(VERSION 3.21) | ||
cmake_minimum_required(VERSION 3.16) | ||
project(search_engine) | ||
include(FetchContent) | ||
include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
set(CMAKE_CXX_STANDARD 14) | ||
set(CMAKE_CXX_STANDARD 17) | ||
message("-- ENABLE_TESTS: " ${ENABLE_TESTS}) | ||
|
||
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.10.5/json.tar.xz) | ||
find_package(Threads REQUIRED) | ||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
|
||
set(Boost_NO_WARN_NEW_VERSIONS 1) | ||
set(Boost_USE_STATIC_LIBS ON) | ||
find_package(Boost COMPONENTS thread system REQUIRED) | ||
include_directories(${Boost_INCLUDE_DIR}) | ||
|
||
FetchContent_Declare( | ||
json | ||
URL | ||
https://github.com/nlohmann/json/releases/download/v3.10.5/json.tar.xz | ||
) | ||
FetchContent_MakeAvailable(json) | ||
|
||
add_executable(search_engine main.cpp ConverterJSON.cpp ConverterJSON.h) | ||
if(ENABLE_TESTS) | ||
FetchContent_Declare( | ||
googletest | ||
URL | ||
https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip | ||
) | ||
FetchContent_MakeAvailable(googletest) | ||
|
||
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) | ||
set(gtest_disable_pthreads on) | ||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
|
||
enable_testing() | ||
|
||
add_executable(search_engine_test src/ConverterJSON.cpp tests/tests.cpp src/InvertedIndex.cpp src/SearchServer.cpp) | ||
target_link_libraries(search_engine_test PRIVATE nlohmann_json::nlohmann_json gtest_main Threads::Threads ${Boost_LIBRARIES}) | ||
|
||
include(GoogleTest) | ||
gtest_discover_tests(search_engine_test) | ||
|
||
endif() | ||
|
||
add_executable(search_engine src/main.cpp src/ConverterJSON.cpp src/InvertedIndex.cpp src/SearchServer.cpp ) | ||
target_link_libraries(search_engine PRIVATE nlohmann_json::nlohmann_json Threads::Threads ${Boost_LIBRARIES}) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/search_engine DESTINATION .) | ||
|
||
|
||
target_link_libraries(search_engine PRIVATE nlohmann_json::nlohmann_json) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Kulaga Sergey | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Oops, something went wrong.