diff --git a/.github/workflows/main-check.yml b/.github/workflows/main-check.yml index e79cc01..c620b70 100644 --- a/.github/workflows/main-check.yml +++ b/.github/workflows/main-check.yml @@ -10,33 +10,99 @@ env: BUILD_TYPE: Release jobs: - - # both tests and static analysis depend on build artifact so - # they are grouped under the same job as it's simpler than cahing - # or artifact upload/download. Rith now the tests are pretty fast - # so not much would be gained from parallel run of test & analysis build: - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + compiler: ['clang','msvc','gcc'] + os: ['ubuntu-latest', 'windows-latest'] + exclude: + - os: 'ubuntu-latest' + compiler: 'msvc' + - os: 'windows-latest' + # temporary exclude everything + # compiler: 'gcc' - steps: + runs-on: ${{ matrix.os }} + + steps: - uses: actions/checkout@v3 - + - name: Cache + uses: actions/cache@v3 + with: + path: | + ~/vcpkg + ./build/vcpkg_installed + ${{ env.CONAN_USER_HOME }} + ~/.cache/pip + ${{ env.HOME }}/.cache/vcpkg/archives + ${{ env.XDG_CACHE_HOME }}/vcpkg/archives + ${{ env.LOCALAPPDATA }}\vcpkg\archives + ${{ env.APPDATA }}\vcpkg\archives + key: ${{ runner.os }}-${{ matrix.compiler }}-${{ hashFiles('**/CMakeLists.txt') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.compiler }} + - name: Prepare environment - run: sudo apt-get update && sudo apt-get install libboost-program-options-dev clang-tidy + uses: aminya/setup-cpp@v1 + with: + compiler: ${{ matrix.compiler }} + vcvarsall: ${{ contains(matrix.os, 'windows' )}} + cmake: true + ninja: true + conan: false + vcpkg: false + ccache: false + clangtidy: false + cppcheck: false + gcovr: false + opencppcoverage: false - - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON + - name: Setup vcpkg and install Boost (Windows) + if: steps.cache-step.outputs.cache-hit != 'true' && matrix.os == 'windows-latest' + + run: | + git clone https://github.com/microsoft/vcpkg.git + cd vcpkg + ./bootstrap-vcpkg.bat + ./vcpkg install boost + + - name: Get boost + if: matrix.os != 'windows-latest' + run: sudo apt-get update && sudo apt-get install libboost-program-options-dev + + - name: Configure CMake (Windows) + if: matrix.os == 'windows-latest' + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=On -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake + + - name: Configure CMake (Windows) + if: matrix.os != 'windows-latest' + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=On - name: Build - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + run: cmake --build ${{github.workspace}}/build --config Release - name: Test - working-directory: ${{github.workspace}}/build + working-directory: ${{ github.workspace }}/build # Exclude LocalLogRepository test as they write to the filesystem run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure -E "LocalLogRepository" + + static-analysis: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Prepare environment + run: sudo apt-get update && sudo apt-get install libboost-program-options-dev clang-tidy + + - name: Configure CMake + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=Off + + - name: Build + run: cmake --build ${{github.workspace}}/build --config Release + - name: Static Analysis - if: always() run: ln -s ./build/compile_commands.json && run-clang-tidy ./source/ code-formatting: @@ -45,5 +111,8 @@ jobs: steps: - uses: actions/checkout@v3 - - name: clang-format - run: find ./source ./test -iname '*.cpp' -o -iname '*.hpp' | xargs clang-format -n -Werror --ferror-limit=1 + - uses: DoozyX/clang-format-lint-action@v0.16.2 + with: + source: 'source test' + extensions: 'hpp,cpp' + clangFormatVersion: 16 diff --git a/CMakeLists.txt b/CMakeLists.txt index a5fbfd8..254b366 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ include(FetchContent) set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE) FetchContent_Declare(ftxui GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui - GIT_TAG v3.0.0 + GIT_TAG v5.0.0 ) FetchContent_GetProperties(ftxui) if(NOT ftxui_POPULATED) diff --git a/caps-log_0.1_arm64.snap b/caps-log_0.1_arm64.snap new file mode 100644 index 0000000..36c679d Binary files /dev/null and b/caps-log_0.1_arm64.snap differ diff --git a/source/app.hpp b/source/app.hpp index f98dfc2..3c03fa8 100644 --- a/source/app.hpp +++ b/source/app.hpp @@ -53,8 +53,8 @@ class App : public InputHandlerBase { App(std::shared_ptr view, std::shared_ptr repo, std::shared_ptr editor, bool skipFirstLine = true) : m_displayedYear(Date::getToday().year), m_view{std::move(view)}, m_repo{std::move(repo)}, - m_editor{std::move(editor)}, m_data{YearOverviewData::collect( - m_repo, date::Date::getToday().year, skipFirstLine)}, + m_editor{std::move(editor)}, + m_data{YearOverviewData::collect(m_repo, date::Date::getToday().year, skipFirstLine)}, m_skipFirstLine{skipFirstLine} { m_view->setInputHandler(this); m_view->setAvailableLogsMap(&m_data.logAvailabilityMap); diff --git a/source/model/log_repository_base.hpp b/source/model/log_repository_base.hpp index 24f3d4a..88fa3a2 100644 --- a/source/model/log_repository_base.hpp +++ b/source/model/log_repository_base.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include diff --git a/source/view/windowed_menu.hpp b/source/view/windowed_menu.hpp index fffe9e7..4b7f971 100644 --- a/source/view/windowed_menu.hpp +++ b/source/view/windowed_menu.hpp @@ -19,8 +19,8 @@ class WindowedMenu : public ComponentBase { int m_selected; public: - WindowedMenu(std::string title, std::vector *items, Ref option) { - auto menu = Menu(items, &m_selected, std::move(option)); + WindowedMenu(std::string title, MenuOption option) { + auto menu = Menu(std::move(option)); auto menuRenderer = Renderer(menu, [title = std::move(title), menu = std::move(menu)]() { if (not menu->Focused()) return window(text(title), menu->Render() | frame) | size(WIDTH, LESS_THAN, 25) | @@ -32,8 +32,8 @@ class WindowedMenu : public ComponentBase { } auto &selected() { return m_selected; } - static auto make(std::string title, std::vector *items, Ref option) { - return std::make_shared(std::move(title), items, std::move(option)); + static auto make(std::string title, MenuOption option) { + return std::make_shared(std::move(title), std::move(option)); } }; diff --git a/source/view/yearly_view.cpp b/source/view/yearly_view.cpp index be8d0b0..97dbe25 100644 --- a/source/view/yearly_view.cpp +++ b/source/view/yearly_view.cpp @@ -17,8 +17,8 @@ namespace clog::view { YearView::YearView(const date::Date &today, bool sundayStart) : m_screen{ScreenInteractive::Fullscreen()}, m_calendarButtons{Calendar::make(today, makeCalendarOptions(today, sundayStart))}, - m_tagsMenu{makeTagsMenu()}, m_sectionsMenu{makeSectionsMenu()}, m_rootComponent{ - makeFullUIComponent()} {} + m_tagsMenu{makeTagsMenu()}, m_sectionsMenu{makeSectionsMenu()}, + m_rootComponent{makeFullUIComponent()} {} void YearView::run() { m_screen.Loop(m_rootComponent); } @@ -104,18 +104,26 @@ CalendarOption YearView::makeCalendarOptions(const Date &today, bool sundayStart } std::shared_ptr YearView::makeTagsMenu() { - MenuOption option{.on_change = [this] { - m_handler->handleInputEvent( - {UIEvent::FOCUSED_TAG_CHANGE, std::to_string(m_tagsMenu->selected())}); - }}; - return WindowedMenu::make("Tags", &m_tagMenuItems, option); + MenuOption option{ + .entries = &m_tagMenuItems, + .on_change = + [this] { + m_handler->handleInputEvent( + {UIEvent::FOCUSED_TAG_CHANGE, std::to_string(m_tagsMenu->selected())}); + }, + }; + return WindowedMenu::make("Tags", option); } std::shared_ptr YearView::makeSectionsMenu() { - MenuOption option = {.on_change = [this] { - m_handler->handleInputEvent( - {UIEvent::FOCUSED_SECTION_CHANGE, std::to_string(m_sectionsMenu->selected())}); - }}; - return WindowedMenu::make("Sections", &m_sectionMenuItems, option); + MenuOption option = { + .entries = &m_sectionMenuItems, + .on_change = + [this] { + m_handler->handleInputEvent( + {UIEvent::FOCUSED_SECTION_CHANGE, std::to_string(m_sectionsMenu->selected())}); + }, + }; + return WindowedMenu::make("Sections", option); } } // namespace clog::view