Skip to content

Commit

Permalink
Merge pull request #1 from camargo2019/fix/add-pr-templete-and-actions
Browse files Browse the repository at this point in the history
💚 fix: add pr template and github actions
  • Loading branch information
camargo2019 authored Sep 9, 2024
2 parents 079ed2a + bbe4968 commit eebaa66
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 13 deletions.
39 changes: 39 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
### Descrição

Por favor, inclua uma descrição detalhada das alterações feitas neste Pull Request. Certifique-se de mencionar a motivação por trás das mudanças e os problemas que foram resolvidos.

- **Tipo de mudança**: (Correção de bug, nova funcionalidade, melhoria, etc.)
- **Problema relacionado**: (Se aplicável, inclua o link ou número da issue relacionada)

### Alterações principais

Liste as principais mudanças que foram feitas:

- [ ] ...
- [ ] ...

### Testes realizados

Descreva os testes que você realizou para verificar as suas mudanças. Inclua instruções detalhadas sobre como os revisores podem testar as alterações:

- [ ] Teste 1: Instrução de como testar
- [ ] Teste 2: Instrução de como testar

### Checklist

Antes de enviar o Pull Request, certifique-se de que você completou as seguintes tarefas:

- [ ] O código segue o padrão de estilo do projeto.
- [ ] Todos os testes novos e existentes passaram.
- [ ] A documentação foi atualizada (se aplicável).
- [ ] Adicionei testes que cobrem as alterações realizadas.

### Problemas conhecidos (se aplicável)

Liste qualquer limitação ou problema que ainda não foi resolvido, se aplicável:

- [ ] ...

### Comentários adicionais

Adicione qualquer informação ou contexto adicional que possa ajudar na revisão.
29 changes: 29 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Run Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
tests:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: sudo apt-get install -y libboost-all-dev

- name: Set up Clang
run: |
sudo apt-get update
sudo apt-get install -y clang
- name: Build
run: |
clang++ -o cmr_cache main.cpp -I./vendor/yaml -I/usr/local/include/boost -L/usr/local/lib -lboost_system -lpthread -Wmissing-declarations
2 changes: 0 additions & 2 deletions core/cache/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ bool Cache::set(std::string db, std::string key, std::string value, int expire){
data.expire = expire;

cache_[db][key] = data;
save();

return true;
}
Expand All @@ -83,7 +82,6 @@ bool Cache::del(std::string db, std::string key){
if (cache_.find(db) != cache_.end()) {
if (cache_[db].find(key) != cache_[db].end()){
cache_[db].erase(key);
save();

return true;
}
Expand Down
10 changes: 5 additions & 5 deletions core/entities/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@

Yaml::Node& connect = root["connect"];
if (connect.IsMap() == false){
throw std::exception("ERROR: We can't find connect in config/connect.yaml");
throw std::runtime_error("ERROR: We can't find connect in config/connect.yaml");
}

config_connect.max_clients = connect["max-clients"].As<int>();

Yaml::Node& auth = connect["auth"];
if (auth.IsMap() == false){
throw std::exception("ERROR: We can't find auth in config/connect.yaml");
throw std::runtime_error("ERROR: We can't find auth in config/connect.yaml");
}

Yaml::Node& authIPs = auth["allow-ip"];

if (authIPs.IsSequence() == false){
throw std::exception("ERROR: allow-ip is not a sequence in config/connect.yaml");
throw std::runtime_error("ERROR: allow-ip is not a sequence in config/connect.yaml");
}

for (auto aIP = authIPs.Begin(); aIP != authIPs.End(); aIP++){
Expand All @@ -81,7 +81,7 @@
Yaml::Node& basicAuth = auth["basic"];

if (basicAuth.IsSequence() == false){
throw std::exception("ERROR: basic-auth is not a sequence in config/connect.yaml");
throw std::runtime_error("ERROR: basic-auth is not a sequence in config/connect.yaml");
}

for (auto bAuth = basicAuth.Begin(); bAuth != basicAuth.End(); bAuth++){
Expand All @@ -104,7 +104,7 @@

Yaml::Node& rootHost = root["host"];
if (rootHost.IsMap() == false){
throw std::exception("ERROR: We can't find the host in config/host.yaml");
throw std::runtime_error("ERROR: We can't find the host in config/host.yaml");
}

host.address = rootHost["address"].As<std::string>();
Expand Down
2 changes: 1 addition & 1 deletion core/manager/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void Manager::invokeSet(std::vector<std::string> args){
try {
expire = std::stoi(args[2]);
}catch (std::exception& e){
std::cout << "Failed: " << args[0] << " " << args[1] << " " << args[2] << " | " << e.what() << std::endl;
std::cout << "Failed: " << e.what() << std::endl;
}
}

Expand Down
4 changes: 0 additions & 4 deletions core/socket/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ CoreSocket::CoreSocket(boost::asio::io_context& io_context, std::string ip, shor
accept();
}

void CoreSocket::removeClient(){
--client_;
}

void CoreSocket::accept() {
acceptor_.async_accept(
[this](boost::system::error_code ec, boost::asio::ip::tcp::socket socket) {
Expand Down
1 change: 0 additions & 1 deletion core/socket/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
class CoreSocket: public std::enable_shared_from_this<CoreSocket> {
public:
CoreSocket(boost::asio::io_context& io_context, std::string, short port, Cache& cache_);
void removeClient();

private:
void accept();
Expand Down

0 comments on commit eebaa66

Please sign in to comment.