Added CI script, updated dependencies, and fixed bugs

-Added CI yaml file for workflows
-Added `doctest` as dependency
-Added test target executable to CMakeLists.txt
-Renamed `bin` scripts to remove `gdpm*` prefix
-Updated `SQLite 3` dependency in CMakeLists.txt
-Implement basic unit testing in `tests/basic.cpp`
-Fixed issue with handling `fmt` strings
This commit is contained in:
David Allen 2023-01-04 20:49:00 -06:00
parent e36f0aee79
commit e048a762b2
22 changed files with 169 additions and 38 deletions

View file

@ -1,4 +1,6 @@
#pragma once
#include "constants.hpp"
#include <sqlite3.h>
#include <vector>

View file

@ -1,6 +1,7 @@
#pragma once
#include "constants.hpp"
#include "error.hpp"
#include <string>
#include <filesystem>
@ -9,7 +10,7 @@
namespace gdpm::config{
struct config_context{
struct context{
std::string username;
std::string password;
std::string path;
@ -24,10 +25,11 @@ namespace gdpm::config{
bool enable_file_logging;
int verbose;
};
std::string to_json(const config_context& params);
config_context load(std::filesystem::path path, int verbose = 0);
int save(const config_context& config, int verbose = 0);
config_context make_context(const std::string& username = GDPM_CONFIG_USERNAME, const std::string& password = GDPM_CONFIG_PASSWORD, const std::string& path = GDPM_CONFIG_PATH, const std::string& token = GDPM_CONFIG_TOKEN, const std::string& godot_version = GDPM_CONFIG_GODOT_VERSION, const std::string& packages_dir = GDPM_CONFIG_LOCAL_PACKAGES_DIR, const std::string& tmp_dir = GDPM_CONFIG_LOCAL_TMP_DIR, const std::set<std::string>& remote_sources = {GDPM_CONFIG_REMOTE_SOURCES}, size_t threads = GDPM_CONFIG_THREADS, size_t timeout = 0, bool enable_sync = GDPM_CONFIG_ENABLE_SYNC, bool enable_file_logging = GDPM_CONFIG_ENABLE_FILE_LOGGING, int verbose = GDPM_CONFIG_VERBOSE);
std::string to_json(const context& params);
context load(std::filesystem::path path, int verbose = 0);
gdpm::error load(std::filesystem:: path, context& config, int verbose = 0);
gdpm::error save(std::filesystem::path path, const context& config, int verbose = 0);
context make_context(const std::string& username = GDPM_CONFIG_USERNAME, const std::string& password = GDPM_CONFIG_PASSWORD, const std::string& path = GDPM_CONFIG_PATH, const std::string& token = GDPM_CONFIG_TOKEN, const std::string& godot_version = GDPM_CONFIG_GODOT_VERSION, const std::string& packages_dir = GDPM_CONFIG_LOCAL_PACKAGES_DIR, const std::string& tmp_dir = GDPM_CONFIG_LOCAL_TMP_DIR, const std::set<std::string>& remote_sources = {GDPM_CONFIG_REMOTE_SOURCES}, size_t threads = GDPM_CONFIG_THREADS, size_t timeout = 0, bool enable_sync = GDPM_CONFIG_ENABLE_SYNC, bool enable_file_logging = GDPM_CONFIG_ENABLE_FILE_LOGGING, int verbose = GDPM_CONFIG_VERBOSE);
extern config_context config;
extern context config;
}

View file

@ -6,6 +6,7 @@
namespace gdpm::constants{
const std::string HomePath(std::string(std::getenv("HOME")) + "/");
const std::string TestPath(HomePath + ".config/gdpm/tests")
const std::string ConfigPath(HomePath + ".config/gdpm/config.json");
const std::string LockfilePath(HomePath + ".config/gdpm/gdpm.lck");
const std::string LocalPackagesDir(HomePath + ".config/gdpm/packages");

16
include/error.hpp Normal file
View file

@ -0,0 +1,16 @@
#include <string>
namespace gdpm{
class error{
public:
error(int code, const std::string& message):
m_code(code), m_message(message)
{}
private:
int m_code;
std::string m_message;
}
}

View file

@ -29,7 +29,8 @@ namespace gdpm::log
#if GDPM_LOG_LEVEL > 0
vlog(
fmt::format(GDPM_COLOR_LOG_INFO "[INFO {}] {}\n" GDPM_COLOR_LOG_RESET, utils::timestamp(), format),
fmt::make_args_checked<Args...>(format, args...)
// fmt::make_format_args<Args...>(args...)
fmt::make_format_args(args...)
);
#endif
}
@ -38,7 +39,8 @@ namespace gdpm::log
static constexpr void info_n(const S& format, Args&&...args){
vlog(
fmt::format(GDPM_COLOR_LOG_INFO "[INFO {}] {}" GDPM_COLOR_LOG_RESET, utils::timestamp(), format),
fmt::make_args_checked<Args...>(format, args...)
// fmt::make_format_args<Args...>(args...)
fmt::make_format_args(args...)
);
}
@ -47,7 +49,8 @@ namespace gdpm::log
#if GDPM_LOG_LEVEL > 1
vlog(
fmt::format(GDPM_COLOR_LOG_ERROR "[ERROR {}] {}\n" GDPM_COLOR_LOG_RESET, utils::timestamp(), format),
fmt::make_args_checked<Args...>(format, args...)
// fmt::make_format_args<Args...>(args...)
fmt::make_format_args(args...)
);
#endif
}
@ -57,7 +60,8 @@ namespace gdpm::log
#if GDPM_LOG_LEVEL > 1
vlog(
fmt::format(GDPM_COLOR_LOG_DEBUG "[DEBUG {}] {}\n" GDPM_COLOR_LOG_RESET, utils::timestamp(), format),
fmt::make_args_checked<Args...>(format, args...)
// fmt::make_format_args<Args...>(args...)
fmt::make_format_args(args...)
);
#endif
}
@ -66,7 +70,8 @@ namespace gdpm::log
static constexpr void print(const S& format, Args&&...args){
vlog(
fmt::format("{}", format),
fmt::make_args_checked<Args...>(format, args...)
// fmt::make_format_args<Args...>(args...)
fmt::make_format_args(args...)
);
}
@ -74,7 +79,8 @@ namespace gdpm::log
static constexpr void println(const S& format, Args&&...args){
vlog(
fmt::format("{}\n", format),
fmt::make_args_checked<Args...>(format, args...)
// fmt::make_format_args<Args...>(args...)
fmt::make_format_args(args...)
);
}

View file

@ -14,7 +14,7 @@ namespace gdpm::package_manager{
extern std::vector<std::string> repo_sources;
extern CURL *curl;
extern CURLcode res;
extern config::config_context config;
extern config::context config;
struct package_info{
size_t asset_id;