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

Commit 76e7adf

Browse files
committed
ci: e2e testing use GITHUB_TOKEN to increase github api rate limit
1 parent 5c7519a commit 76e7adf

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

.github/workflows/template-build-linux-x64.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ jobs:
144144
python e2e-test/main.py
145145
rm build/cortex-nightly
146146
rm build/cortex-beta
147+
env:
148+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
147149

148150
- name: Pre-package
149151
run: |

.github/workflows/template-build-macos.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ jobs:
169169
python e2e-test/main.py
170170
rm build/cortex-nightly
171171
rm build/cortex-beta
172+
env:
173+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
172174

173175
- name: Pre-package
174176
run: |

.github/workflows/template-build-windows-x64.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ jobs:
180180
python e2e-test/main.py
181181
rm build/cortex-nightly.exe
182182
rm build/cortex-beta.exe
183+
env:
184+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
183185

184186
- name: Pre-package
185187
run: |

engine/services/engine_service.cc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ cpp::result<bool, std::string> EngineService::UninstallEngine(
217217

218218
cpp::result<bool, std::string> EngineService::DownloadEngine(
219219
const std::string& engine, const std::string& version) {
220+
221+
// Check if GITHUB_TOKEN env exist
222+
const char* github_token = std::getenv("GITHUB_TOKEN");
223+
220224
auto get_params = [&engine, &version]() -> std::vector<std::string> {
221225
if (version == "latest") {
222226
return {"repos", "janhq", engine, "releases", version};
@@ -232,7 +236,18 @@ cpp::result<bool, std::string> EngineService::DownloadEngine(
232236
};
233237

234238
httplib::Client cli(url_obj.GetProtocolAndHost());
235-
if (auto res = cli.Get(url_obj.GetPathAndQuery());
239+
240+
httplib::Headers headers;
241+
242+
if (github_token) {
243+
std::string auth_header = "token " + std::string(github_token);
244+
headers.insert({"Authorization", auth_header});
245+
CTL_INF("Using authentication with GitHub token.");
246+
} else {
247+
CTL_INF("No GitHub token found. Sending request without authentication.");
248+
}
249+
250+
if (auto res = cli.Get(url_obj.GetPathAndQuery(), headers);
236251
res->status == httplib::StatusCode::OK_200) {
237252
auto body = json::parse(res->body);
238253
auto get_data =

0 commit comments

Comments
 (0)