Skip to content

Commit e6f6c22

Browse files
LinZhihao-723kirkrodriguesjunhaoliaoHenry8192gibber9809
authored
Conventional commit (#15)
* ffi: Add support for serializing/deserializing auto-generated and user-generated schema tree node IDs. (y-scope#557) Co-authored-by: kirkrodrigues <[email protected]> * clp: Add missing C++ standard library includes in IR parsing files. (y-scope#561) Co-authored-by: kirkrodrigues <[email protected]> * log-viewer-webui: Update `yscope-log-viewer` to the latest version (which uses `clp-ffi-js`). (y-scope#562) * package: Upgrade dependencies to resolve security issues. (y-scope#536) * clp-s: Implement table packing (y-scope#466) Co-authored-by: wraymo <[email protected]> Co-authored-by: Kirk Rodrigues <[email protected]> Co-authored-by: wraymo <[email protected]> * log-viewer-webui: Update `yscope-log-viewer` to the latest version. (y-scope#565) * ci: Switch GitHub macOS build workflow to use macos-13 (x86) and macos-14 (ARM) runners. (y-scope#566) * core: Add support for user-defined HTTP headers in `NetworkReader`. (y-scope#568) Co-authored-by: Lin Zhihao <[email protected]> Co-authored-by: Xiaochong Wei <[email protected]> * chore: Update to the latest version of yscope-dev-utils. (y-scope#574) * build(core): Upgrade msgpack to v7.0.0. (y-scope#575) * feat(ffi): Update IR stream protocol version handling in preparation for releasing the kv-pair IR stream format: (y-scope#573) - Bump the IR stream protocol version to 0.1.0 for the kv-pair IR stream format. - Treat the previous IR stream format's versions as backwards compatible. - Differentiate between backwards-compatible and supported versions during validation. Co-authored-by: kirkrodrigues <[email protected]> * fix(taskfiles): Trim trailing slash from URL prefix in `download-and-extract-tar` (fixes y-scope#577). (y-scope#578) * fix(ffi): Correct `clp::ffi::ir_stream::Deserializer::deserialize_next_ir_unit`'s return value when failing to read the next IR unit's type tag. (y-scope#579) * fix(taskfiles): Update `yscope-log-viewer` sources in `log-viewer-webui-clients` sources list (fixes y-scope#576). (y-scope#580) * fix(cmake): Add Homebrew path detection for `mariadb-connector-c` to fix macOS build failure. (y-scope#582) Co-authored-by: kirkrodrigues <[email protected]> * refactor(ffi): Make `get_schema_subtree_bitmap` a public method of `KeyValuePairLogEvent`. (y-scope#581) * ci: Schedule GitHub workflows to daily run to detect failures due to upgraded dependencies or environments. (y-scope#583) * docs: Update the required version of task. (y-scope#567) * Add pr check workflow --------- Co-authored-by: kirkrodrigues <[email protected]> Co-authored-by: Junhao Liao <[email protected]> Co-authored-by: Henry8192 <[email protected]> Co-authored-by: Devin Gibson <[email protected]> Co-authored-by: wraymo <[email protected]> Co-authored-by: wraymo <[email protected]> Co-authored-by: Xiaochong(Eddy) Wei <[email protected]> Co-authored-by: Xiaochong Wei <[email protected]> Co-authored-by: haiqi96 <[email protected]>
1 parent de2cf07 commit e6f6c22

File tree

75 files changed

+5632
-3580
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+5632
-3580
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<!--
2-
Set the PR title to a meaningful commit message in imperative form. E.g.:
3-
4-
clp-s: Don't add implicit wildcards ('*') at the beginning and the end of a query (fixes #390).
2+
Set the PR title to a meaningful commit message that:
3+
- follows the Conventional Commits specification (https://www.conventionalcommits.org).
4+
- is in imperative form.
5+
Example:
6+
fix: Don't add implicit wildcards ('*') at the beginning and the end of a query (fixes #390).
57
-->
68

79
# Description

.github/workflows/clp-core-build-macos.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- "components/core/CMakeLists.txt"
99
- "components/core/src/**"
1010
- "components/core/tests/**"
11-
- "components/core/tools/scripts/lib_install/macos-12/**"
11+
- "components/core/tools/scripts/lib_install/macos/**"
1212
- "components/core/tools/scripts/deps-download/**"
1313
- "components/core/tools/scripts/utils/build-and-run-unit-tests.py"
1414
- "deps-tasks.yml"
@@ -21,12 +21,15 @@ on:
2121
- "components/core/CMakeLists.txt"
2222
- "components/core/src/**"
2323
- "components/core/tests/**"
24-
- "components/core/tools/scripts/lib_install/macos-12/**"
24+
- "components/core/tools/scripts/lib_install/macos/**"
2525
- "components/core/tools/scripts/deps-download/**"
2626
- "components/core/tools/scripts/utils/build-and-run-unit-tests.py"
2727
- "deps-tasks.yml"
2828
- "Taskfile.yml"
2929
- "tools/scripts/deps-download/**"
30+
schedule:
31+
# Run daily at 00:15 UTC (the 15 is to avoid periods of high load)
32+
- cron: "15 0 * * *"
3033
workflow_dispatch:
3134

3235
concurrency:
@@ -38,8 +41,9 @@ jobs:
3841
build-macos:
3942
strategy:
4043
matrix:
44+
runner: ["macos-13", "macos-14"]
4145
use_shared_libs: [true, false]
42-
runs-on: "macos-12"
46+
runs-on: "${{matrix.runner}}"
4347
steps:
4448
- uses: "actions/checkout@v4"
4549
with:
@@ -55,7 +59,7 @@ jobs:
5559
rm -f /usr/local/bin/python3*
5660
5761
- name: "Install dependencies"
58-
run: "./components/core/tools/scripts/lib_install/macos-12/install-all.sh"
62+
run: "./components/core/tools/scripts/lib_install/macos/install-all.sh"
5963

6064
- run: "./tools/scripts/deps-download/init.sh"
6165
shell: "bash"

.github/workflows/clp-core-build.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
- "deps-tasks.yml"
1212
- "Taskfile.yml"
1313
- "tools/scripts/deps-download/**"
14-
- "!components/core/tools/scripts/lib_install/macos-12/**"
14+
- "!components/core/tools/scripts/lib_install/macos/**"
1515
push:
1616
paths:
1717
- ".github/actions/clp-core-build/action.yaml"
@@ -22,7 +22,10 @@ on:
2222
- "deps-tasks.yml"
2323
- "Taskfile.yml"
2424
- "tools/scripts/deps-download/**"
25-
- "!components/core/tools/scripts/lib_install/macos-12/**"
25+
- "!components/core/tools/scripts/lib_install/macos/**"
26+
schedule:
27+
# Run daily at 00:15 UTC (the 15 is to avoid periods of high load)
28+
- cron: "15 0 * * *"
2629
workflow_dispatch:
2730

2831
env:

.github/workflows/clp-docs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: "clp-docs"
33
on:
44
pull_request:
55
push:
6+
schedule:
7+
# Run daily at 00:15 UTC (the 15 is to avoid periods of high load)
8+
- cron: "15 0 * * *"
69
workflow_dispatch:
710

811
concurrency:

.github/workflows/clp-execution-image-build.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
- ".github/actions/clp-execution-image-build/action.yaml"
1212
- ".github/workflows/clp-execution-image-build.yaml"
1313
- "tools/docker-images/**/*"
14+
schedule:
15+
# Run daily at 00:15 UTC (the 15 is to avoid periods of high load)
16+
- cron: "15 0 * * *"
1417
workflow_dispatch:
1518

1619
concurrency:

.github/workflows/clp-lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
pull_request:
55
push:
66
schedule:
7-
# Run at midnight UTC every day with 15 minutes delay added to avoid high load periods
7+
# Run daily at 00:15 UTC (the 15 is to avoid periods of high load)
88
- cron: "15 0 * * *"
99
workflow_dispatch:
1010

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: "clp-pr-title-checks"
2+
3+
on:
4+
pull_request_target:
5+
types: ["edited", "opened", "reopened"]
6+
branches: ["main"]
7+
8+
permissions:
9+
pull-requests: "read"
10+
11+
concurrency:
12+
group: "${{github.workflow}}-${{github.ref}}"
13+
14+
# Cancel in-progress jobs for efficiency
15+
cancel-in-progress: true
16+
17+
jobs:
18+
conventional-commits:
19+
runs-on: "ubuntu-latest"
20+
steps:
21+
- uses: "amannn/action-semantic-pull-request@v5"
22+
env:
23+
GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}"

Taskfile.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ tasks:
228228
- "client/src/**/*.css"
229229
- "client/src/**/*.jsx"
230230
- "client/src/webpack.config.js"
231-
- "yscope-log-viewer/.babelrc"
232-
- "yscope-log-viewer/customized-packages/**/*"
233231
- "yscope-log-viewer/package.json"
232+
- "yscope-log-viewer/public/**/*"
234233
- "yscope-log-viewer/src/**/*"
234+
- "yscope-log-viewer/tsconfig.json"
235235
- "yscope-log-viewer/webpack.common.js"
236236
- "yscope-log-viewer/webpack.prod.js"
237237
dir: "components/log-viewer-webui"
@@ -348,7 +348,7 @@ tasks:
348348
- "mkdir -p '{{.OUTPUT_TMP_DIR}}'"
349349
- >-
350350
curl --fail --location --show-error
351-
"{{.URL_PREFIX}}/{{.TAR_NAME}}"
351+
"{{trimSuffix "/" .URL_PREFIX}}/{{.TAR_NAME}}"
352352
--output "{{.TAR_PATH}}"
353353
- "tar xf '{{.TAR_PATH}}' --directory '{{.OUTPUT_TMP_DIR}}'"
354354
- "mv '{{.EXTRACTED_DIR}}' '{{.OUTPUT_DIR}}'"

components/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ else()
194194
endif()
195195

196196
# Find and setup msgpack
197-
find_package(msgpack-cxx 6.0.0 REQUIRED)
197+
find_package(msgpack-cxx 7.0.0 REQUIRED)
198198
if(msgpack-cxx_FOUND)
199199
message(STATUS "Found msgpack-cxx ${msgpack-cxx_VERSION}")
200200
else()

components/core/cmake/Modules/FindMariaDBClient.cmake

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,28 @@ include(cmake/Modules/FindLibraryDependencies.cmake)
2020
find_package(PkgConfig)
2121
pkg_check_modules(mariadbclient_PKGCONF QUIET "lib${mariadbclient_LIBNAME}")
2222

23+
if(NOT mariadbclient_PKGCONF_FOUND AND APPLE)
24+
execute_process(
25+
COMMAND brew --prefix mariadb-connector-c
26+
RESULT_VARIABLE mariadbclient_BREW_RESULT
27+
OUTPUT_VARIABLE mariadbclient_MACOS_PREFIX
28+
)
29+
if(NOT mariadbclient_BREW_RESULT EQUAL 0)
30+
message(
31+
FATAL_ERROR
32+
"pkg-config cannot find ${mariadbclient_LIBNAME} and mariadb-connector-c isn't"
33+
" installed via Homebrew"
34+
)
35+
endif()
36+
string(STRIP "${mariadbclient_MACOS_PREFIX}" mariadbclient_MACOS_PREFIX)
37+
list(PREPEND CMAKE_PREFIX_PATH ${mariadbclient_MACOS_PREFIX})
38+
pkg_check_modules(mariadbclient_PKGCONF QUIET "lib${mariadbclient_LIBNAME}")
39+
endif()
40+
41+
if(NOT mariadbclient_PKGCONF_FOUND)
42+
message(FATAL_ERROR "pkg-config cannot find ${mariadbclient_LIBNAME}")
43+
endif()
44+
2345
# Set include directory
2446
find_path(MariaDBClient_INCLUDE_DIR mysql.h
2547
HINTS ${mariadbclient_PKGCONF_INCLUDEDIR}

components/core/src/clp/CurlDownloadHandler.cpp

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
#include "CurlDownloadHandler.hpp"
22

3+
#include <algorithm>
4+
#include <array>
5+
#include <cctype>
36
#include <chrono>
47
#include <cstddef>
58
#include <memory>
9+
#include <optional>
610
#include <string>
711
#include <string_view>
12+
#include <unordered_map>
13+
#include <unordered_set>
814
#include <utility>
915

1016
#include <curl/curl.h>
17+
#include <fmt/core.h>
18+
19+
#include "ErrorCode.hpp"
1120

1221
namespace clp {
1322
CurlDownloadHandler::CurlDownloadHandler(
@@ -19,7 +28,8 @@ CurlDownloadHandler::CurlDownloadHandler(
1928
size_t offset,
2029
bool disable_caching,
2130
std::chrono::seconds connection_timeout,
22-
std::chrono::seconds overall_timeout
31+
std::chrono::seconds overall_timeout,
32+
std::optional<std::unordered_map<std::string, std::string>> const& http_header_kv_pairs
2333
)
2434
: m_error_msg_buf{std::move(error_msg_buf)} {
2535
if (nullptr != m_error_msg_buf) {
@@ -48,13 +58,55 @@ CurlDownloadHandler::CurlDownloadHandler(
4858
m_easy_handle.set_option(CURLOPT_TIMEOUT, static_cast<long>(overall_timeout.count()));
4959

5060
// Set up http headers
61+
constexpr std::string_view cRangeHeaderName{"range"};
62+
constexpr std::string_view cCacheControlHeaderName{"cache-control"};
63+
constexpr std::string_view cPragmaHeaderName{"pragma"};
64+
std::unordered_set<std::string_view> const reserved_headers{
65+
cRangeHeaderName,
66+
cCacheControlHeaderName,
67+
cPragmaHeaderName
68+
};
5169
if (0 != offset) {
52-
std::string const range{"Range: bytes=" + std::to_string(offset) + "-"};
53-
m_http_headers.append(range);
70+
m_http_headers.append(fmt::format("{}: bytes={}-", cRangeHeaderName, offset));
5471
}
5572
if (disable_caching) {
56-
m_http_headers.append("Cache-Control: no-cache");
57-
m_http_headers.append("Pragma: no-cache");
73+
m_http_headers.append(fmt::format("{}: no-cache", cCacheControlHeaderName));
74+
m_http_headers.append(fmt::format("{}: no-cache", cPragmaHeaderName));
75+
}
76+
if (http_header_kv_pairs.has_value()) {
77+
for (auto const& [key, value] : http_header_kv_pairs.value()) {
78+
// HTTP header field-name (key) is case-insensitive:
79+
// https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
80+
// Therefore, we convert keys to lowercase for comparison with the reserved keys.
81+
// NOTE: We do not check for duplicate keys due to case insensitivity, leaving duplicate
82+
// handling to the server.
83+
auto lower_key{key};
84+
std::transform(
85+
lower_key.begin(),
86+
lower_key.end(),
87+
lower_key.begin(),
88+
[](unsigned char c) -> char {
89+
// Implicitly cast the input character into `unsigned char` to avoid UB:
90+
// https://en.cppreference.com/w/cpp/string/byte/tolower
91+
return static_cast<char>(std::tolower(c));
92+
}
93+
);
94+
if (reserved_headers.contains(lower_key) || value.ends_with("\r\n")) {
95+
throw CurlOperationFailed(
96+
ErrorCode_Failure,
97+
__FILE__,
98+
__LINE__,
99+
CURLE_BAD_FUNCTION_ARGUMENT,
100+
fmt::format(
101+
"`CurlDownloadHandler` failed to construct with the following "
102+
"invalid header: {}:{}",
103+
key,
104+
value
105+
)
106+
);
107+
}
108+
m_http_headers.append(fmt::format("{}: {}", key, value));
109+
}
58110
}
59111
if (false == m_http_headers.is_empty()) {
60112
m_easy_handle.set_option(CURLOPT_HTTPHEADER, m_http_headers.get_raw_list());

components/core/src/clp/CurlDownloadHandler.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
#include <chrono>
66
#include <cstddef>
77
#include <memory>
8+
#include <optional>
9+
#include <string>
810
#include <string_view>
11+
#include <unordered_map>
912

1013
#include <curl/curl.h>
1114

@@ -53,6 +56,9 @@ class CurlDownloadHandler {
5356
* Doc: https://curl.se/libcurl/c/CURLOPT_CONNECTTIMEOUT.html
5457
* @param overall_timeout Maximum time that the transfer may take. Note that this includes
5558
* `connection_timeout`. Doc: https://curl.se/libcurl/c/CURLOPT_TIMEOUT.html
59+
* @param http_header_kv_pairs Key-value pairs representing HTTP headers to pass to the server
60+
* in the download request. Doc: https://curl.se/libcurl/c/CURLOPT_HTTPHEADER.html
61+
* @throw CurlOperationFailed if an error occurs.
5662
*/
5763
explicit CurlDownloadHandler(
5864
std::shared_ptr<ErrorMsgBuf> error_msg_buf,
@@ -63,7 +69,9 @@ class CurlDownloadHandler {
6369
size_t offset = 0,
6470
bool disable_caching = false,
6571
std::chrono::seconds connection_timeout = cDefaultConnectionTimeout,
66-
std::chrono::seconds overall_timeout = cDefaultOverallTimeout
72+
std::chrono::seconds overall_timeout = cDefaultOverallTimeout,
73+
std::optional<std::unordered_map<std::string, std::string>> const& http_header_kv_pairs
74+
= std::nullopt
6775
);
6876

6977
// Disable copy/move constructors/assignment operators

components/core/src/clp/NetworkReader.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
#include <memory>
77
#include <mutex>
88
#include <optional>
9+
#include <string>
910
#include <string_view>
11+
#include <unordered_map>
12+
#include <utility>
1013

1114
#include <curl/curl.h>
1215

@@ -118,7 +121,8 @@ NetworkReader::NetworkReader(
118121
std::chrono::seconds overall_timeout,
119122
std::chrono::seconds connection_timeout,
120123
size_t buffer_pool_size,
121-
size_t buffer_size
124+
size_t buffer_size,
125+
std::optional<std::unordered_map<std::string, std::string>> http_header_kv_pairs
122126
)
123127
: m_src_url{src_url},
124128
m_offset{offset},
@@ -130,7 +134,12 @@ NetworkReader::NetworkReader(
130134
for (size_t i = 0; i < m_buffer_pool_size; ++i) {
131135
m_buffer_pool.emplace_back(m_buffer_size);
132136
}
133-
m_downloader_thread = std::make_unique<DownloaderThread>(*this, offset, disable_caching);
137+
m_downloader_thread = std::make_unique<DownloaderThread>(
138+
*this,
139+
offset,
140+
disable_caching,
141+
std::move(http_header_kv_pairs)
142+
);
134143
m_downloader_thread->start();
135144
}
136145

@@ -215,7 +224,8 @@ auto NetworkReader::DownloaderThread::thread_method() -> void {
215224
m_offset,
216225
m_disable_caching,
217226
m_reader.m_connection_timeout,
218-
m_reader.m_overall_timeout
227+
m_reader.m_overall_timeout,
228+
m_http_header_kv_pairs
219229
};
220230
auto const ret_code{curl_handler.perform()};
221231
// Enqueue the last filled buffer, if any

0 commit comments

Comments
 (0)