From 1ec18b7fe95ab9e7ff07ae9d893d8ed1b338c1b7 Mon Sep 17 00:00:00 2001 From: Natuworkguy <149914029+Natuworkguy@users.noreply.github.com> Date: Tue, 5 May 2026 03:35:47 +0000 Subject: [PATCH 1/2] Add CI/CD workflows and initial test suite - Added GitHub Actions workflows for Linting (Ruff), Testing (Pytest), and Building. - Created `tests/` directory and added unit tests for `shellmind/ai.py`. - Added `requirements-dev.txt` for development dependencies. - Updated project to support testing with `pip install -e .`. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 23 ++++++++++++++++++++++ .github/workflows/lint.yml | 23 ++++++++++++++++++++++ .github/workflows/test.yml | 29 ++++++++++++++++++++++++++++ requirements-dev.txt | 4 ++++ tests/test_ai.py | 38 +++++++++++++++++++++++++++++++++++++ 5 files changed, 117 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test.yml create mode 100644 requirements-dev.txt create mode 100644 tests/test_ai.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..1258c0b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: Build + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..f79a2c4 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,23 @@ +name: Lint + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ruff + - name: Run Ruff + run: ruff check . diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1d989d2 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,29 @@ +name: Test + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.10', '3.11', '3.12'] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pytest + pip install -e . + - name: Run tests + run: pytest diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..2327f42 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,4 @@ +pytest +ruff +build +twine diff --git a/tests/test_ai.py b/tests/test_ai.py new file mode 100644 index 0000000..a9db973 --- /dev/null +++ b/tests/test_ai.py @@ -0,0 +1,38 @@ +from shellmind.ai import _int_env, _trim_history, _direct_shell_command, _trim_tool_output, config + +def test_int_env(monkeypatch): + monkeypatch.setenv("TEST_VAR", "10") + assert _int_env("TEST_VAR", 5, minimum=2) == 10 + + monkeypatch.setenv("TEST_VAR", "1") + assert _int_env("TEST_VAR", 5, minimum=2) == 2 + + monkeypatch.setenv("TEST_VAR", "invalid") + assert _int_env("TEST_VAR", 5, minimum=2) == 5 + + monkeypatch.delenv("TEST_VAR", raising=False) + assert _int_env("TEST_VAR", 5, minimum=2) == 5 + +def test_trim_history(): + messages = [{"role": "user", "parts": [{"text": "hello"}]}] * 10 + # config.max_history_messages is 6 by default + _trim_history(messages) + assert len(messages) <= config.max_history_messages + +def test_direct_shell_command(): + assert _direct_shell_command("!ls") == "ls" + assert _direct_shell_command("/shell echo hi") == "echo hi" + assert _direct_shell_command("/run git status") == "git status" + assert _direct_shell_command("just text") is None + +def test_trim_tool_output(): + text = "a" * 2000 + trimmed = _trim_tool_output(text) + assert "truncated" in trimmed + assert len(trimmed) < 2000 + + short_text = "hello" + assert _trim_tool_output(short_text) == "hello" + + empty_text = "" + assert _trim_tool_output(empty_text) == "(no output)" From a5697f1dd221642c61a95dfcc007e9d5285a27a9 Mon Sep 17 00:00:00 2001 From: Natuworkguy <149914029+Natuworkguy@users.noreply.github.com> Date: Tue, 5 May 2026 03:42:06 +0000 Subject: [PATCH 2/2] Implement cross-platform CI/CD with separate jobs for Linux, Windows, and macOS - Created a consolidated `ci.yml` workflow. - Defined separate jobs for Linting, Testing, and Building on Linux, Windows, and macOS to generate a clear visual pipeline graph. - Added comprehensive unit tests in `tests/test_ai.py`. - Included `requirements-dev.txt` for developer tools. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 23 ------ .github/workflows/ci.yml | 141 ++++++++++++++++++++++++++++++++++++ .github/workflows/lint.yml | 23 ------ .github/workflows/test.yml | 29 -------- 4 files changed, 141 insertions(+), 75 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 1258c0b..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Build - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: python -m build diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e58cf16 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,141 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + lint: + name: Lint (Ruff) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install ruff + - name: Run Ruff + run: ruff check . + + test-linux: + name: Test (Linux) + needs: lint + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.10', '3.11', '3.12'] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pytest + pip install -e . + - name: Run tests + run: pytest + + test-windows: + name: Test (Windows) + needs: lint + runs-on: windows-latest + strategy: + matrix: + python-version: ['3.10', '3.11', '3.12'] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pytest + pip install -e . + - name: Run tests + run: pytest + + test-macos: + name: Test (macOS) + needs: lint + runs-on: macos-latest + strategy: + matrix: + python-version: ['3.10', '3.11', '3.12'] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install pytest + pip install -e . + - name: Run tests + run: pytest + + build-linux: + name: Build (Linux) + needs: test-linux + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + + build-windows: + name: Build (Windows) + needs: test-windows + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + + build-macos: + name: Build (macOS) + needs: test-macos + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index f79a2c4..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Lint - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install ruff - - name: Run Ruff - run: ruff check . diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 1d989d2..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Test - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.10', '3.11', '3.12'] - - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install pytest - pip install -e . - - name: Run tests - run: pytest