Skip to content

Commit 6450b0a

Browse files
committed
ci: update workflow
1 parent 5768615 commit 6450b0a

File tree

7 files changed

+62
-12
lines changed

7 files changed

+62
-12
lines changed

.clang-tidy

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,38 @@
1-
Checks: '-*,readability-identifier-naming'
1+
Checks:
2+
- '-*'
3+
- 'readability-identifier-naming'
4+
- 'cppcoreguidelines-special-member-functions'
5+
- 'google-explicit-constructor'
26

3-
# CamelCase classes, types, structs and enums
47
CheckOptions:
8+
# CamelCase classes, types, structs and enums
59
- key: readability-identifier-naming.ClassCase
610
value: CamelCase
11+
- key: readability-identifier-naming.TypedefCase
12+
value: CamelCase
713
- key: readability-identifier-naming.EnumCase
814
value: CamelCase
915
- key: readability-identifier-naming.StructCase
1016
value: CamelCase
1117

12-
# snake_case functions and variables
18+
# lower_case functions and variables
1319
- key: readability-identifier-naming.FunctionCase
1420
value: lower_case
1521
- key: readability-identifier-naming.VariableCase
1622
value: lower_case
1723

18-
# underscore suffix for private members (foo_)
24+
# Underscore suffix for private members (foo_)
1925
- key: readability-identifier-naming.PrivateMemberSuffix
2026
value: _
2127

22-
- key: readability-identifier-naming.MacroCase
23-
value: UPPER_CASE
28+
# camelBack constants with k prefix (kMaxConnections)
29+
- key: readability-identifier-naming.ConstantCase
30+
value: camelBack
31+
- key: readability-identifier-naming.ConstantPrefix
32+
value: k
33+
34+
# Rule of three / orthodox cannonical form
35+
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
36+
value: true
37+
- key: cppcoreguidelines-special-member-functions.AllowImplicitlyDeletedCopyOrMove
38+
value: true

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI pipeline
2+
3+
on:
4+
pull_request:
5+
branches: [main, dev]
6+
7+
jobs:
8+
ci:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
14+
- name: Install dependencies
15+
run: pipx install compiledb
16+
17+
- name: Run clang-format
18+
run: clang-format --dry-run --Werror *.cpp *.hpp
19+
20+
- name: Build and generate compilation database
21+
run: compiledb make
22+
23+
- name: Run clang-tidy
24+
run: clang-tidy --header-filter=.* --warnings-as-errors=* *.cpp

Client.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@
77

88
class Client {
99
public:
10-
Client(Socket* socket);
10+
explicit Client(Socket* socket);
1111
~Client();
1212

13+
private:
14+
Client();
15+
Client(const Client& other);
16+
Client& operator=(const Client& other);
17+
1318
private:
1419
Socket* socket_;
1520
};

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ db:
3434
compiledb -n $(MAKE)
3535

3636
format:
37-
clang-format --style=file --dry-run *.cpp *.hpp
37+
clang-format -style=file -dry-run *.cpp *.hpp
3838

3939
format-fix:
40-
clang-format --style=file -i *.cpp *.hpp
40+
clang-format -style=file -i *.cpp *.hpp
4141

4242
lint:
4343
clang-tidy -p=. -header-filter=.* *.cpp

Server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void Server::run()
5151
// poll for available connections
5252
// two solutions possible : wait returns n events -> either loop 0 to n in the epoll_event
5353
// array held by the epoll object or modify the wait function to return an array
54-
int n_events = epoll_wait(epoll_fd_, events_, MAX_EVENTS, -1);
54+
int n_events = epoll_wait(epoll_fd_, events_, WEBSERV_MAX_EVENTS, -1);
5555

5656
for (int i = 0; i < n_events; ++i) {
5757
int event_fd = events_[i].data.fd;

Server.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <map>
1616

17-
#define MAX_EVENTS 10
17+
#define WEBSERV_MAX_EVENTS 10
1818

1919
class Server {
2020
public:
@@ -29,11 +29,13 @@ class Server {
2929

3030
private:
3131
Server();
32+
Server(const Server& other);
33+
Server& operator=(const Server& other);
3234

3335
private:
3436
Socket socket_;
3537
int epoll_fd_;
36-
epoll_event events_[MAX_EVENTS];
38+
epoll_event events_[WEBSERV_MAX_EVENTS];
3739
std::map<int, Client*> clients_; // Map of clients connections
3840
};
3941

Socket.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class Socket {
2121

2222
int fd() const { return fd_; }
2323

24+
private:
25+
Socket(const Socket& other);
26+
Socket& operator=(const Socket& other);
27+
2428
private:
2529
int fd_;
2630
sockaddr_in addr_;

0 commit comments

Comments
 (0)