From b55c6569a4850e67842083ba4313b2a4a06cae41 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 09:32:00 -0700 Subject: [PATCH 01/17] change status badge name --- docs/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index 07264802..7d6fbf67 100644 --- a/docs/README.md +++ b/docs/README.md @@ -43,7 +43,7 @@ The diagram describes the current state of parser implementation and data availa | | | | |-|-|-| | Build | | [![CMake Build Multi-Platform](https://github.com/nam20485/OdbDesign/actions/workflows/cmake-multi-platform.yml/badge.svg?branch=development)](https://github.com/nam20485/OdbDesign/actions/workflows/cmake-multi-platform.yml) | -| Code Scan | | [![CodeQL](https://github.com/nam20485/OdbDesign/actions/workflows/codeql.yml/badge.svg?branch=development)](https://github.com/nam20485/OdbDesign/actions/workflows/codeql.yml) | +| Security Scan | | [![CodeQL](https://github.com/nam20485/OdbDesign/actions/workflows/codeql.yml/badge.svg?branch=development)](https://github.com/nam20485/OdbDesign/actions/workflows/codeql.yml) | | Docker | | [![Docker Publish](https://github.com/nam20485/OdbDesign/actions/workflows/docker-publish.yml/badge.svg?branch=development)](https://github.com/nam20485/OdbDesign/actions/workflows/docker-publish.yml) | ##### `main` @@ -51,7 +51,7 @@ The diagram describes the current state of parser implementation and data availa | | | | |-|-|-| | Build | | [![CMake Build Multi-Platform](https://github.com/nam20485/OdbDesign/actions/workflows/cmake-multi-platform.yml/badge.svg?branch=main)](https://github.com/nam20485/OdbDesign/actions/workflows/cmake-multi-platform.yml) | -| Code Scan | | [![CodeQL](https://github.com/nam20485/OdbDesign/actions/workflows/codeql.yml/badge.svg?branch=main)](https://github.com/nam20485/OdbDesign/actions/workflows/codeql.yml) | +| Security Scan | | [![CodeQL](https://github.com/nam20485/OdbDesign/actions/workflows/codeql.yml/badge.svg?branch=main)](https://github.com/nam20485/OdbDesign/actions/workflows/codeql.yml) | | Docker | | [![Docker Publish](https://github.com/nam20485/OdbDesign/actions/workflows/docker-publish.yml/badge.svg?branch=main)](https://github.com/nam20485/OdbDesign/actions/workflows/docker-publish.yml) | ### Architecture From 282f791c0798d023dabae2aa618eb2c0cfca1880 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 12:01:44 -0700 Subject: [PATCH 02/17] reformat CI/CD table and add paragraph about Architecture --- docs/README.md | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/docs/README.md b/docs/README.md index 7d6fbf67..b78df142 100644 --- a/docs/README.md +++ b/docs/README.md @@ -34,28 +34,32 @@ The diagram describes the current state of parser implementation and data availa ![image](https://github.com/nam20485/OdbDesign/assets/1829396/d55d0ea8-6ad9-446a-8659-9157636e1c9f) -### CI/CD Build Statuses +### CI/CD Build #### Branches ##### `development` -| | | | -|-|-|-| -| Build | | [![CMake Build Multi-Platform](https://github.com/nam20485/OdbDesign/actions/workflows/cmake-multi-platform.yml/badge.svg?branch=development)](https://github.com/nam20485/OdbDesign/actions/workflows/cmake-multi-platform.yml) | -| Security Scan | | [![CodeQL](https://github.com/nam20485/OdbDesign/actions/workflows/codeql.yml/badge.svg?branch=development)](https://github.com/nam20485/OdbDesign/actions/workflows/codeql.yml) | -| Docker | | [![Docker Publish](https://github.com/nam20485/OdbDesign/actions/workflows/docker-publish.yml/badge.svg?branch=development)](https://github.com/nam20485/OdbDesign/actions/workflows/docker-publish.yml) | +| Step | Status | +|--------------------|---------| +| Build | [![CMake Build Multi-Platform](https://github.com/nam20485/OdbDesign/actions/workflows/cmake-multi-platform.yml/badge.svg?branch=development)](https://github.com/nam20485/OdbDesign/actions/workflows/cmake-multi-platform.yml) | +| Security Code Scan | [![CodeQL](https://github.com/nam20485/OdbDesign/actions/workflows/codeql.yml/badge.svg?branch=development)](https://github.com/nam20485/OdbDesign/actions/workflows/codeql.yml) | +| Docker Image | [![Docker Publish](https://github.com/nam20485/OdbDesign/actions/workflows/docker-publish.yml/badge.svg?branch=development)](https://github.com/nam20485/OdbDesign/actions/workflows/docker-publish.yml) | ##### `main` -| | | | -|-|-|-| -| Build | | [![CMake Build Multi-Platform](https://github.com/nam20485/OdbDesign/actions/workflows/cmake-multi-platform.yml/badge.svg?branch=main)](https://github.com/nam20485/OdbDesign/actions/workflows/cmake-multi-platform.yml) | -| Security Scan | | [![CodeQL](https://github.com/nam20485/OdbDesign/actions/workflows/codeql.yml/badge.svg?branch=main)](https://github.com/nam20485/OdbDesign/actions/workflows/codeql.yml) | -| Docker | | [![Docker Publish](https://github.com/nam20485/OdbDesign/actions/workflows/docker-publish.yml/badge.svg?branch=main)](https://github.com/nam20485/OdbDesign/actions/workflows/docker-publish.yml) | +| Step | Status | +|--------------------|----------| +| Build | [![CMake Build Multi-Platform](https://github.com/nam20485/OdbDesign/actions/workflows/cmake-multi-platform.yml/badge.svg?branch=main)](https://github.com/nam20485/OdbDesign/actions/workflows/cmake-multi-platform.yml) | +| Security Code Scan | [![CodeQL](https://github.com/nam20485/OdbDesign/actions/workflows/codeql.yml/badge.svg?branch=main)](https://github.com/nam20485/OdbDesign/actions/workflows/codeql.yml) | +| Docker Image | [![Docker Publish](https://github.com/nam20485/OdbDesign/actions/workflows/docker-publish.yml/badge.svg?branch=main)](https://github.com/nam20485/OdbDesign/actions/workflows/docker-publish.yml) | ### Architecture +The OdbDesign parser is built as a C++ shared library on all three platforms. An executable running the server links to the library and provides the REST API for accessing the data the library parses. The REST API server can be run by invoking the executable directly or by running the Docker image. The server executable and library can be run on Windows, Linux, or MacOS and the Docker image can be run on any platform that supports Docker. + +[Insert Diagram Image] + ## Building from Source ### Build Dependencies @@ -125,7 +129,9 @@ $ cmake --build --preset linux-release $ docker build -f Dockerfile_OdbDesignServer . -t odbdesign-server ``` -## Integration +## Running the REST API Server + +## Integration into Other Applications There are four interfaces that allow use of the library in other applications. From 9c4a897cf4d61df1216fbbc0d6e80f386dbffb65 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 12:07:21 -0700 Subject: [PATCH 03/17] run workflows for all branches and pull requests --- .github/workflows/cmake-multi-platform.yml | 6 +++--- .github/workflows/codeql.yml | 5 ++--- .github/workflows/docker-build.yml | 6 +++--- .github/workflows/docker-publish.yml | 4 +++- .github/workflows/msvc.yml | 4 +--- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 2b0ebc30..3e0ac7ce 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -3,10 +3,10 @@ name: CMake Build Multi-Platform on: push: - branches: [ "development", "main" ] + branches: [ "development", "main", "release" ] pull_request: - branches: [ "development" ] - workflow_dispatch: + branches: [ "development", "main", "release" ] + #workflow_dispatch: permissions: contents: write diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 17375e7e..355213eb 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -13,10 +13,9 @@ name: "CodeQL" on: push: - branches: [ "development", main, release ] + branches: [ "development", "main", "release" ] pull_request: - # The branches below must be a subset of the branches above - branches: [ "development" ] + branches: [ "development", "main", "release" ] env: VCPKG_ROOT: ${{ github.workspace }}/vcpkg diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 782a81bb..4b63fffe 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -1,10 +1,10 @@ name: Docker Build on: - # push: - # branches: [ "main" ] + #push: + # branches: [ "development", "main", "release" ] pull_request: - branches: [ "*" ] + branches: [ "development", "main", "release" ] jobs: diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 7a4ff51c..5fcfd5ed 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -7,7 +7,9 @@ name: Docker Publish on: push: - branches: [ "*" ] + branches: [ "development", "main", "release" ] + #pull_request: + # branches: [ "development", "main", "release" ] env: # Use docker.io for Docker Hub if empty diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml index fbf7e227..1e777c54 100644 --- a/.github/workflows/msvc.yml +++ b/.github/workflows/msvc.yml @@ -12,9 +12,7 @@ on: push: branches: [ "development", "main", "release" ] pull_request: - branches: [ "development" ] - schedule: - - cron: '23 4 * * 6' + branches: [ "development", "main", "release" ] env: # Path to the CMake build directory. From 482cc137afe545d74c2f8cc1eaa43986d02dabd5 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 12:25:29 -0700 Subject: [PATCH 04/17] add openssl package as vcpkg dependency --- vcpkg.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vcpkg.json b/vcpkg.json index a68e4755..7e6ae209 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -2,12 +2,13 @@ "dependencies": [ "libarchive", "zlib", - "crow", + "crow", { "name": "protobuf", "features": [ - "zlib" + "zlib" ] - } + }, + "openssl" ] } From bbb8014ff493479be8a72f09df38ac765f7be315 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 13:37:26 -0700 Subject: [PATCH 05/17] add step to install vcpkg dependencies --- .github/workflows/cmake-multi-platform.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 3e0ac7ce..8cfc8e6a 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -5,8 +5,7 @@ on: push: branches: [ "development", "main", "release" ] pull_request: - branches: [ "development", "main", "release" ] - #workflow_dispatch: + branches: [ "development", "main", "release" ] permissions: contents: write @@ -48,6 +47,12 @@ jobs: - uses: actions/checkout@v3 + - name: Install vcpkg Dependencies + run: | + sudo apt update + sudo apt install -y -q --no-install-recommends build-essential tar curl zip unzip + if: matrix.os == 'ubuntu-22.04' + # # os != windows-2022 (i.e. Linux, MacOS) # From 2db2288e851c78c99ead24879b262f712eb2ffd7 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 16:52:04 -0700 Subject: [PATCH 06/17] add ovverride for passing string exception info --- Utils/Logger.cpp | 8 +++++++- Utils/Logger.h | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Utils/Logger.cpp b/Utils/Logger.cpp index d434c77e..dbb0b7f4 100644 --- a/Utils/Logger.cpp +++ b/Utils/Logger.cpp @@ -74,7 +74,13 @@ namespace Utils void Logger::exception(const std::exception& e, const std::string& file, int line) { - error(e.what(), file, line); + exception(e.what(), file, line); + } + + void Logger::exception(const std::string& message, const std::string& file, int line) + { + std::string s = "EXCEPTION!: " + message; + error(s, file, line); } void Logger::start() diff --git a/Utils/Logger.h b/Utils/Logger.h index fb3a0e75..1a2b1681 100644 --- a/Utils/Logger.h +++ b/Utils/Logger.h @@ -71,6 +71,7 @@ namespace Utils void info(const std::stringstream& message, const std::string& file = "", int line = -1); void debug(const std::string& message, const std::string& file = "", int line = -1); void exception(const std::exception& e, const std::string& file = "", int line = -1); + void exception(const std::string& message, const std::string& file = "", int line = -1); template Logger& operator<<(const T& output); @@ -92,7 +93,7 @@ namespace Utils }; template - inline Logger& Logger::operator<<(const T& output) + Logger& Logger::operator<<(const T& output) { log(Level::Info, output); return *this; From 3d58ccd705c47ce272f81c019d241564f59adb9f Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 16:52:19 -0700 Subject: [PATCH 07/17] log start and stopping of logger --- Utils/Logger.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Utils/Logger.cpp b/Utils/Logger.cpp index dbb0b7f4..71520e71 100644 --- a/Utils/Logger.cpp +++ b/Utils/Logger.cpp @@ -85,11 +85,13 @@ namespace Utils void Logger::start() { + info("logger started"); m_logMessageLoop.startProcessing(); } void Logger::stop() { + info("logger stopping"); m_logMessageLoop.stopProcessing(); } From acbf77a6d82c6d3cd6d5c70250332bc7d56adbb6 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 16:52:43 -0700 Subject: [PATCH 08/17] copy test executable into bin dir in Dockerfile --- Dockerfile_OdbDesignServer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile_OdbDesignServer b/Dockerfile_OdbDesignServer index f881cf13..61c16523 100644 --- a/Dockerfile_OdbDesignServer +++ b/Dockerfile_OdbDesignServer @@ -57,7 +57,7 @@ COPY --from=build /src/OdbDesign/out/build/linux-release/OdbDesignLib/*.so . COPY --from=build /src/OdbDesign/out/build/linux-release/Utils/*.so . COPY --from=build /src/OdbDesign/out/build/linux-release/OdbDesignServer/OdbDesignServer . COPY --from=build /src/OdbDesign/out/build/linux-release/OdbDesignServer/*.so . -COPY --from=build /src/OdbDesign/out/build/linux-release/*.so . +COPY --from=build /src/OdbDesign/out/build/linux-release/OdbDesignTest/OdbDesignTest . # copy designs and templates directories #COPY --from=build /src/OdbDesign/OdbDesignServer/designs ./designs #COPY --from=build /src/OdbDesign/OdbDesignServer/templates ./templates From 205225f0e0296ef317f0f7311db85137a7c40869 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 16:53:13 -0700 Subject: [PATCH 09/17] use Visual Studio 17 2022 generator in cmake command for msvc code scan workflow --- .github/workflows/msvc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml index 1e777c54..7ed6f8fd 100644 --- a/.github/workflows/msvc.yml +++ b/.github/workflows/msvc.yml @@ -53,7 +53,7 @@ jobs: run: "& \"${{env.VCPKG_ROOT}}/vcpkg\" install --triplet x64-windows" - name: CMake Configure - run: cmake --preset x64-release -B ${{ env.build }} + run: cmake --preset x64-release -B ${{ env.build }} -G "Visual Studio 17 2022" # - name: Configure CMake # run: cmake -B ${{ env.build }} From 55bc6f2bfa161075bb6bc906a357264aa85d83a6 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 18:07:18 -0700 Subject: [PATCH 10/17] add exit code for SSL initialization failure --- Utils/ExitCode.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Utils/ExitCode.h b/Utils/ExitCode.h index 3ef5a456..293501c7 100644 --- a/Utils/ExitCode.h +++ b/Utils/ExitCode.h @@ -6,7 +6,8 @@ namespace Utils enum class ExitCode { Success = 0, - FailedInit, + FailedInit = 1, + FailedInitSsl = 2, UnknownError }; } From 28441d6e754e9d1df6d4f9a19a5bb7af1923782a Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 18:08:14 -0700 Subject: [PATCH 11/17] add argument for providing default when argument name specified was not provided and functions for getting the executable's durectory and name --- Utils/CommandLineArgs.cpp | 68 ++++++++++++++++++++++++++++++--------- Utils/CommandLineArgs.h | 15 ++++++--- 2 files changed, 64 insertions(+), 19 deletions(-) diff --git a/Utils/CommandLineArgs.cpp b/Utils/CommandLineArgs.cpp index 7ef3a725..e3bde128 100644 --- a/Utils/CommandLineArgs.cpp +++ b/Utils/CommandLineArgs.cpp @@ -2,6 +2,10 @@ #include "CommandLineArgs.h" #include "CommandLineArgs.h" #include "CommandLineArgs.h" +#include "CommandLineArgs.h" +#include "CommandLineArgs.h" +#include "CommandLineArgs.h" +#include "CommandLineArgs.h" #include #include #include "str_trim.h" @@ -26,32 +30,62 @@ namespace Utils parse(); } - bool CommandLineArgs::boolArg(const std::string& name) const + bool CommandLineArgs::boolArg(const std::string& name, bool default) const { auto strB = getArgValue(name); - if (strB.length() == 0) throw std::invalid_argument("Argument not found: " + name); - bool b; - std::istringstream(strB) >> std::boolalpha >> b; - return b; + if (strB.length() > 0) + { + bool b; + std::istringstream(strB) >> std::boolalpha >> b; + return b; + } + + return default; } - std::string CommandLineArgs::stringArg(const std::string& name) const + std::string CommandLineArgs::stringArg(const std::string& name, const std::string& default) const { - return getArgValue(name); + auto str = getArgValue(name); + if (str.length() > 0) + { + return str; + } + return default; } - int CommandLineArgs::intArg(const std::string& name) const + int CommandLineArgs::intArg(const std::string& name, int default) const { auto strI = getArgValue(name); - if (strI.length() == 0) throw std::invalid_argument("Argument not found: " + name); - return std::stoi(strI); + if (strI.length() > 0) + { + return std::stoi(strI); + } + return default; } - double CommandLineArgs::doubleArg(const std::string& name) const + double CommandLineArgs::doubleArg(const std::string& name, double default) const { auto strD = getArgValue(name); - if (strD.length() == 0) throw std::invalid_argument("Argument not found: " + name); - return std::stod(strD); + if (strD.length() > 0) + { + return std::stod(strD); + } + return default; + } + + std::string CommandLineArgs::executable() const + { + return getArgValue(EXECUTABLE_ARG_NAME); + } + + std::filesystem::path CommandLineArgs::executableDirectory() const + { + return std::filesystem::path(executable()).parent_path().string(); + } + + std::filesystem::path CommandLineArgs::executableName() const + { + return std::filesystem::path(executable()).filename().string(); } std::string CommandLineArgs::getArgValue(const std::string& name) const @@ -68,7 +102,11 @@ namespace Utils auto& arg = m_vecArguments[i]; if (arg.length() > 0) { - if (arg[0] == '-' || arg[0] == '/') + if (i == 0) + { + m_mapArguments["executable"] = arg; + } + else if (arg[0] == '-' || arg[0] == '/') { Utils::str_ltrim(arg, '-'); Utils::str_ltrim(arg, '/'); @@ -102,7 +140,7 @@ namespace Utils //{ // m_mapArguments[arg] = "true"; //} - } + } } } } diff --git a/Utils/CommandLineArgs.h b/Utils/CommandLineArgs.h index ed9b1e81..3b49c243 100644 --- a/Utils/CommandLineArgs.h +++ b/Utils/CommandLineArgs.h @@ -5,6 +5,7 @@ #include "utils_export.h" #include #include +#include namespace Utils @@ -15,10 +16,14 @@ namespace Utils CommandLineArgs(int argc, char* argv[]); CommandLineArgs(const std::vector& vecArgv); - bool boolArg(const std::string& name) const; - std::string stringArg(const std::string& name) const; - int intArg(const std::string& name) const; - double doubleArg(const std::string& name) const; + bool boolArg(const std::string& name, bool default) const; + std::string stringArg(const std::string& name, const std::string& default) const; + int intArg(const std::string& name, int default) const; + double doubleArg(const std::string& name, double default) const; + + std::string executable() const; + std::filesystem::path executableDirectory() const; + std::filesystem::path executableName() const; protected: std::vector m_vecArguments; @@ -27,6 +32,8 @@ namespace Utils std::string getArgValue(const std::string& name) const; void parse(); + + const char* EXECUTABLE_ARG_NAME = "executable"; }; } From 7dc6e566d2b5c542a098108b8ebfeba53b5dde03 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 18:10:39 -0700 Subject: [PATCH 12/17] use command line arguments to set crow server's settings and wrap ssl_file() call in try/catch, provide logging message if it fails --- OdbDesignLib/OdbServerAppBase.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/OdbDesignLib/OdbServerAppBase.cpp b/OdbDesignLib/OdbServerAppBase.cpp index ca671d2a..aac6fcf1 100644 --- a/OdbDesignLib/OdbServerAppBase.cpp +++ b/OdbDesignLib/OdbServerAppBase.cpp @@ -1,4 +1,5 @@ #include "OdbServerAppBase.h" +#include using namespace Utils; @@ -25,8 +26,21 @@ namespace Odb::Lib // enable HTTP compression m_crowApp.use_compression(crow::compression::algorithm::GZIP); - // enable SSL/HTTPS - m_crowApp.ssl_file("ssl/localhost.crt", "ssl/localhost.key"); + try + { + if (args().useHttps()) + { + // enable SSL/HTTPS + m_crowApp.ssl_file("ssl/localhost.crt", "ssl/localhost.key"); + } + } + catch (boost::wrapexcept& e) + { + // log the error + logexception(e.what()); + logerror("SSL was specified but it failed to initialize, exiting..."); + return ExitCode::FailedInitSsl; + } // let subclasses add controller types add_controllers(); @@ -34,8 +48,14 @@ namespace Odb::Lib // register all added controllers' routes register_routes(); + // set port to passed-in port or default if none supplied + m_crowApp.port(static_cast(args().port())); + + // set server to use multiple threads + m_crowApp.multithreaded(); + // run the Crow server - m_crowApp.port(18080).multithreaded().run(); + m_crowApp.run(); // success! return ExitCode::Success; From 3f37e103c212fa4093c01a85971276eed19e6ba9 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 18:11:06 -0700 Subject: [PATCH 13/17] set defaults for all argument get()ers --- OdbDesignLib/OdbDesignArgs.cpp | 8 ++++---- OdbDesignLib/OdbDesignArgs.h | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/OdbDesignLib/OdbDesignArgs.cpp b/OdbDesignLib/OdbDesignArgs.cpp index 954b77f2..9133f1ae 100644 --- a/OdbDesignLib/OdbDesignArgs.cpp +++ b/OdbDesignLib/OdbDesignArgs.cpp @@ -9,21 +9,21 @@ namespace Odb::Lib int OdbDesignArgs::port() const { - return boolArg("port"); + return intArg("port", DEFAULT_PORT); } bool OdbDesignArgs::useHttps() const { - return boolArg("use-https"); + return boolArg("use-https", DEFAULT_USE_HTTPS); } std::string OdbDesignArgs::designsDir() const { - return stringArg("designs-dir"); + return stringArg("designs-dir", DEFAULT_DESIGNS_DIR); } std::string OdbDesignArgs::templatesDir() const { - return stringArg("templates-dir"); + return stringArg("templates-dir", DEFAULT_TEMPLATES_DIR); } } diff --git a/OdbDesignLib/OdbDesignArgs.h b/OdbDesignLib/OdbDesignArgs.h index 4a20dba1..80d097b7 100644 --- a/OdbDesignLib/OdbDesignArgs.h +++ b/OdbDesignLib/OdbDesignArgs.h @@ -15,9 +15,10 @@ namespace Odb::Lib std::string designsDir() const; std::string templatesDir() const; - // port - // use HTTPS - // designs dir - // templates dir + const int DEFAULT_PORT = 8888; + const bool DEFAULT_USE_HTTPS = false; + const std::string DEFAULT_DESIGNS_DIR = "designs"; + const std::string DEFAULT_TEMPLATES_DIR = "templates"; + }; } From 8d2dc3c87606c14d411c0a12dc03db5afd2e2f38 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 18:21:09 -0700 Subject: [PATCH 14/17] fix name in docker copy --- Dockerfile_OdbDesignServer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile_OdbDesignServer b/Dockerfile_OdbDesignServer index 61c16523..c4fb6449 100644 --- a/Dockerfile_OdbDesignServer +++ b/Dockerfile_OdbDesignServer @@ -57,7 +57,7 @@ COPY --from=build /src/OdbDesign/out/build/linux-release/OdbDesignLib/*.so . COPY --from=build /src/OdbDesign/out/build/linux-release/Utils/*.so . COPY --from=build /src/OdbDesign/out/build/linux-release/OdbDesignServer/OdbDesignServer . COPY --from=build /src/OdbDesign/out/build/linux-release/OdbDesignServer/*.so . -COPY --from=build /src/OdbDesign/out/build/linux-release/OdbDesignTest/OdbDesignTest . +COPY --from=build /src/OdbDesign/out/build/linux-release/OdbDesignTests/OdbDesignTests . # copy designs and templates directories #COPY --from=build /src/OdbDesign/OdbDesignServer/designs ./designs #COPY --from=build /src/OdbDesign/OdbDesignServer/templates ./templates From 9684cd04761125692cdbbe5e79e31409bd193910 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 19:14:23 -0700 Subject: [PATCH 15/17] add problem matchers --- .github/workflows/cmake-multi-platform.yml | 10 +++++++++- .github/workflows/docker-build.yml | 5 +++++ .github/workflows/docker-publish.yml | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 8cfc8e6a..8235ddf2 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -45,7 +45,15 @@ jobs: steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 + + # add problem matchers by compiler + - name: Add Problem Matchers + uses: ammaraskar/msvc-problem-matcher@master + if: matrix.os == 'windows-2022' + - name: Add Problem Matchers + uses: ammaraskar/gcc-problem-matcher@master + if: matrix.os != 'windows-2022' - name: Install vcpkg Dependencies run: | diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 4b63fffe..b0a691ea 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -14,5 +14,10 @@ jobs: steps: - uses: actions/checkout@v3 + + # add problem matchers + - name: Add Problem Matchers + uses: ammaraskar/gcc-problem-matcher@master + - name: Build the Docker image run: docker build . --file Dockerfile_OdbDesignServer --tag odbdesign:${{github.ref_name}}-${{github.run_number}} diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 5fcfd5ed..c508087e 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -33,6 +33,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + # add problem matchers + - name: Add Problem Matchers + uses: ammaraskar/gcc-problem-matcher@master + # Install the cosign tool except on PR # https://github.com/sigstore/cosign-installer - name: Install cosign From 9995f3a499e9c1a88c48b24c0f97ff281a0045e4 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 19:19:02 -0700 Subject: [PATCH 16/17] add unique job-id names --- .github/workflows/cmake-multi-platform.yml | 1 + .github/workflows/codeql.yml | 2 +- .github/workflows/docker-build.yml | 1 + .github/workflows/docker-publish.yml | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 8235ddf2..1c2db0ba 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -19,6 +19,7 @@ env: jobs: build: + name: CMake-Multi-Platform-Build runs-on: ${{ matrix.os }} strategy: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 355213eb..47b04ea1 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -23,7 +23,7 @@ env: jobs: analyze: - name: Analyze + name: CodeQL-Security-Scan runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} permissions: diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index b0a691ea..eb999510 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -9,6 +9,7 @@ on: jobs: build: + name: Docker-Build runs-on: ubuntu-latest diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index c508087e..16528a95 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -20,6 +20,7 @@ env: jobs: build: + name: Docker-Build-and-Publish runs-on: ubuntu-latest permissions: From 39aa92b27e14e0daf97be87e2cd7d9a9b4c6ed71 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Thu, 19 Oct 2023 19:59:35 -0700 Subject: [PATCH 17/17] fix use of default as not a keyword --- Utils/CommandLineArgs.cpp | 16 ++++++++-------- Utils/CommandLineArgs.h | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Utils/CommandLineArgs.cpp b/Utils/CommandLineArgs.cpp index e3bde128..6fbdaebe 100644 --- a/Utils/CommandLineArgs.cpp +++ b/Utils/CommandLineArgs.cpp @@ -30,7 +30,7 @@ namespace Utils parse(); } - bool CommandLineArgs::boolArg(const std::string& name, bool default) const + bool CommandLineArgs::boolArg(const std::string& name, bool defaultValue) const { auto strB = getArgValue(name); if (strB.length() > 0) @@ -40,37 +40,37 @@ namespace Utils return b; } - return default; + return defaultValue; } - std::string CommandLineArgs::stringArg(const std::string& name, const std::string& default) const + std::string CommandLineArgs::stringArg(const std::string& name, const std::string& defaultValue) const { auto str = getArgValue(name); if (str.length() > 0) { return str; } - return default; + return defaultValue; } - int CommandLineArgs::intArg(const std::string& name, int default) const + int CommandLineArgs::intArg(const std::string& name, int defaultValue) const { auto strI = getArgValue(name); if (strI.length() > 0) { return std::stoi(strI); } - return default; + return defaultValue; } - double CommandLineArgs::doubleArg(const std::string& name, double default) const + double CommandLineArgs::doubleArg(const std::string& name, double defaultValue) const { auto strD = getArgValue(name); if (strD.length() > 0) { return std::stod(strD); } - return default; + return defaultValue; } std::string CommandLineArgs::executable() const diff --git a/Utils/CommandLineArgs.h b/Utils/CommandLineArgs.h index 3b49c243..74a824ac 100644 --- a/Utils/CommandLineArgs.h +++ b/Utils/CommandLineArgs.h @@ -16,10 +16,10 @@ namespace Utils CommandLineArgs(int argc, char* argv[]); CommandLineArgs(const std::vector& vecArgv); - bool boolArg(const std::string& name, bool default) const; - std::string stringArg(const std::string& name, const std::string& default) const; - int intArg(const std::string& name, int default) const; - double doubleArg(const std::string& name, double default) const; + bool boolArg(const std::string& name, bool defaultValue) const; + std::string stringArg(const std::string& name, const std::string& defaultValue) const; + int intArg(const std::string& name, int defaultValue) const; + double doubleArg(const std::string& name, double defaultValue) const; std::string executable() const; std::filesystem::path executableDirectory() const;