From e03f8e0da8b136c683201227014612847d30f292 Mon Sep 17 00:00:00 2001 From: "Luktug Ltd." Date: Sat, 11 Jan 2025 23:14:41 +0000 Subject: [PATCH] Update github CI workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Update doc dependencies # Update toolchain and github actions workflow # Update pyproject.toml dependencies (+optional) # Update ruff.lint configuration # Generate pytest coverage report --- .github/workflows/ci.yml | 60 ++++++++++++++++++++++++++++++-------- pyproject.toml | 17 ++++++++++- pyslm/hatching/hatching.py | 2 +- tests/core/test_core.py | 7 ++--- 4 files changed, 67 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0fede62..95d1688 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,10 +44,10 @@ jobs: uses: actions/setup-python@v5 with: python-version: 3.12 - - name: Install libspatial + - name: Install libspatial, pyclipr dependencies run: | sudo apt-get update -y -qq - sudo apt-get install -qq -y libglu1-mesa libspatialindex6 + sudo apt-get install -qq -y libglu1-mesa libspatialindex6 build-essential libeigen3-dev - name: Install dev dependencies run: | python -m pip install --upgrade pip @@ -55,8 +55,7 @@ jobs: - name: Build docs run: | cd docs - make html SPHINXOPTS="-W --keep-going" - + sphinx-build --builder html . out test-builds: name: ${{ matrix.name }} runs-on: ${{ matrix.os }} @@ -85,20 +84,51 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.pyversion }} - - name: Install libspatial + - name: Install libspatial and pyclipr dependencies if: matrix.os == 'ubuntu-latest' run: | sudo apt-get update -y -qq - sudo apt-get install -qq -y libglu1-mesa libspatialindex6 + sudo apt-get install -qq -y libglu1-mesa libspatialindex6 build-essential libeigen3-dev - name: Install package and dev dependencies run: | python -m pip install --upgrade pip + pip install . pip install .[tests] + pip install .[support] rm -r pyslm - - name: Unit tests + - name: Unit tests with pytest run: | - pytest -v tests - + pytest tests/ + test-coverage: + name: Test Coverage + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: Install libspatial and pyclipr dependencies + run: | + sudo apt-get update -y -qq + sudo apt-get install -qq -y libglu1-mesa libspatialindex6 build-essential libeigen3-dev + - name: Install package and dev dependencies + run: | + python -m pip install --upgrade pip + pip install . + pip install .[tests] + pip install .[support] + rm -r pyslm + - name: Run Pytest coverage + run: | + pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=pyslm tests/ | tee pytest-coverage.txt + - name: Pytest coverage comment + uses: MishaKav/pytest-coverage-comment@main + with: + pytest-coverage-path: ./pytest-coverage.txt + junitxml-path: ./pytest.xml test-examples-build: name: Test examples ${{ matrix.pyversion }} runs-on: ${{ matrix.os }} @@ -116,10 +146,10 @@ jobs: uses: actions/setup-python@v5 with: python-version: 3.12 - - name: Install libspatial + - name: Install libspatial and pyclipr dependencies run: | sudo apt-get update -y -qq - sudo apt-get install -qq -y libglu1-mesa libspatialindex6 + sudo apt-get install -qq -y libglu1-mesa libspatialindex6 build-essential libeigen3-dev - name: Install dev dependencies run: | python -m pip install --upgrade pip @@ -139,10 +169,16 @@ jobs: uses: actions/setup-python@v5 with: python-version: 3.12 + - name: Install Hatch + uses: pypa/hatch@install + - name: Install libspatial and pyclipr dependencies + run: | + sudo apt-get update -y -qq + sudo apt-get install -qq -y libglu1-mesa libspatialindex6 build-essential libeigen3-dev - name: Install dev dependencies run: | python -m pip install --upgrade pip - pip install -U flit build twine + pip install -U flit build twine hatchling - name: Create source distribution run: | python -m build -n -s diff --git a/pyproject.toml b/pyproject.toml index 0a453c7..c1b1980 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,15 +50,25 @@ docs = [ "networkx", "numpy", "pyclipr", + "mapbox-earcut", "autodocsumm", + "sphinx-autodoc-typehints", + "m2r2", + "sphinx_automodapi", "scikit-image", "scipy", "shapely", "sphinx", + "docutils==0.20", + "mock", "sphinx-paramlinks", "pypandoc", "sphinx_rtd_theme", + "furo", + "triangle", "trimesh", + "vispy", + "PyQt5" ] easy = [ "colorlog", @@ -68,6 +78,11 @@ easy = [ "triangle", "trimesh", ] +tests = [ + "pytest", + "pytest-cov", + "coverage-badge" +] support = [ "mapbox-earcut", "manifold3d", @@ -119,7 +134,7 @@ testpaths = [ [tool.ruff.lint] select = ["F", "E", "W", "N", "B", "RUF"] -exclude = ["build/", "docs/", "examples/", "tests/", "__pycache__", ".github"] +exclude = ["setup.py", "build/*", "dist/*", "docs/*", "examples/*", "tests/*", "__pycache__", ".github"] ignore = [ "E501", # Line too long "N802", # Function name should be lowercase diff --git a/pyslm/hatching/hatching.py b/pyslm/hatching/hatching.py index 23271cd..b114cf2 100755 --- a/pyslm/hatching/hatching.py +++ b/pyslm/hatching/hatching.py @@ -1,6 +1,6 @@ import abc import time -from typing import assert_never, Any, List, Optional, Tuple, Union +from typing import Any, List, Optional, Tuple, Union import logging import numpy as np diff --git a/tests/core/test_core.py b/tests/core/test_core.py index 075b327..01ac507 100644 --- a/tests/core/test_core.py +++ b/tests/core/test_core.py @@ -15,9 +15,6 @@ class TestBasic: NUM_ORIGINS = 10 NUM_SCALEFACTORS = 10 - def test_version(self): - assert pyslm.__version__ == '0.7.0' - def test_vector_slicing_cube(self): # load the mesh into a pyslm Part @@ -111,7 +108,7 @@ def test_vector_slicing_complex_path(self): # slice the part part = pyslm.Part('cube') - part.setGeometry('../../models/frameGuide.stl') + part.setGeometry('./models/frameGuide.stl') # slice the part polys = part.getVectorSlice(0.0, returnCoordPaths=False) @@ -149,7 +146,7 @@ def test_bitmap_slicing_complex(self): # slice the part part = pyslm.Part('frameguide') - part.setGeometry('../../models/frameGuide.stl') + part.setGeometry('./models/frameGuide.stl') # slice the part polys = part.getVectorSlice(0.0, returnCoordPaths=False)