Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8168cd8
feat: download pre-release
vansangpfiev Sep 17, 2024
67fed07
Merge branch 'dev' of github.com:janhq/nitro into feat/download-pre-r…
vansangpfiev Sep 17, 2024
1efc0b6
feat: download pre-release
vansangpfiev Sep 17, 2024
24cbcf1
chore: add e2e test
vansangpfiev Sep 17, 2024
d3c36c1
fix: m
vansangpfiev Sep 17, 2024
f729364
feat: e2e test CI
vansangpfiev Sep 17, 2024
bfde9b9
f:m
vansangpfiev Sep 17, 2024
71a55cc
f:f
vansangpfiev Sep 17, 2024
10e87e4
fix: timeout
vansangpfiev Sep 17, 2024
a40594b
Merge branch 'dev' of github.com:janhq/nitro into feat/e2e-test-ci
vansangpfiev Sep 18, 2024
85ef04d
fix: exit code
vansangpfiev Sep 18, 2024
3b5ac11
Merge branch 'dev' into feat/e2e-test-ci
vansangpfiev Sep 19, 2024
dd8328b
Merge branch 'dev' of github.com:janhq/nitro into feat/e2e-test-ci
vansangpfiev Sep 19, 2024
7d603c5
Merge branch 'feat/e2e-test-ci' of github.com:janhq/nitro into feat/e…
vansangpfiev Sep 19, 2024
c2d3d92
fix: timeout None
vansangpfiev Sep 19, 2024
607629a
Merge branch 'dev' of github.com:janhq/nitro into feat/e2e-test-ci
vansangpfiev Sep 19, 2024
479cd1b
Merge branch 'dev' of github.com:janhq/nitro into feat/e2e-test-ci
vansangpfiev Oct 1, 2024
a343f4b
Merge branch 'dev' of github.com:janhq/nitro into feat/e2e-test-ci
vansangpfiev Oct 1, 2024
652363a
fix: test
vansangpfiev Oct 1, 2024
e10370f
f:m
vansangpfiev Oct 1, 2024
32cef18
f:m
vansangpfiev Oct 2, 2024
8a71cae
fix: clone exe
vansangpfiev Oct 2, 2024
ad9ac1e
fix: cd
vansangpfiev Oct 2, 2024
90f5b26
fix: temp comment
vansangpfiev Oct 2, 2024
b198911
fix: windows and macos
vansangpfiev Oct 2, 2024
14c12f8
fix: test
vansangpfiev Oct 2, 2024
8af6b78
fix: windows
vansangpfiev Oct 2, 2024
f7fdd42
fix: readable
vansangpfiev Oct 2, 2024
5c7519a
Merge branch 'dev' into feat/e2e-test-ci
hiento09 Oct 2, 2024
76e7adf
ci: e2e testing use GITHUB_TOKEN to increase github api rate limit
hiento09 Oct 2, 2024
f6ea8bd
ci: enable e2e testing in quality gate new PR
hiento09 Oct 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 36 additions & 6 deletions .github/workflows/cortex-cpp-quality-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI Quality Gate Cortex CPP

on:
pull_request:
types: [opened, synchronize, reopened]
types: [opened, synchronize, reopened, ready_for_review]
paths:
[
"engine/**",
Expand Down Expand Up @@ -53,11 +53,10 @@ jobs:
with:
submodules: recursive

- name: use python for linux
if: runner.os == 'Linux'
uses: actions/setup-python@v4
- name: use python
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.10'

- name: Install tools on Linux
if: runner.os == 'Linux'
Expand Down Expand Up @@ -106,7 +105,38 @@ jobs:
run: |
cd engine
make run-unit-tests


- name: Run e2e tests
if: runner.os != 'Windows' && github.event.pull_request.draft == false
run: |
cd engine
cp build/cortex build/cortex-nightly
cp build/cortex build/cortex-beta
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install requests
python e2e-test/main.py
rm build/cortex-nightly
rm build/cortex-beta
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


- name: Run e2e tests
if: runner.os == 'Windows' && github.event.pull_request.draft == false
run: |
cd engine
cp build/cortex.exe build/cortex-nightly.exe
cp build/cortex.exe build/cortex-beta.exe
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install requests
python e2e-test/main.py
rm build/cortex-nightly.exe
rm build/cortex-beta.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Pre-package
run: |
cd engine
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/template-build-linux-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@ jobs:
run: |
cd engine
make build CMAKE_EXTRA_FLAGS="${{ inputs.cmake-flags }}" BUILD_DEPS_CMAKE_EXTRA_FLAGS="${{ inputs.build-deps-cmake-flags }}"

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Run e2e tests
run: |
cd engine
cp build/cortex build/cortex-nightly
cp build/cortex build/cortex-beta
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install requests
python e2e-test/main.py
rm build/cortex-nightly
rm build/cortex-beta
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Pre-package
run: |
Expand Down
21 changes: 20 additions & 1 deletion .github/workflows/template-build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,26 @@ jobs:
run: |
cd engine
make build CMAKE_EXTRA_FLAGS="${{ inputs.cmake-flags }}" BUILD_DEPS_CMAKE_EXTRA_FLAGS="${{ inputs.build-deps-cmake-flags }}"


- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Run e2e tests
run: |
cd engine
cp build/cortex build/cortex-nightly
cp build/cortex build/cortex-beta
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install requests
python e2e-test/main.py
rm build/cortex-nightly
rm build/cortex-beta
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Pre-package
run: |
cd engine
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/template-build-windows-x64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,25 @@ jobs:
cd engine
make build CMAKE_EXTRA_FLAGS="${{ inputs.cmake-flags }}" BUILD_DEPS_CMAKE_EXTRA_FLAGS="${{ inputs.build-deps-cmake-flags }}"

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Run e2e tests
run: |
cd engine
cp build/cortex.exe build/cortex-nightly.exe
cp build/cortex.exe build/cortex-beta.exe
python -m pip install --upgrade pip
python -m pip install pytest
python -m pip install requests
python e2e-test/main.py
rm build/cortex-nightly.exe
rm build/cortex-beta.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Pre-package
run: |
cd engine
Expand Down
2 changes: 1 addition & 1 deletion engine/e2e-test/test_cli_engine_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class TestCliEngineInstall:

def test_engines_install_llamacpp_should_be_successfully(self):
exit_code, output, error = run(
"Install Engine", ["engines", "install", "cortex.llamacpp"], timeout=600
"Install Engine", ["engines", "install", "cortex.llamacpp"], timeout=None
)
assert "Start downloading" in output, "Should display downloading message"
assert exit_code == 0, f"Install engine failed with error: {error}"
Expand Down
6 changes: 5 additions & 1 deletion engine/e2e-test/test_create_log_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ def setup_and_teardown(self):

def test_create_log_folder_run_successfully(self):
root = Path.home()
assert os.path.exists(root / "cortexcpp" / "logs")
assert (
os.path.exists(root / "cortexcpp" / "logs")
or os.path.exists(root / "cortexcpp-beta" / "logs")
or os.path.exists(root / "cortexcpp-nightly" / "logs")
)
2 changes: 1 addition & 1 deletion engine/e2e-test/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import List

# You might want to change the path of the executable based on your build directory
executable_windows_path = "build\\Debug\\cortex.exe"
executable_windows_path = "build\\cortex.exe"
executable_unix_path = "build/cortex"

# Timeout
Expand Down
17 changes: 16 additions & 1 deletion engine/services/engine_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ cpp::result<bool, std::string> EngineService::UninstallEngine(

cpp::result<bool, std::string> EngineService::DownloadEngine(
const std::string& engine, const std::string& version) {

// Check if GITHUB_TOKEN env exist
const char* github_token = std::getenv("GITHUB_TOKEN");

auto get_params = [&engine, &version]() -> std::vector<std::string> {
if (version == "latest") {
return {"repos", "janhq", engine, "releases", version};
Expand All @@ -232,7 +236,18 @@ cpp::result<bool, std::string> EngineService::DownloadEngine(
};

httplib::Client cli(url_obj.GetProtocolAndHost());
if (auto res = cli.Get(url_obj.GetPathAndQuery());

httplib::Headers headers;

if (github_token) {
std::string auth_header = "token " + std::string(github_token);
headers.insert({"Authorization", auth_header});
CTL_INF("Using authentication with GitHub token.");
} else {
CTL_INF("No GitHub token found. Sending request without authentication.");
}

if (auto res = cli.Get(url_obj.GetPathAndQuery(), headers);
res->status == httplib::StatusCode::OK_200) {
auto body = json::parse(res->body);
auto get_data =
Expand Down
Loading