From b78e637e8095cd608dcca53046446b8faf3f3828 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Tue, 8 Mar 2022 12:02:58 -0700 Subject: [PATCH 1/6] Basic FTXUI working --- CMakeLists.txt | 17 ++++++++++- src/CMakeLists.txt | 8 ++++- src/main.cpp | 74 +++++++++++++++++++++++++++++++++++----------- 3 files changed, 79 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2600ad09..52fbe7d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,22 @@ set(CMAKE_CXX_STANDARD 20) # when compiling with PCH enabled set(CMAKE_CXX_EXTENSIONS OFF) +include(FetchContent) + +set(FETCHCONTENT_UPDATES_DISCONNECTED TRUE) +FetchContent_Declare(ftxui + GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui + GIT_TAG v2.0.0 +) + +FetchContent_GetProperties(ftxui) +if(NOT ftxui_POPULATED) + FetchContent_Populate(ftxui) + add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL) +endif() + + + # Note: by default ENABLE_DEVELOPER_MODE is True # This means that all analysis (sanitizers, static analysis) # is enabled and all warnings are treated as errors @@ -22,7 +38,6 @@ set(OPT_WARNINGS_AS_ERRORS_DEVELOPER_DEFAULT TRUE) # Add project_options v0.17.0 # https://github.com/cpp-best-practices/project_options -include(FetchContent) FetchContent_Declare(_project_options URL https://github.com/cpp-best-practices/project_options/archive/refs/tags/v0.17.0.zip) FetchContent_MakeAvailable(_project_options) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 23208c22..9f7d9a3c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,5 +12,11 @@ target_link_libraries( fmt::fmt spdlog::spdlog) -target_include_directories(intro PRIVATE "${CMAKE_BINARY_DIR}/configured_files/include") +target_link_system_libraries( + intro + PRIVATE + ftxui::screen + ftxui::dom + ftxui::component) +target_include_directories(intro PRIVATE "${CMAKE_BINARY_DIR}/configured_files/include") diff --git a/src/main.cpp b/src/main.cpp index de9b1564..55a6b10a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,29 +2,26 @@ #include #include +#include // for ftxui +#include // for Slider +#include // for ScreenInteractive #include -// This file will be generated automatically when you run the CMake configuration step. -// It creates a namespace called `myproject`. -// You can modify the source template at `configured_files/config.hpp.in`. +// This file will be generated automatically when you run the CMake +// configuration step. It creates a namespace called `myproject`. You can modify +// the source template at `configured_files/config.hpp.in`. #include static constexpr auto USAGE = - R"(Naval Fate. + R"(intro Usage: - naval_fate ship new ... - naval_fate ship move [--speed=] - naval_fate ship shoot - naval_fate mine (set|remove) [--moored | --drifting] - naval_fate (-h | --help) - naval_fate --version + intro + intro (-h | --help) + intro --version Options: -h --help Show this screen. --version Show version. - --speed= Speed in knots [default: 10]. - --moored Moored (anchored) mine. - --drifting Drifting mine. )"; int main(int argc, const char **argv) @@ -35,15 +32,56 @@ int main(int argc, const char **argv) true,// show help if requested fmt::format("{} {}", myproject::cmake::project_name, - myproject::cmake::project_version));// version string, acquired from config.hpp via CMake + myproject::cmake::project_version));// version string, acquired + // from config.hpp via CMake - for (auto const &arg : args) { std::cout << arg.first << "=" << arg.second << '\n'; } + using namespace ftxui; + std::vector toggle_1_entries = { + "On", + "Off", + }; + std::vector toggle_2_entries = { + "Enabled", + "Disabled", + }; + std::vector toggle_3_entries = { + "10€", + "0€", + }; + std::vector toggle_4_entries = { + "Nothing", + "One element", + "Several elements", + }; + auto screen = ScreenInteractive::TerminalOutput(); - // Use the default logger (stdout, multi-threaded, colored) - spdlog::info("Hello, {}!", "World"); + int toggle_1_selected = 0; + int toggle_2_selected = 0; + int toggle_3_selected = 0; + int toggle_4_selected = 0; + Component toggle_1 = Toggle(&toggle_1_entries, &toggle_1_selected); + Component toggle_2 = Toggle(&toggle_2_entries, &toggle_2_selected); + Component toggle_3 = Toggle(&toggle_3_entries, &toggle_3_selected); + Component toggle_4 = Toggle(&toggle_4_entries, &toggle_4_selected); + auto quit_button = Button("Save & Quit", screen.ExitLoopClosure()); + + auto container = Container::Vertical({ toggle_1, toggle_2, toggle_3, toggle_4, quit_button }); + + auto renderer = Renderer(container, [&] { + return vbox({ text("Choose your options:"), + text(""), + hbox(text(" * Poweroff on startup : "), toggle_1->Render()), + hbox(text(" * Out of process : "), toggle_2->Render()), + hbox(text(" * Price of the information : "), toggle_3->Render()), + hbox(text(" * Number of elements : "), toggle_4->Render()), + text(""), + hbox(toggle_1_selected == 0 ? color(Color::Green, quit_button->Render()) + : color(Color::Blue, quit_button->Render())) }); + }); + + screen.Loop(renderer); - fmt::print("Hello, from {}\n", "{fmt}"); } catch (const std::exception &e) { fmt::print("Unhandled exception in main: {}", e.what()); } From 76e49af29e94268d91097ee8811f1387f7b5729e Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Wed, 9 Mar 2022 20:05:23 -0700 Subject: [PATCH 2/6] Moving towards a simple game --- src/main.cpp | 121 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 82 insertions(+), 39 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 55a6b10a..c1f5a747 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,6 +24,48 @@ static constexpr auto USAGE = --version Show version. )"; + +struct GameBoard +{ + static constexpr std::size_t width = 5; + static constexpr std::size_t height = 5; + + std::array, width> strings; + std::array, width> values{}; + + void set(std::size_t x, std::size_t y, bool new_value) + { + values[x][y] = new_value; + + if (new_value) { + strings[x][y] = " ON"; + } else { + strings[x][y] = "OFF"; + } + } + + bool get(std::size_t x, std::size_t y) { return values[x][y]; } + + GameBoard() { update_strings(); } + + void update_strings() + { + for (std::size_t x = 0; x < width; ++x) { + for (std::size_t y = 0; y < height; ++y) { set(x, y, get(x, y)); } + } + } + + void toggle(std::size_t x, std::size_t y) { set(x, y, !get(x, y)); } + + void press(std::size_t x, std::size_t y) + { + if (x > 0) { toggle(x - 1, y); } + if (y > 0) { toggle(x, y - 1); } + if (x < width - 1) { toggle(x + 1, y); } + if (y < height - 1) { toggle(x, y + 1); } + } +}; + int main(int argc, const char **argv) { try { @@ -36,49 +78,50 @@ int main(int argc, const char **argv) // from config.hpp via CMake using namespace ftxui; - std::vector toggle_1_entries = { - "On", - "Off", - }; - std::vector toggle_2_entries = { - "Enabled", - "Disabled", - }; - std::vector toggle_3_entries = { - "10€", - "0€", + auto screen = ScreenInteractive::TerminalOutput(); + + GameBoard gb; + + const auto make_buttons = [&] { + std::vector buttons; + for (std::size_t x = 0; x < gb.width; ++x) { + for (std::size_t y = 0; y < gb.height; ++y) { + buttons.push_back(ftxui::Button(&gb.strings[x][y], [x, y, &gb] { gb.press(x,y); })); + } + } + return buttons; }; - std::vector toggle_4_entries = { - "Nothing", - "One element", - "Several elements", + + auto buttons = make_buttons(); + + auto container = Container::Horizontal(buttons); + + auto make_layout = [&] { + std::vector columns; + + std::size_t idx = 0; + + for (std::size_t x = 0; x < gb.width; ++x) { + std::vector row; + for (std::size_t y = 0; y < gb.height; ++y) { + row.push_back(buttons[idx]->Render()); + ++idx; + } + columns.push_back(ftxui::hbox(std::move(row))); + } + + return ftxui::vbox(std::move(columns)); }; - auto screen = ScreenInteractive::TerminalOutput(); + auto renderer = Renderer(container, make_layout); + - int toggle_1_selected = 0; - int toggle_2_selected = 0; - int toggle_3_selected = 0; - int toggle_4_selected = 0; - Component toggle_1 = Toggle(&toggle_1_entries, &toggle_1_selected); - Component toggle_2 = Toggle(&toggle_2_entries, &toggle_2_selected); - Component toggle_3 = Toggle(&toggle_3_entries, &toggle_3_selected); - Component toggle_4 = Toggle(&toggle_4_entries, &toggle_4_selected); - auto quit_button = Button("Save & Quit", screen.ExitLoopClosure()); - - auto container = Container::Vertical({ toggle_1, toggle_2, toggle_3, toggle_4, quit_button }); - - auto renderer = Renderer(container, [&] { - return vbox({ text("Choose your options:"), - text(""), - hbox(text(" * Poweroff on startup : "), toggle_1->Render()), - hbox(text(" * Out of process : "), toggle_2->Render()), - hbox(text(" * Price of the information : "), toggle_3->Render()), - hbox(text(" * Number of elements : "), toggle_4->Render()), - text(""), - hbox(toggle_1_selected == 0 ? color(Color::Green, quit_button->Render()) - : color(Color::Blue, quit_button->Render())) }); - }); + /* + return vbox({ text("Turn all boxes to 'on':"), + text(""), + hbox(toggle_1_selected == 0 ? color(Color::Green, quit_button->Render()) + : color(Color::Blue, quit_button->Render())) }); + */ screen.Loop(renderer); From 9036cfc49568aca6ffe46fdd013608056a49b78b Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Thu, 10 Mar 2022 18:50:12 -0700 Subject: [PATCH 3/6] Basic game working --- src/main.cpp | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c1f5a747..6769cbbd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include // for ftxui @@ -44,9 +45,19 @@ struct GameBoard } } - bool get(std::size_t x, std::size_t y) { return values[x][y]; } + void visit(auto visitor) + { + for (std::size_t x = 0; x < width; ++x) { + for (std::size_t y = 0; y < height; ++y) { visitor(x, y, *this); } + } + } - GameBoard() { update_strings(); } + bool get(std::size_t x, std::size_t y) const { return values[x][y]; } + + GameBoard() + { + visit([](const auto x, const auto y, auto &gameboard) { gameboard.set(x, y, true); }); + } void update_strings() { @@ -64,6 +75,17 @@ struct GameBoard if (x < width - 1) { toggle(x + 1, y); } if (y < height - 1) { toggle(x, y + 1); } } + + bool solved() const + { + for (std::size_t x = 0; x < width; ++x) { + for (std::size_t y = 0; y < height; ++y) { + if (!get(x, y)) { return false; } + } + } + + return true; + } }; int main(int argc, const char **argv) @@ -86,7 +108,10 @@ int main(int argc, const char **argv) std::vector buttons; for (std::size_t x = 0; x < gb.width; ++x) { for (std::size_t y = 0; y < gb.height; ++y) { - buttons.push_back(ftxui::Button(&gb.strings[x][y], [x, y, &gb] { gb.press(x,y); })); + buttons.push_back(ftxui::Button(&gb.strings[x][y], [x, y, &gb, &screen] { + gb.press(x, y); + if (gb.solved()) { screen.ExitLoopClosure()(); } + })); } } return buttons; @@ -113,15 +138,14 @@ int main(int argc, const char **argv) return ftxui::vbox(std::move(columns)); }; - auto renderer = Renderer(container, make_layout); + std::mt19937 gen32; + std::uniform_int_distribution x(static_cast(0), gb.width - 1); + std::uniform_int_distribution y(static_cast(0), gb.height - 1); + for (int i = 0; i < 100; ++i) { gb.press(x(gen32), y(gen32)); } + + auto renderer = Renderer(container, make_layout); - /* - return vbox({ text("Turn all boxes to 'on':"), - text(""), - hbox(toggle_1_selected == 0 ? color(Color::Green, quit_button->Render()) - : color(Color::Blue, quit_button->Render())) }); - */ screen.Loop(renderer); From 2035d93e755655503e54b769d576ab64af23efb4 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 14 Mar 2022 10:43:18 -0600 Subject: [PATCH 4/6] Make game state more obvious, playable --- src/main.cpp | 71 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6769cbbd..57e5df34 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,22 +26,29 @@ static constexpr auto USAGE = )"; -struct GameBoard +template struct GameBoard { - static constexpr std::size_t width = 5; - static constexpr std::size_t height = 5; + static constexpr std::size_t width = Width; + static constexpr std::size_t height = Height; std::array, width> strings; std::array, width> values{}; + std::size_t move_count{0}; + + std::string &get_string(std::size_t x, std::size_t y) { + return strings.at(x).at(y); + } + + void set(std::size_t x, std::size_t y, bool new_value) { - values[x][y] = new_value; + get(x,y) = new_value; if (new_value) { - strings[x][y] = " ON"; + get_string(x,y) = " ON"; } else { - strings[x][y] = "OFF"; + get_string(x,y) = "OFF"; } } @@ -52,7 +59,9 @@ struct GameBoard } } - bool get(std::size_t x, std::size_t y) const { return values[x][y]; } + [[nodiscard]] bool get(std::size_t x, std::size_t y) const { return values.at(x).at(y); } + + [[nodiscard]] bool &get(std::size_t x, std::size_t y) { return values.at(x).at(y); } GameBoard() { @@ -70,13 +79,15 @@ struct GameBoard void press(std::size_t x, std::size_t y) { + ++move_count; + toggle(x, y); if (x > 0) { toggle(x - 1, y); } if (y > 0) { toggle(x, y - 1); } if (x < width - 1) { toggle(x + 1, y); } if (y < height - 1) { toggle(x, y + 1); } } - bool solved() const + [[nodiscard]] bool solved() const { for (std::size_t x = 0; x < width; ++x) { for (std::size_t y = 0; y < height; ++y) { @@ -99,18 +110,24 @@ int main(int argc, const char **argv) myproject::cmake::project_version));// version string, acquired // from config.hpp via CMake - using namespace ftxui; - auto screen = ScreenInteractive::TerminalOutput(); + auto screen = ftxui::ScreenInteractive::TerminalOutput(); + + GameBoard<3, 3> gb; - GameBoard gb; + std::string quit_text; + + const auto update_quit_text = [&quit_text](const auto &game_board) { + quit_text = fmt::format("Quit ({} moves)", game_board.move_count); + if (game_board.solved()) { quit_text += " Solved!"; } + }; const auto make_buttons = [&] { std::vector buttons; for (std::size_t x = 0; x < gb.width; ++x) { for (std::size_t y = 0; y < gb.height; ++y) { - buttons.push_back(ftxui::Button(&gb.strings[x][y], [x, y, &gb, &screen] { - gb.press(x, y); - if (gb.solved()) { screen.ExitLoopClosure()(); } + buttons.push_back(ftxui::Button(&gb.get_string(x,y), [=, &gb] { + if (!gb.solved()) { gb.press(x, y); } + update_quit_text(gb); })); } } @@ -119,10 +136,10 @@ int main(int argc, const char **argv) auto buttons = make_buttons(); - auto container = Container::Horizontal(buttons); + auto quit_button = ftxui::Button(&quit_text, screen.ExitLoopClosure()); auto make_layout = [&] { - std::vector columns; + std::vector rows; std::size_t idx = 0; @@ -132,23 +149,35 @@ int main(int argc, const char **argv) row.push_back(buttons[idx]->Render()); ++idx; } - columns.push_back(ftxui::hbox(std::move(row))); + rows.push_back(ftxui::hbox(std::move(row))); } - return ftxui::vbox(std::move(columns)); + rows.push_back(ftxui::hbox({ quit_button->Render() })); + + return ftxui::vbox(std::move(rows)); }; - std::mt19937 gen32; + + static constexpr int randomization_iterations = 100; + static constexpr int random_seed = 42; + + std::mt19937 gen32{random_seed}; // NOLINT std::uniform_int_distribution x(static_cast(0), gb.width - 1); std::uniform_int_distribution y(static_cast(0), gb.height - 1); - for (int i = 0; i < 100; ++i) { gb.press(x(gen32), y(gen32)); } + for (int i = 0; i < randomization_iterations; ++i) { gb.press(x(gen32), y(gen32)); } + gb.move_count = 0; + update_quit_text(gb); - auto renderer = Renderer(container, make_layout); + auto all_buttons = buttons; + all_buttons.push_back(quit_button); + auto container = ftxui::Container::Horizontal(all_buttons); + auto renderer = ftxui::Renderer(container, make_layout); screen.Loop(renderer); + } catch (const std::exception &e) { fmt::print("Unhandled exception in main: {}", e.what()); } From 60d696fa01a5f84478e9720532cc6ef934c4f426 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Wed, 16 Mar 2022 12:57:36 -0600 Subject: [PATCH 5/6] Add template janitor sanity check / enhancements (#9) --- .github/template/template_name | 1 + .github/template/template_repository | 1 + .github/workflows/template-janitor.yml | 47 ++++++++++--- .github/workflows/template-renamer.yml | 94 ++++++++++++++++++++++++++ CMakeLists.txt | 2 +- README.md | 2 +- 6 files changed, 136 insertions(+), 11 deletions(-) create mode 100644 .github/template/template_name create mode 100644 .github/template/template_repository create mode 100644 .github/workflows/template-renamer.yml diff --git a/.github/template/template_name b/.github/template/template_name new file mode 100644 index 00000000..9f9b489e --- /dev/null +++ b/.github/template/template_name @@ -0,0 +1 @@ +cpp_boilerplate_project diff --git a/.github/template/template_repository b/.github/template/template_repository new file mode 100644 index 00000000..622fb5a7 --- /dev/null +++ b/.github/template/template_repository @@ -0,0 +1 @@ +cpp-best-practices/cpp_boilerplate_project diff --git a/.github/workflows/template-janitor.yml b/.github/workflows/template-janitor.yml index 20f5bb83..b64b0630 100644 --- a/.github/workflows/template-janitor.yml +++ b/.github/workflows/template-janitor.yml @@ -1,11 +1,16 @@ # This workflow should cleanup everything unneeded from the template project name: Template Janitor + on: + pull_request: + release: + types: [published] push: + tags: branches: - - develop - - main # maybe all to run "tests" on every change? + - main + - develop env: TEMPLATES_PATH: ".github/template" @@ -23,7 +28,7 @@ jobs: run: | echo "NEW_ORG=${{ github.repository_owner }}" >> $GITHUB_ENV echo "NEW_PROJECT=${{ github.event.repository.name }}" >> $GITHUB_ENV - echo "NEW_URL=${{ github.repositoryUrl}}" >> $GITHUB_ENV + echo "NEW_URL=${{ github.repositoryUrl }}" >> $GITHUB_ENV - uses: octokit/request-action@v2.x id: get_repo_meta @@ -41,17 +46,17 @@ jobs: sed -i "s/myproject/${{ github.event.repository.name }}/gi" CMakeLists.txt configured_files/config.hpp.in # Update URL placeholders for project - sed -i "s/%%myurl%%/${{ github.event.repositoryUrl }}/gi" CMakeLists.txt + sed -i "s|%%myurl%%|${{ fromJson(steps.get_repo_meta.outputs.data).html_url }}|gi" CMakeLists.txt # fill in placeholders of readme and move it into place sed -i "s/%%myorg%%/${{ env.NEW_ORG }}/g" ${{ env.TEMPLATES_PATH }}/README.md sed -i "s/%%myproject%%/${{ env.NEW_PROJECT }}/g" ${{ env.TEMPLATES_PATH }}/README.md - sed -i "s/%%description%%/${{ fromJson(steps.get_repo_meta.outputs.data).description }}/g" ${{ env.TEMPLATES_PATH }}/README.md + sed -i "s|%%description%%|${{ fromJson(steps.get_repo_meta.outputs.data).description }}|g" ${{ env.TEMPLATES_PATH }}/README.md cp ${{ env.TEMPLATES_PATH }}/README.md README.md - name: Print diff after replacement run: | - # Exclude the README as that is checked seperatly! + # Exclude the README as that is checked separately! git diff ':!README.md' # following should not have any diffs diff ${{ env.TEMPLATES_PATH }}/README.md README.md @@ -63,11 +68,35 @@ jobs: - name: Clean up before commit and push run: | - rm -rf ${{ env.TEMPLATES_PATH }} + rm -r ${{ env.TEMPLATES_PATH }} - # Can we get that from a variabl? + # Can we get that from a variable? # Remove this workflow as it has fulfilled its purpose - rm -rf .github/workflows/template-janitor.yml + rm .github/workflows/template-janitor.yml + rm .github/workflows/template-renamer.yml + + - name: Setup Cpp + uses: aminya/setup-cpp@v1 + with: + compiler: gcc + + cmake: true + ninja: false + conan: true + vcpkg: false + ccache: false + clangtidy: false + + cppcheck: false + + gcovr: false + opencppcoverage: false + + + - name: Test simple configuration to make sure nothing broke (default compiler,cmake,developer_mode OFF) + run: | + cmake -S . -B ./build -DCMAKE_BUILD_TYPE:STRING=DEBUG -DENABLE_DEVELOPER_MODE:BOOL=OFF -DOPT_ENABLE_COVERAGE:BOOL=OFF + - uses: EndBug/add-and-commit@v4 # only commit and push if we are not a template project anymore! diff --git a/.github/workflows/template-renamer.yml b/.github/workflows/template-renamer.yml new file mode 100644 index 00000000..fce3b6fe --- /dev/null +++ b/.github/workflows/template-renamer.yml @@ -0,0 +1,94 @@ +# This workflow should cleanup everything unneeded from the template project + +name: Template Renamer + +on: + pull_request: + release: + types: [published] + push: + tags: + branches: + - main + - develop + +env: + TEMPLATES_PATH: ".github/template" + +jobs: + + template-rename: + name: Renames template when a new name is detected + runs-on: ubuntu-latest + steps: + - name: Fetch Sources + uses: actions/checkout@v2.4.0 + + - name: Get organization and project name + run: | + echo "TEST_RUN=false" >> $GITHUB_ENV + echo "NEW_ORG=${{ github.repository_owner }}" >> $GITHUB_ENV + echo "NEW_PROJECT=${{ github.event.repository.name }}" >> $GITHUB_ENV + echo "NEW_REPOSITORY=${{ github.repository }}" >> $GITHUB_ENV + echo "TEMPLATE_NAME=`cat ${{ env.TEMPLATES_PATH }}/template_name`" >> $GITHUB_ENV + echo "TEMPLATE_REPOSITORY=`cat ${{ env.TEMPLATES_PATH }}/template_repository`" >> $GITHUB_ENV + + - uses: octokit/request-action@v2.x + id: get_repo_meta + with: + route: GET /repos/{owner}/{repo} + owner: ${{ env.NEW_ORG }} + repo: ${{ env.NEW_PROJECT }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup fake test org/project names if project didn't change + if: env.TEMPLATE_NAME == env.NEW_PROJECT + run: | + echo "TEST_RUN=true" >> $GITHUB_ENV + echo "NEW_ORG=${{ github.repository_owner }}" >> $GITHUB_ENV + echo "NEW_PROJECT=TEST_PROJECT" >> $GITHUB_ENV + echo "NEW_REPOSITORY=TEST_REPOSITORY" >> $GITHUB_ENV + + + # Rename all cpp_starter_project occurrences to current repository and remove this workflow + - name: Update repository to match new template information + run: | + # Update the README and template files to match the new org / repository names + sed -i "s|${{ env.TEMPLATE_REPOSITORY }}|${{ env.NEW_REPOSITORY }}|g" README.md ${{ env.TEMPLATES_PATH }}/template_repository + sed -i "s|${{ env.TEMPLATE_NAME }}|${{ env.NEW_PROJECT }}|g" README.md ${{ env.TEMPLATES_PATH }}/template_name + + - name: Print diff after template name replacement + run: | + git diff + + - name: Setup Cpp + uses: aminya/setup-cpp@v1 + with: + compiler: gcc + + cmake: true + ninja: false + conan: true + vcpkg: false + ccache: false + clangtidy: false + + cppcheck: false + + gcovr: false + opencppcoverage: false + + - name: Test simple configuration to make sure nothing broke (default compiler,cmake,developer_mode OFF) + run: | + cmake -S . -B ./build -DCMAKE_BUILD_TYPE:STRING=DEBUG -DENABLE_DEVELOPER_MODE:BOOL=OFF -DOPT_ENABLE_COVERAGE:BOOL=OFF + + - uses: EndBug/add-and-commit@v4 + # only commit and push if we are a template and project name has changed + if: fromJson(steps.get_repo_meta.outputs.data).is_template == true && env.TEST_RUN == 'false' + with: + author_name: Template Janitor + author_email: template.janitor@example.com + message: 'Change Template Name' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 2600ad09..5bb3bee9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ project( myproject VERSION 0.0.1 DESCRIPTION "" - HOMEPAGE_URL "%%url%%" + HOMEPAGE_URL "%%myurl%%" LANGUAGES CXX C) set(GIT_SHA diff --git a/README.md b/README.md index 8f666d88..860389e3 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![ci](https://github.com/cpp-best-practices/cpp_boilerplate_project/actions/workflows/ci.yml/badge.svg)](https://github.com/cpp-best-practices/cpp_boilerplate_project/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/cpp-best-practices/cpp_boilerplate_project/branch/main/graph/badge.svg)](https://codecov.io/gh/cpp-best-practices/cpp_boilerplate_project) -[![Language grade: C++](https://img.shields.io/lgtm/grade/cpp/github/cpp-best-practices/cpp_boilerplate_project)](https://lgtm.com/projects/g/cpp-best-practices/cpp_starter_project/context:cpp) +[![Language grade: C++](https://img.shields.io/lgtm/grade/cpp/github/cpp-best-practices/cpp_boilerplate_project)](https://lgtm.com/projects/g/cpp-best-practices/cpp_boilerplate_project/context:cpp) [![CodeQL](https://github.com/cpp-best-practices/cpp_boilerplate_project/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/cpp-best-practices/cpp_boilerplate_project/actions/workflows/codeql-analysis.yml) ## About cpp_boilerplate_project From f910e5bc3098ea6cd119a597f8f1f65a3e6a8239 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Wed, 16 Mar 2022 13:07:03 -0600 Subject: [PATCH 6/6] Update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 860389e3..8e4e5593 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,9 @@ It requires * conan * a compiler -If you want a more complex example project, check out the [cpp_starter_project](https://github.com/cpp-best-practices/cpp_starter_project). -Ths Boilerplate project will merge new features first, then they will be merged (as appropriate) into cpp_starter_project. +This project gets you started with a simple example of using FTXUI, which happens to also be a game + ## Getting Started