-
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
4,129 additions
and
244 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
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,138 @@ | ||
name: 'HW4 action' | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- 'HW4/**' | ||
- '.github/workflows/HW4.yml' | ||
|
||
permissions: | ||
actions: write | ||
contents: write | ||
|
||
jobs: | ||
build-and-run-job: | ||
env: | ||
target_name: print_ip | ||
homework_label: HW4 | ||
cmake_preset: linux-release | ||
cmake_build_preset: linux-build-release | ||
hw_path: ./HW4 | ||
build_folder: build | ||
release_folder: linux-release | ||
version_base: '1.0' | ||
build_tests: ${{ false }} | ||
# Variables to populate in "Initialize variables" step | ||
build_path: | ||
bin_path: | ||
deb_path: | ||
version: | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Initialize variables | ||
run: | | ||
echo "build_path=${{ env.hw_path }}/${{ env.build_folder }}/${{ env.release_folder }}" >> $GITHUB_ENV | ||
echo "bin_path=${{ env.hw_path }}/${{ env.build_folder }}/${{ env.release_folder }}/bin" >> $GITHUB_ENV | ||
echo "deb_path=${{ env.hw_path }}/${{ env.build_folder }}/${{ env.release_folder }}/deb" >> $GITHUB_ENV | ||
echo "version=${{ env.version_base }}.${{ github.run_number }}" >> $GITHUB_ENV | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
#- name: Update apt-get | ||
# run: sudo apt-get update | ||
|
||
- name: Build package ${{ env.target_name }} | ||
working-directory: ${{env.hw_path}} | ||
run: | | ||
cmake -DBuildTests=${{ env.build_tests }} -DPROJECT_VERSION=${{ env.version }} --preset ${{ env.cmake_preset }} | ||
cmake --build --preset ${{ env.cmake_build_preset }} | ||
- name: Run tests | ||
if: ${{ env.build_tests }} | ||
working-directory: ${{ env.build_path }} | ||
run: ctest --test-dir . | ||
|
||
- name: Check tests results | ||
if: ${{ env.build_tests && !success()}} | ||
run: | | ||
gh run cancel ${{ github.run_id }} | ||
gh run watch ${{ github.run_id }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Run packet ${{ env.target_name }} | ||
run: '${{ env.bin_path }}/${{ env.target_name }}' | ||
|
||
- name: Build package | ||
working-directory: ${{env.build_path}} | ||
run: cpack -G DEB | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ env.homework_label }}_${{ github.run_number }} | ||
release_name: ${{ env.homework_label }} release ${{ github.run_number }} | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload packet | ||
id: upload-app-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ${{ env.bin_path }}/${{ env.target_name }} | ||
asset_name: ${{ env.target_name }} | ||
asset_content_type: application/octet-stream | ||
|
||
- name: Upload package | ||
id: upload-package-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ${{ env.deb_path }}/${{ env.target_name }}-${{ env.version }}-Linux.deb | ||
asset_name: ${{ env.target_name }}-${{ env.version }}-Linux.deb | ||
asset_content_type: application/vnd.debian.binary-package | ||
|
||
- name: Create Doxygen | ||
uses: mattnotmitt/[email protected] | ||
with: | ||
doxyfile-path: ./Doxyfile | ||
working-directory: ${{ env.hw_path }} | ||
|
||
- name: GitHub Pages Deployment | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./doc/html/ | ||
enable_jekyll: false | ||
allow_empty_commit: false | ||
force_orphan: true | ||
publish_branch: gh-pages | ||
|
||
# Build the HTML documentation | ||
- name: Doxygen Action | ||
uses: mattnotmitt/[email protected] | ||
with: | ||
doxyfile-path: ${{ env.hw_path }}/Doxyfile | ||
working-directory: . | ||
|
||
# Deploy the HTML documentation to GitHub Pages | ||
- name: GH Pages Deployment | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ${{ env.hw_path }}/doc/html/ | ||
enable_jekyll: false | ||
allow_empty_commit: false | ||
force_orphan: true | ||
publish_branch: gh-pages |
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
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,37 +1,17 @@ | ||
cmake_minimum_required (VERSION 3.12) | ||
|
||
option(BUILD_TESTS "BuildTests" OFF) | ||
option(BUILD_TESTS "BuildTests" ON) | ||
set(PROJECT_VERSION "0.0.3" CACHE INTERNAL "Version") | ||
project (ip_filter_project VERSION ${PROJECT_VERSION}) | ||
|
||
project ("ip_filter") | ||
add_executable (ip_filter "src/main.cpp" "src/ip.cpp" "include/ip.h") | ||
include_directories("include") | ||
|
||
set_property(TARGET ip_filter PROPERTY CXX_STANDARD 20) | ||
|
||
# Enable Hot Reload for MSVC compilers if supported. | ||
if (POLICY CMP0141) | ||
cmake_policy(SET CMP0141 NEW) | ||
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>") | ||
endif() | ||
|
||
set_target_properties(ip_filter | ||
PROPERTIES | ||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" | ||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" | ||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" | ||
) | ||
|
||
# deb-package. | ||
set(CPACK_GENERATOR DEB) | ||
set(CPACK_PACKAGE_NAME "ip_filter") | ||
set(CPACK_PACKAGE_VERSION "1.0.0") | ||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") | ||
set(CPACK_PACKAGE_ARCHITECTURE "amd64") | ||
set(CPACK_PACKAGE_CONTACT [email protected]) | ||
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/deb") | ||
include(CPack) | ||
|
||
# Tests. | ||
if(BuildTests) | ||
add_subdirectory(ip_filter) | ||
add_subdirectory(ip_lib) | ||
if(BUILD_TESTS) | ||
enable_testing() | ||
add_subdirectory(tests) | ||
endif() |
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,19 @@ | ||
add_executable(ip_filter main.cpp) | ||
target_link_libraries(ip_filter PUBLIC ip) | ||
|
||
set_target_properties(ip_filter | ||
PROPERTIES | ||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" | ||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" | ||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" | ||
) | ||
|
||
# deb-package. | ||
set(CPACK_GENERATOR DEB) | ||
set(CPACK_PACKAGE_NAME "ip_filter") | ||
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) | ||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") | ||
set(CPACK_PACKAGE_ARCHITECTURE "amd64") | ||
set(CPACK_PACKAGE_CONTACT [email protected]) | ||
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/deb") | ||
include(CPack) |
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,31 @@ | ||
#include <sstream> | ||
#include <fstream> | ||
#include <iostream> | ||
#include <vector> | ||
#include <functional> | ||
#include <algorithm> | ||
#include <limits> | ||
|
||
#include "ip_lib/ip.h" | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
std::istream& stream = std::cin; | ||
std::ostream& outStream = std::cout; | ||
|
||
auto [ips, success] = ip::readIps(stream); | ||
if (!success) { | ||
std::cerr << "Couldn't parse some IPs. Quiting." << std::endl; | ||
return 1; | ||
} | ||
|
||
std::sort(ips.begin(), ips.end(), std::greater()); | ||
for (const auto& ip : ips) { | ||
outStream << ip << '\n'; | ||
} | ||
ip::filterPart0Is1(ips.begin(), ips.end(), std::cout); | ||
ip::filterPart0Is46AndPart1Is70(ips.begin(), ips.end(), std::cout); | ||
ip::filterAnyPartIs46(ips.begin(), ips.end(), std::cout); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.