Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
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@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install OpenGL (GLU)
run: sudo apt-get update && sudo apt-get install -y libglu1-mesa libglu1-mesa-dev
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest pytest-cov
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
VISUALTEST=false PYTHONPATH=${PWD}/src:$PYTHONPATH pytest tests/ -m "not visual"
2 changes: 1 addition & 1 deletion tests/test_geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
from yapcad.geom import *
from yapcad.geom_util import *
from yapcad.pyglet_drawable import *

## unit tests for yapCAD geom.py

Expand Down Expand Up @@ -476,6 +475,7 @@ def test_visual_intersect(self):
"""Visual test of intersection calculation - requires display"""
if not VISUALTEST:
pytest.skip("Visual tests disabled (set VISUALTEST=true to enable)")
from yapcad.pyglet_drawable import *
dd = pygletDraw()
dd.linecolor='silver'
# make a polyline spiral
Expand Down
3 changes: 2 additions & 1 deletion tests/test_geom3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
from yapcad.geom_util import *
from yapcad.geom3d import *
from yapcad.geom3d_util import *
from yapcad.pyglet_drawable import *
from yapcad.poly import *
from yapcad.combine import *

# Control flag for visual tests - set via environment variable or directly
VISUALTEST = os.environ.get('VISUALTEST', 'false').lower() in ('true', '1', 'yes')
if VISUALTEST:
from yapcad.pyglet_drawable import *

def randomPoints(bbox,numpoints):
"""Given a 3D bounding box and a number of points to generate,
Expand Down
4 changes: 3 additions & 1 deletion tests/test_geom_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
from yapcad.geom import *
from yapcad.geom_util import *
from yapcad.pyglet_drawable import *
from yapcad.poly import *
from yapcad.combine import *

Expand All @@ -11,6 +10,9 @@
# Control flag for visual tests - set via environment variable or directly
VISUALTEST = os.environ.get('VISUALTEST', 'false').lower() in ('true', '1', 'yes')

if VISUALTEST:
from yapcad.pyglet_drawable import *

class TestSample:
"""test sampling-related operations"""

Expand Down
4 changes: 2 additions & 2 deletions tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
from yapcad.geom import *
from yapcad.geom_util import *
from yapcad.geometry import *
from yapcad.pyglet_drawable import *

"""test functions for the yapcad.geometry module"""

# Control flag for visual tests - set via environment variable or directly
VISUALTEST = os.environ.get('VISUALTEST', 'false').lower() in ('true', '1', 'yes')

if VISUALTEST:
from yapcad.pyglet_drawable import *

class TestGeometry:
"""Tests for the Geometry class"""
Expand Down
5 changes: 2 additions & 3 deletions tests/test_mesh_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
from yapcad.geom3d_util import conic, sphere
from yapcad.geom_util import geomlist2poly, geomlist2poly_components
from yapcad.mesh import mesh_view
from yapcad.pyglet_drawable import pygletDraw
from yapcad.poly import Polygon, Rect


VISUALTEST = os.environ.get('VISUALTEST', 'false').lower() in ('true', '1', 'yes')

if VISUALTEST:
from yapcad.pyglet_drawable import *

def _strip_w(pt):
return tuple(round(coord, 6) for coord in pt[:3])
Expand Down
3 changes: 2 additions & 1 deletion tests/test_octtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import random
from yapcad.geom import *
from yapcad.octtree import *
from yapcad.pyglet_drawable import *

# Control flag for visual tests - set via environment variable or directly
VISUALTEST = os.environ.get('VISUALTEST', 'false').lower() in ('true', '1', 'yes')
if VISUALTEST:
from yapcad.pyglet_drawable import *

def three2two(x):
"""take a 3D bounding box with non-zero z coordinates, return
Expand Down
Loading