Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 8db7e9c

Browse files
fix: set progress bar width base on terminal width (#1713)
* fix: set progress bar width base on terminal width * chore: CI * fix: CI --------- Co-authored-by: vansangpfiev <[email protected]>
1 parent 16e7c00 commit 8db7e9c

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

.github/workflows/cortex-cpp-quality-gate.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
cd engine
103103
echo "huggingFaceToken: ${{ secrets.HUGGINGFACE_TOKEN_READ }}" > ~/.cortexrc
104104
echo "gitHubToken: ${{ secrets.PAT_SERVICE_ACCOUNT }}" >> ~/.cortexrc
105-
./build/cortex
105+
# ./build/cortex
106106
cat ~/.cortexrc
107107
108108
- name: Run unit tests
@@ -115,10 +115,10 @@ jobs:
115115
- name: Run setup config
116116
run: |
117117
cd engine
118-
echo "huggingFaceToken: ${{ secrets.HUGGINGFACE_TOKEN_READ }}" > ~/.cortexrc
118+
echo "apiServerPort: 3928" > ~/.cortexrc
119+
echo "huggingFaceToken: ${{ secrets.HUGGINGFACE_TOKEN_READ }}" >> ~/.cortexrc
119120
echo "gitHubToken: ${{ secrets.PAT_SERVICE_ACCOUNT }}" >> ~/.cortexrc
120-
echo "apiServerPort: 3928" >> ~/.cortexrc
121-
./build/cortex
121+
# ./build/cortex
122122
cat ~/.cortexrc
123123
124124
- name: Run e2e tests

engine/cli/utils/download_progress.cc

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#include "utils/format_utils.h"
99
#include "utils/json_helper.h"
1010
#include "utils/logging_utils.h"
11+
#if !defined(WIN32) && !defined(WIN64)
12+
#include <sys/ioctl.h>
13+
#include <unistd.h>
14+
#endif
1115

1216
namespace {
1317
std::string Repo2Engine(const std::string& r) {
@@ -20,6 +24,20 @@ std::string Repo2Engine(const std::string& r) {
2024
}
2125
return r;
2226
};
27+
28+
int GetColumns() {
29+
#if defined(WIN32) || defined(WIN64)
30+
CONSOLE_SCREEN_BUFFER_INFO csbi;
31+
int columns;
32+
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
33+
columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
34+
return columns;
35+
#else
36+
struct winsize w;
37+
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
38+
return w.ws_col;
39+
#endif
40+
}
2341
} // namespace
2442
bool DownloadProgress::Connect(const std::string& host, int port) {
2543
if (ws_) {
@@ -97,7 +115,7 @@ bool DownloadProgress::Handle(
97115
items[i.id] = std::pair(
98116
idx,
99117
std::make_unique<indicators::ProgressBar>(
100-
indicators::option::BarWidth{50},
118+
indicators::option::BarWidth{GetColumns() / 6},
101119
indicators::option::Start{"["}, indicators::option::Fill{"="},
102120
indicators::option::Lead{">"}, indicators::option::End{"]"},
103121
indicators::option::PrefixText{pad_string(Repo2Engine(i.id))},

engine/e2e-test/test_api_engine_list.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ class TestApiEngineList:
88
@pytest.fixture(autouse=True)
99
def setup_and_teardown(self):
1010
# Setup
11+
# Not sure why but on macOS amd, the first start server timeouts with CI
12+
start_server()
13+
stop_server()
1114
success = start_server()
1215
if not success:
1316
raise Exception("Failed to start server")

0 commit comments

Comments
 (0)