diff --git a/.github/workflows/python-cli-publish.yml b/.github/workflows/python-cli-publish.yml index 26fc608d..7486d045 100644 --- a/.github/workflows/python-cli-publish.yml +++ b/.github/workflows/python-cli-publish.yml @@ -31,6 +31,13 @@ jobs: - name: Build package run: make build-python-cli + - name: Verify wheel install + run: | + python -m venv /tmp/agentcube-cli-smoke + /tmp/agentcube-cli-smoke/bin/python -m pip install --upgrade pip + /tmp/agentcube-cli-smoke/bin/python -m pip install cmd/cli/dist/*.whl + /tmp/agentcube-cli-smoke/bin/kubectl-agentcube --help + - name: Read package version id: package working-directory: cmd/cli diff --git a/.github/workflows/python-cli-tests.yml b/.github/workflows/python-cli-tests.yml new file mode 100644 index 00000000..23f1e11f --- /dev/null +++ b/.github/workflows/python-cli-tests.yml @@ -0,0 +1,53 @@ +name: Python CLI Tests + +on: + pull_request: + merge_group: + +jobs: + python-cli-tests: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Filter paths + id: changes + uses: dorny/paths-filter@v3 + with: + filters: | + cli: + - "cmd/cli/**" + - "Makefile" + - ".github/workflows/python-cli-publish.yml" + - ".github/workflows/python-cli-tests.yml" + + - name: Setup Python + if: steps.changes.outputs.cli == 'true' + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install dependencies + if: steps.changes.outputs.cli == 'true' + run: | + python -m pip install --upgrade pip + python -m pip install build pytest setuptools + python -m pip install -e ./cmd/cli + + - name: Run unit tests + if: steps.changes.outputs.cli == 'true' + run: python -m pytest cmd/cli/tests -q + + - name: Build CLI package + if: steps.changes.outputs.cli == 'true' + run: make build-python-cli + + - name: Verify wheel install + if: steps.changes.outputs.cli == 'true' + run: | + python -m venv /tmp/agentcube-cli-smoke + /tmp/agentcube-cli-smoke/bin/python -m pip install --upgrade pip + /tmp/agentcube-cli-smoke/bin/python -m pip install cmd/cli/dist/*.whl + /tmp/agentcube-cli-smoke/bin/kubectl-agentcube --help diff --git a/cmd/cli/agentcube/models/__init__.py b/cmd/cli/agentcube/models/__init__.py new file mode 100644 index 00000000..eb0c41f8 --- /dev/null +++ b/cmd/cli/agentcube/models/__init__.py @@ -0,0 +1,13 @@ +# Copyright The Volcano Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/cmd/cli/pyproject.toml b/cmd/cli/pyproject.toml index 7491d9c6..ed9d0dc2 100644 --- a/cmd/cli/pyproject.toml +++ b/cmd/cli/pyproject.toml @@ -43,12 +43,14 @@ dev = [ "ruff>=0.1.0", "mypy>=1.5.0", "pre-commit>=3.3.0", + "setuptools>=61.0", ] test = [ "pytest>=7.4.0", "pytest-asyncio>=0.21.0", "pytest-cov>=4.1.0", "pytest-mock>=3.11.0", + "setuptools>=61.0", "httpx-mock>=0.10.0", ] @@ -61,5 +63,7 @@ Issues = "https://github.com/volcano-sh/agentcube/issues" [project.scripts] kubectl-agentcube = "agentcube.cli.main:app" -[tool.setuptools] -packages = ["agentcube", "agentcube.cli", "agentcube.runtime", "agentcube.operations", "agentcube.services"] +[tool.setuptools.packages.find] +where = ["."] +include = ["agentcube*"] +namespaces = false diff --git a/cmd/cli/tests/test_packaging.py b/cmd/cli/tests/test_packaging.py new file mode 100644 index 00000000..2bc0ef5b --- /dev/null +++ b/cmd/cli/tests/test_packaging.py @@ -0,0 +1,33 @@ +# Copyright The Volcano Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from pathlib import Path + +from setuptools import find_packages + + +def test_packages_are_correctly_discovered(): + package_root = Path(__file__).resolve().parents[1] + packages = set(find_packages(where=package_root, include=["agentcube*"])) + + expected_packages = { + "agentcube", + "agentcube.cli", + "agentcube.runtime", + "agentcube.operations", + "agentcube.services", + "agentcube.models", + } + + assert expected_packages.issubset(packages)