Skip to content

Commit 2680cef

Browse files
committed
debian trixie build
1 parent 81d745b commit 2680cef

File tree

14 files changed

+187
-73
lines changed

14 files changed

+187
-73
lines changed

.github/workflows/ci.yml

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ jobs:
1313
##### coverage #####
1414
coverage:
1515
runs-on: ubuntu-latest
16-
container: debian:bookworm
16+
container: debian:trixie
1717
name: coverage - measure
1818
env:
1919
linux_distro: debian
20-
linux_release: bookworm
20+
linux_release: trixie
2121
steps:
2222
- name: add cppfw deb repo
2323
uses: myci-actions/add-deb-repo@main
@@ -26,12 +26,12 @@ jobs:
2626
repo-name: cppfw
2727
keys-asc: https://gagis.hopto.org/repo/cppfw/pubkey.gpg
2828
install: myci locales git pipx
29-
- name: add llvm repo (for clang-format)
30-
uses: myci-actions/add-deb-repo@main
31-
with:
32-
repo: deb http://apt.llvm.org/${{ env.linux_release }} llvm-toolchain-${{ env.linux_release }} main
33-
repo-name: llvm
34-
keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
29+
# - name: add llvm repo (for clang-format)
30+
# uses: myci-actions/add-deb-repo@main
31+
# with:
32+
# repo: deb http://apt.llvm.org/${{ env.linux_release }} llvm-toolchain-${{ env.linux_release }} main
33+
# repo-name: llvm
34+
# keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
3535
- name: git clone
3636
uses: myci-actions/checkout@main
3737
- name: prepare debian package
@@ -84,9 +84,9 @@ jobs:
8484
fail-fast: false
8585
matrix:
8686
include:
87-
- {os: debian, codename: bookworm, image_owner: }
88-
- {os: debian, codename: bookworm, image_owner: arm32v7/, labels: [ubuntu-24.04-arm]}
89-
- {os: debian, codename: bookworm, image_owner: arm64v8/, labels: [ubuntu-24.04-arm]}
87+
- {os: debian, codename: trixie, image_owner: }
88+
- {os: debian, codename: trixie, image_owner: arm32v7/, labels: [ubuntu-24.04-arm]}
89+
- {os: debian, codename: trixie, image_owner: arm64v8/, labels: [ubuntu-24.04-arm]}
9090
runs-on: ${{ (matrix.labels == '' && 'ubuntu-latest') || matrix.labels }}
9191
container: ${{ matrix.image_owner }}${{ matrix.os }}:${{ matrix.codename }}
9292
name: sanitizer - ${{ matrix.image_owner }}${{ matrix.os }}:${{ matrix.codename }}
@@ -98,12 +98,12 @@ jobs:
9898
repo-name: cppfw
9999
keys-asc: https://gagis.hopto.org/repo/cppfw/pubkey.gpg
100100
install: myci git
101-
- name: add llvm repo (for clang-format)
102-
uses: myci-actions/add-deb-repo@main
103-
with:
104-
repo: deb http://apt.llvm.org/${{ matrix.codename }} llvm-toolchain-${{ matrix.codename }} main
105-
repo-name: llvm
106-
keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
101+
# - name: add llvm repo (for clang-format)
102+
# uses: myci-actions/add-deb-repo@main
103+
# with:
104+
# repo: deb http://apt.llvm.org/${{ matrix.codename }} llvm-toolchain-${{ matrix.codename }} main
105+
# repo-name: llvm
106+
# keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
107107
- name: install ci tools
108108
run: |
109109
apt install --assume-yes devscripts equivs
@@ -117,6 +117,32 @@ jobs:
117117
run: make config=asan
118118
- name: test
119119
run: make config=asan test
120+
##### lint #####
121+
lint:
122+
runs-on: ubuntu-latest
123+
container: debian:trixie
124+
name: lint
125+
env:
126+
linux_distro: debian
127+
linux_release: trixie
128+
steps:
129+
- name: add cppfw deb repo
130+
uses: myci-actions/add-deb-repo@main
131+
with:
132+
repo: deb https://gagis.hopto.org/repo/cppfw/${{ env.linux_distro }} ${{ env.linux_release }} main
133+
repo-name: cppfw
134+
keys-asc: https://gagis.hopto.org/repo/cppfw/pubkey.gpg
135+
install: myci locales git devscripts equivs
136+
- name: git clone
137+
uses: myci-actions/checkout@main
138+
- name: prepare debian package
139+
run: myci-deb-prepare.sh
140+
- name: install deps
141+
run: myci-deb-install-build-deps.sh
142+
- name: build
143+
run: make config=lint
144+
- name: test
145+
run: make config=lint test
120146
##### deb linux #####
121147
deb_linux:
122148
strategy:
@@ -134,6 +160,10 @@ jobs:
134160
# - {os: debian, codename: bookworm, image_owner: i386/, package_type: deb, labels: [i386,docker]}
135161
- {os: debian, codename: bookworm, image_owner: arm32v7/, package_type: deb, labels: [ubuntu-24.04-arm]}
136162
- {os: debian, codename: bookworm, image_owner: arm64v8/, package_type: deb, labels: [ubuntu-24.04-arm]}
163+
- {os: debian, codename: trixie, image_owner: , package_type: deb}
164+
# - {os: debian, codename: trixie, image_owner: i386/, package_type: deb, labels: [i386,docker]}
165+
- {os: debian, codename: trixie, image_owner: arm32v7/, package_type: deb, labels: [ubuntu-24.04-arm]}
166+
- {os: debian, codename: trixie, image_owner: arm64v8/, package_type: deb, labels: [ubuntu-24.04-arm]}
137167
# - {os: ubuntu, codename: focal, image_owner: , package_type: deb}
138168
# - {os: ubuntu, codename: jammy, image_owner: , package_type: deb}
139169
- {os: ubuntu, codename: noble, image_owner: , package_type: deb}

.vscode/tasks.json

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
{
77
"label": "build",
88
"type": "shell",
9-
"command": "make autojobs=true",
9+
"command": "make",
1010
"problemMatcher": [
1111
"$gcc"
1212
],
1313
"group": "build"
1414
},
1515
{
16-
"label": "build_dbg",
16+
"label": "build-dev",
1717
"type": "shell",
18-
"command": "make config=dbg autojobs=true",
18+
"command": "make config=dev",
1919
"problemMatcher": [
2020
"$gcc"
2121
],
@@ -31,16 +31,30 @@
3131
{
3232
"label": "test_",
3333
"type": "shell",
34-
"command": "make test autojobs=true",
34+
"command": "make test",
3535
"dependsOn": "build",
3636
"problemMatcher": [],
3737
"group": "build"
3838
},
3939
{
40-
"label": "test_dbg",
40+
"label": "test-dev",
4141
"type": "shell",
42-
"command": "make test config=dbg autojobs=true",
43-
"dependsOn": "build_dbg",
42+
"command": "make test config=dev",
43+
"dependsOn": "build-dev",
44+
"problemMatcher": [],
45+
"group": "build"
46+
},
47+
{
48+
"label": "format",
49+
"type": "shell",
50+
"command": "make format",
51+
"problemMatcher": [],
52+
"group": "build"
53+
},
54+
{
55+
"label": "lint",
56+
"type": "shell",
57+
"command": "make config=lint && make config=lint test",
4458
"problemMatcher": [],
4559
"group": "build"
4660
}

build/debian/control.in

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@ Source: libhttpclient
22
Section: libs
33
Priority: extra
44
Maintainer: Ivan Gagis <igagis@gmail.com>
5-
Build-Depends: debhelper (>= 9), prorab, prorab-extra, myci, pkg-config,
6-
libc6-dev,
7-
libssl-dev,
8-
zlib1g-dev,
9-
libutki-dev,
10-
libnitki-dev,
11-
libtst-dev,
12-
libhttpmodel-dev,
13-
libcurl4-openssl-dev,
14-
clang-tidy,
15-
clang-format
5+
Build-Depends:
6+
debhelper (>= 9),
7+
prorab,
8+
prorab-extra,
9+
myci,
10+
pkg-config,
11+
libc6-dev,
12+
libssl-dev,
13+
zlib1g-dev,
14+
libutki-dev,
15+
libnitki-dev,
16+
libtst-dev,
17+
libhttpmodel-dev,
18+
libcurl4-openssl-dev,
19+
clang-tidy,
20+
clang-format
1621
Build-Depends-Indep: doxygen
1722
Standards-Version: 3.9.2
1823

config/base/base.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ this_cxxflags += -g
1010

1111
this_ldlibs += -lstdc++
1212

13+
this_no_format_test := true
14+
1315
ifeq ($(gprof), true)
1416
this_cxxflags += -pg
1517
this_ldflags += -pg

config/lint.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include $(config_dir)dev.mk
2+
3+
this_lint_cmd = $(prorab_lint_cmd_clang_tidy)
4+
this_no_format_test := false

src/httpclient/init_guard.cpp

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ using namespace httpclient;
3737

3838
decltype(init_guard::instance) init_guard::instance;
3939

40+
// TODO: refactor to avoid non-const globals, perhaps make them static vars of some class
4041
namespace {
41-
std::thread thread;
42-
std::atomic_bool quit_flag;
43-
nitki::queue queue;
44-
CURLM* multi_handle = nullptr;
45-
std::map<CURL*, std::shared_ptr<request>> handle_to_request_map;
42+
std::thread thread; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
43+
std::atomic_bool quit_flag; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
44+
nitki::queue queue; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
45+
CURLM* multi_handle = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
46+
std::map<CURL*, std::shared_ptr<request>>
47+
handle_to_request_map; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
4648
} // namespace
4749

4850
namespace {
@@ -60,9 +62,10 @@ status_code curlcode_to_status(CURLcode code)
6062
}
6163
} // namespace
6264

63-
void init_guard::handle_completed_request(const void* CURLMsg_message)
65+
void init_guard::handle_completed_request(const void* curlmsg_message)
6466
{
65-
const CURLMsg& m = *reinterpret_cast<const CURLMsg*>(CURLMsg_message);
67+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast, "type erasure")
68+
const CURLMsg& m = *reinterpret_cast<const CURLMsg*>(curlmsg_message);
6669
switch (m.msg) {
6770
case CURLMSG_DONE:
6871
{
@@ -74,12 +77,16 @@ void init_guard::handle_completed_request(const void* CURLMsg_message)
7477
handle_to_request_map.erase(i);
7578
r->is_idle = true;
7679

77-
long response_code;
80+
long response_code{};
7881
curl_easy_getinfo(r->CURL_handle, CURLINFO_RESPONSE_CODE, &response_code);
7982
r->resp.status = httpmodel::status(response_code);
8083

8184
if (r->completed_handler) {
82-
r->completed_handler(curlcode_to_status(m.data.result), *r);
85+
r->completed_handler(
86+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-union-access, "use of third party library libcurl")
87+
curlcode_to_status(m.data.result), //
88+
*r
89+
);
8390
}
8491
break;
8592
}
@@ -98,27 +105,39 @@ void init_guard::thread_func()
98105
m();
99106
}
100107

101-
int num_active_sockets;
108+
int num_active_sockets{};
102109
curl_multi_perform(multi_handle, &num_active_sockets);
103110

104111
// handle completed requests
105-
CURLMsg* msg;
112+
CURLMsg* msg = nullptr;
113+
// NOLINTNEXTLINE(cppcoreguidelines-avoid-do-while, "TODO: refactor to avoid do{}while()")
106114
do {
107-
int num_messages_left;
115+
int num_messages_left{};
108116
msg = curl_multi_info_read(multi_handle, &num_messages_left);
109117
if (msg) {
110118
init_guard::handle_completed_request(msg);
111119
}
112120
} while (msg);
113121

114-
long timeout;
122+
long timeout{};
123+
124+
constexpr auto default_timeout_ms = 1000;
115125

116126
curl_multi_timeout(multi_handle, &timeout);
117127
if (timeout < 0) { // no set timeout, use default
118-
timeout = 1000;
128+
timeout = default_timeout_ms;
129+
} else {
130+
using std::min;
131+
timeout = min(timeout, decltype(timeout)(default_timeout_ms));
119132
}
120133

121-
CURLMcode rc = curl_multi_poll(multi_handle, nullptr, 0, timeout, nullptr);
134+
CURLMcode rc = curl_multi_poll(
135+
multi_handle, //
136+
nullptr,
137+
0,
138+
int(timeout),
139+
nullptr
140+
);
122141

123142
if (rc != CURLM_OK) {
124143
utki::log([](auto& o) {
@@ -147,7 +166,7 @@ bool init_guard::cancel_request(request& r)
147166
{
148167
// TRACE(<< "cancelling request..." << std::endl)
149168
nitki::semaphore sema;
150-
bool ret;
169+
bool ret = false;
151170
queue.push_back([&r, &sema, &ret]() {
152171
auto i = handle_to_request_map.find(r.CURL_handle);
153172
if (i == handle_to_request_map.end()) {
@@ -182,7 +201,7 @@ init_guard::init_guard(bool init_winsock)
182201
thread = std::thread(&thread_func);
183202
}
184203

185-
init_guard::~init_guard() noexcept
204+
init_guard::~init_guard()
186205
{
187206
quit_flag.store(true);
188207
ASSERT(multi_handle)

src/httpclient/init_guard.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,18 @@ class init_guard : public utki::intrusive_singleton<init_guard>
4343
bool cancel_request(request& r);
4444

4545
static void thread_func();
46-
static void handle_completed_request(const void* CURLMsg_message);
46+
static void handle_completed_request(const void* curlmsg_message);
4747

4848
public:
4949
init_guard(bool init_winsock = true);
50-
~init_guard() noexcept;
50+
51+
init_guard(const init_guard&) = delete;
52+
init_guard& operator=(const init_guard&) = delete;
53+
54+
init_guard(init_guard&&) = delete;
55+
init_guard& operator=(init_guard&&) = delete;
56+
57+
~init_guard() override;
5158
};
5259

5360
} // namespace httpclient

0 commit comments

Comments
 (0)