From 51f2c55d3058a578f4d699d2e9a7803d56c60a7f Mon Sep 17 00:00:00 2001 From: imotai Date: Fri, 29 Sep 2023 23:51:09 +0800 Subject: [PATCH 1/9] fix: fix the output exception --- up/src/og_up/up.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/up/src/og_up/up.py b/up/src/og_up/up.py index c325fb6..1e68dbe 100644 --- a/up/src/og_up/up.py +++ b/up/src/og_up/up.py @@ -86,7 +86,8 @@ def run_with_realtime_print( shell=useshell, env=env, ) - text_fd = io.TextIOWrapper(p.stdout, encoding="utf-8", newline=os.linesep) + + text_fd = io.TextIOWrapper(p.stdout, encoding="utf-8", newline=os.linesep, errors='replace') while True: chunk = text_fd.read(40) if not chunk: From 34d326103e0b06d47ca0512c18a997f3fb3f674d Mon Sep 17 00:00:00 2001 From: imotai Date: Sat, 30 Sep 2023 00:07:05 +0800 Subject: [PATCH 2/9] fix: add matric action --- .github/workflows/ci.yaml | 5 +++-- start_sandbox.sh | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c49996c..68317fe 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,8 +9,9 @@ on: - main jobs: build: - #runs-on: self-hosted - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, windows-latest] steps: - name: Checkout repository uses: actions/checkout@v3 diff --git a/start_sandbox.sh b/start_sandbox.sh index cc2f0c8..35cfb98 100644 --- a/start_sandbox.sh +++ b/start_sandbox.sh @@ -1,5 +1,4 @@ #! /bin/sh -# # start_local.sh ps -ef | grep python3 | grep -v grep | awk '{print $2}' | while read line; do kill -9 $line; done WORKDIR=`pwd` From fbcdf5d4abe14f66bcf87b96d3a6ca4eeb278718 Mon Sep 17 00:00:00 2001 From: imotai Date: Sat, 30 Sep 2023 00:09:23 +0800 Subject: [PATCH 3/9] fix: add run on --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 68317fe..05a12da 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,6 +12,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - name: Checkout repository uses: actions/checkout@v3 From a97b83af31bea2b22936f03a0835d819f01a7ca1 Mon Sep 17 00:00:00 2001 From: imotai Date: Sat, 30 Sep 2023 00:20:09 +0800 Subject: [PATCH 4/9] fix: add macos --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 05a12da..901a0a4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,7 +11,7 @@ jobs: build: strategy: matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - name: Checkout repository From d07a328413569c9cdb37e2342c81e00b675113ef Mon Sep 17 00:00:00 2001 From: imotai Date: Sat, 30 Sep 2023 14:13:09 +0800 Subject: [PATCH 5/9] test: add cli cl workflow --- .github/workflows/ci.yaml | 8 +++----- .github/workflows/cli_ci.yaml | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/cli_ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 901a0a4..649c9fa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: Python Project +name: backend testing on: push: @@ -9,10 +9,8 @@ on: - main jobs: build: - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - runs-on: ${{ matrix.os }} + #runs-on: self-hosted + runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 diff --git a/.github/workflows/cli_ci.yaml b/.github/workflows/cli_ci.yaml new file mode 100644 index 0000000..7602de7 --- /dev/null +++ b/.github/workflows/cli_ci.yaml @@ -0,0 +1,27 @@ +name: Cli Testing + +on: + push: + branches: + - main + pull_request: + branches: + - main +jobs: + build: + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Install dependencies + run: pip install -r requirements.txt + - name: Run cli tests + run: | + cd up + pip install . + pytest tests/*.py From 0a466160abccec5f9fe1279f559cb7767be4722c Mon Sep 17 00:00:00 2001 From: imotai Date: Sat, 30 Sep 2023 14:16:35 +0800 Subject: [PATCH 6/9] fix: add python setup --- .github/workflows/cli_ci.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/cli_ci.yaml b/.github/workflows/cli_ci.yaml index 7602de7..bdf3487 100644 --- a/.github/workflows/cli_ci.yaml +++ b/.github/workflows/cli_ci.yaml @@ -12,12 +12,17 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ["3.10", "3.11"] runs-on: ${{ matrix.os }} steps: - name: Checkout repository uses: actions/checkout@v3 with: submodules: recursive + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} - name: Install dependencies run: pip install -r requirements.txt - name: Run cli tests From 36e8646470dc9c312f1041549e5eaa13f871784f Mon Sep 17 00:00:00 2001 From: imotai Date: Sat, 30 Sep 2023 14:23:26 +0800 Subject: [PATCH 7/9] test: add a simple test for chat --- .github/workflows/cli_ci.yaml | 7 ++++++- chat/tests/test_parse_files.py | 19 +++++++++++++++++++ up/tests/up_tests.py | 25 +++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 chat/tests/test_parse_files.py create mode 100644 up/tests/up_tests.py diff --git a/.github/workflows/cli_ci.yaml b/.github/workflows/cli_ci.yaml index bdf3487..e4d9e72 100644 --- a/.github/workflows/cli_ci.yaml +++ b/.github/workflows/cli_ci.yaml @@ -27,6 +27,11 @@ jobs: run: pip install -r requirements.txt - name: Run cli tests run: | - cd up + WORK_DIR=`pwd` + cd ${WORK_DIR}/up pip install . pytest tests/*.py + cd ${WORK_DIR}/chat + pip install . + pytest tests/*.py + diff --git a/chat/tests/test_parse_files.py b/chat/tests/test_parse_files.py new file mode 100644 index 0000000..436b790 --- /dev/null +++ b/chat/tests/test_parse_files.py @@ -0,0 +1,19 @@ +#! /usr/bin/env python3 +# vim:fenc=utf-8 +# +# Copyright © 2023 imotai +# +# Distributed under terms of the MIT license. + +""" + +""" + +from og_terminal.utils import parse_file_path + + +def test_parse_file_path(): + prompt = "convert the file /up /home/test.pdf to text" + paths = parse_file_path(prompt) + assert len(paths) == 1, "bad file path count" + assert paths[0] == '/home/test.pdf', "bad file path " diff --git a/up/tests/up_tests.py b/up/tests/up_tests.py new file mode 100644 index 0000000..07ab1ed --- /dev/null +++ b/up/tests/up_tests.py @@ -0,0 +1,25 @@ +#! /usr/bin/env python3 +# vim:fenc=utf-8 +# +# Copyright © 2023 imotai +# +# Distributed under terms of the MIT license. + +""" +""" + +import os +from og_up.up import run_with_realtime_print + +import pytest + +def test_run_print(): + use_dir = os.path.expanduser("~") + command = ["ls", use_dir] + result_code = 0 + for code , output in run_with_realtime_print(command): + result_code = code + assert code == 0, "bad return code" + + + From 0e26089e0be9b33077e33840515ad030cd95f198 Mon Sep 17 00:00:00 2001 From: imotai Date: Sat, 30 Sep 2023 14:28:42 +0800 Subject: [PATCH 8/9] fix: adjust the shell command --- .github/workflows/cli_ci.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cli_ci.yaml b/.github/workflows/cli_ci.yaml index e4d9e72..2040125 100644 --- a/.github/workflows/cli_ci.yaml +++ b/.github/workflows/cli_ci.yaml @@ -27,11 +27,9 @@ jobs: run: pip install -r requirements.txt - name: Run cli tests run: | - WORK_DIR=`pwd` - cd ${WORK_DIR}/up + cd up pip install . pytest tests/*.py - cd ${WORK_DIR}/chat + cd ../chat pip install . pytest tests/*.py - From 2d248d82b9ef090be98d8f1a31a03b3a2c9d3dfc Mon Sep 17 00:00:00 2001 From: imotai Date: Sat, 30 Sep 2023 14:33:20 +0800 Subject: [PATCH 9/9] fix: adjust the shell --- .github/workflows/cli_ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cli_ci.yaml b/.github/workflows/cli_ci.yaml index 2040125..765ad6b 100644 --- a/.github/workflows/cli_ci.yaml +++ b/.github/workflows/cli_ci.yaml @@ -26,6 +26,7 @@ jobs: - name: Install dependencies run: pip install -r requirements.txt - name: Run cli tests + shell: bash run: | cd up pip install .