diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 982dca875..3d55aaf74 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -5,13 +5,13 @@ permissions: on: push: - branches: [ 'main' ] + branches: ["main"] paths: - - 'python/**' + - "python/**" pull_request: - branches: [ '*' ] + branches: ["*"] paths: - - 'python/**' + - "python/**" jobs: lint: @@ -21,16 +21,16 @@ jobs: working-directory: ./python steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Install Ruff - uses: astral-sh/ruff-action@v3 + - name: Install Ruff + uses: astral-sh/ruff-action@v3 - - name: Ruff Format - run: ruff format --check --config ./pyproject.toml . + - name: Ruff Format + run: ruff format --check --config ./pyproject.toml . - - name: Ruff Lint - run: ruff check --config ./pyproject.toml . + - name: Ruff Lint + run: ruff check --config ./pyproject.toml . unit_test: runs-on: ubuntu-latest @@ -39,19 +39,24 @@ jobs: working-directory: ./python steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 + with: + fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version-file: "./python/pyproject.toml" + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version-file: "./python/pyproject.toml" - - name: Install uv - uses: astral-sh/setup-uv@v6 + - name: Install uv + uses: astral-sh/setup-uv@v6 - - name: Install the project - run: uv sync --locked --all-extras --dev + - name: Install the project + run: uv sync --locked --all-extras --dev - - name: Run tests - run: uv run pytest + - name: Run tests + run: uv run pytest valuecell/core/ --cov=valuecell.core --cov-report=xml --cov-report=term + - name: Check coverage + run: | + uv run diff-cover coverage.xml --fail-under=90 diff --git a/python/pyproject.toml b/python/pyproject.toml index c96f87b94..72213c125 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -31,6 +31,7 @@ dev = [ "pytest>=7.4.0", "pytest-cov>=4.1.0", "pytest-asyncio>=1.0.0", + "diff-cover>=9.0.0", ] [dependency-groups] @@ -45,6 +46,7 @@ test = [ "pytest>=7.4.0", "pytest-cov>=4.1.0", "pytest-asyncio>=1.0.0", + "diff-cover>=9.0.0", ] [tool.ruff] diff --git a/python/uv.lock b/python/uv.lock index 95e6de56f..d7ac00e44 100644 --- a/python/uv.lock +++ b/python/uv.lock @@ -297,6 +297,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/7c/fc/6a8cb64e5f0324877d503c854da15d76c1e50eb722e320b15345c4d0c6de/cffi-1.17.1-cp313-cp313-win_amd64.whl", hash = "sha256:f6a16c31041f09ead72d69f583767292f750d24913dadacf5756b966aacb3f1a", size = 182009, upload-time = "2024-09-04T20:44:45.309Z" }, ] +[[package]] +name = "chardet" +version = "5.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f3/0d/f7b6ab21ec75897ed80c17d79b15951a719226b9fababf1e40ea74d69079/chardet-5.2.0.tar.gz", hash = "sha256:1b3b6ff479a8c414bc3fa2c0852995695c4a026dcd6d0633b2dd092ca39c1cf7", size = 2069618, upload-time = "2023-08-01T19:23:02.662Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/38/6f/f5fbc992a329ee4e0f288c1fe0e2ad9485ed064cac731ed2fe47dcc38cbf/chardet-5.2.0-py3-none-any.whl", hash = "sha256:e1cf59446890a00105fe7b7912492ea04b6e6f06d4b742b2c788469e34c82970", size = 199385, upload-time = "2023-08-01T19:23:00.661Z" }, +] + [[package]] name = "charset-normalizer" version = "3.4.3" @@ -454,6 +463,21 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/4e/8c/f3147f5c4b73e7550fe5f9352eaa956ae838d5c51eb58e7a25b9f3e2643b/decorator-5.2.1-py3-none-any.whl", hash = "sha256:d316bb415a2d9e2d2b3abcc4084c6502fc09240e292cd76a76afc106a1c8e04a", size = 9190, upload-time = "2025-02-24T04:41:32.565Z" }, ] +[[package]] +name = "diff-cover" +version = "9.7.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "chardet" }, + { name = "jinja2" }, + { name = "pluggy" }, + { name = "pygments" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/eb/b7/3124f2038eb9d2842665c109d4516110e3e5570615243ee1065fdc65ac7d/diff_cover-9.7.1.tar.gz", hash = "sha256:a03b78bc64b7dc27dda7f11c46bc6d44f4e121c8fb9a5068d41f20a05d463548", size = 100366, upload-time = "2025-09-26T01:02:43.81Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1d/c2/36d747a14dd3834af7e2f4f86daf8d6e21762ffbdb2b177a5bb3be8f0e8f/diff_cover-9.7.1-py3-none-any.whl", hash = "sha256:a662f3cacf57ba494dcb0235349c4912ae7f44345b162894ce5949745501c9c7", size = 56008, upload-time = "2025-09-26T01:02:42.399Z" }, +] + [[package]] name = "distro" version = "1.9.0" @@ -2122,6 +2146,7 @@ dependencies = [ [package.optional-dependencies] dev = [ + { name = "diff-cover" }, { name = "pytest" }, { name = "pytest-asyncio" }, { name = "pytest-cov" }, @@ -2130,6 +2155,7 @@ dev = [ [package.dev-dependencies] dev = [ + { name = "diff-cover" }, { name = "pytest" }, { name = "pytest-asyncio" }, { name = "pytest-cov" }, @@ -2139,6 +2165,7 @@ lint = [ { name = "ruff" }, ] test = [ + { name = "diff-cover" }, { name = "pytest" }, { name = "pytest-asyncio" }, { name = "pytest-cov" }, @@ -2150,6 +2177,7 @@ requires-dist = [ { name = "agno", extras = ["openai"], specifier = ">=1.8.2,<2.0" }, { name = "aiosqlite", specifier = ">=0.19.0" }, { name = "akshare", specifier = ">=1.17.44" }, + { name = "diff-cover", marker = "extra == 'dev'", specifier = ">=9.0.0" }, { name = "edgartools", specifier = ">=4.12.2" }, { name = "fastapi", specifier = ">=0.104.0" }, { name = "pydantic", specifier = ">=2.0.0" }, @@ -2169,6 +2197,7 @@ provides-extras = ["dev"] [package.metadata.requires-dev] dev = [ + { name = "diff-cover", specifier = ">=9.0.0" }, { name = "pytest", specifier = ">=7.4.0" }, { name = "pytest-asyncio", specifier = ">=1.0.0" }, { name = "pytest-cov", specifier = ">=4.1.0" }, @@ -2176,6 +2205,7 @@ dev = [ ] lint = [{ name = "ruff" }] test = [ + { name = "diff-cover", specifier = ">=9.0.0" }, { name = "pytest", specifier = ">=7.4.0" }, { name = "pytest-asyncio", specifier = ">=1.0.0" }, { name = "pytest-cov", specifier = ">=4.1.0" },