Skip to content

Commit 4c57b41

Browse files
committed
Add Continuous Integration Github Workflow
- Add pytest dependencies to 'project.toml' - Add sphinx dependencies to 'projetc.toml'
1 parent 15e25fc commit 4c57b41

5 files changed

Lines changed: 230 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
pull_request:
8+
branches:
9+
- dev
10+
11+
concurrency:
12+
group: ci-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
17+
lint-build:
18+
name: Linting
19+
runs-on: ubuntu-latest
20+
strategy:
21+
fail-fast: false
22+
steps:
23+
- uses: actions/checkout@v4
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: 3.12
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install ruff
32+
- name: Ruff lint
33+
run: |
34+
ruff check --output-format=github .
35+
36+
docs-build:
37+
name: Docs
38+
runs-on: ubuntu-latest
39+
strategy:
40+
fail-fast: false
41+
steps:
42+
- uses: actions/checkout@v4
43+
- name: Set up Python
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: 3.12
47+
- name: Install calculix dependencies
48+
run: |
49+
sudo apt-get update -y -qq
50+
sudo apt-get install -qq -y calculix-ccx libglu1-mesa gmsh
51+
- name: Install dev dependencies
52+
run: |
53+
python -m pip install --upgrade pip
54+
pip install -U -e .[docs]
55+
- name: Build docs
56+
run: |
57+
cd docs
58+
sphinx-build --builder html . out
59+
test-builds:
60+
name: ${{ matrix.name }}
61+
runs-on: ${{ matrix.os }}
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
include:
66+
- name: Test py39
67+
os: ubuntu-latest
68+
pyversion: '3.9'
69+
- name: Test py310
70+
os: ubuntu-latest
71+
pyversion: '3.10'
72+
- name: Test py311
73+
os: ubuntu-latest
74+
pyversion: '3.11'
75+
- name: Test py312
76+
os: ubuntu-latest
77+
pyversion: '3.12'
78+
- name: Test py313
79+
os: ubuntu-latest
80+
pyversion: '3.13'
81+
steps:
82+
- uses: actions/checkout@v4
83+
- name: Set up Python ${{ matrix.pyversion }}
84+
uses: actions/setup-python@v5
85+
with:
86+
python-version: ${{ matrix.pyversion }}
87+
- name: Install calculix
88+
if: matrix.os == 'ubuntu-latest'
89+
run: |
90+
sudo apt-get update -y -qq
91+
sudo apt-get install -qq -y calculix-ccx
92+
- name: Install package and dev dependencies
93+
run: |
94+
python -m pip install --upgrade pip
95+
pip install .
96+
pip install .[tests]
97+
pip install .[support]
98+
rm -r pyccx
99+
- name: Unit tests with pytest
100+
run: |
101+
pytest tests/
102+
test-coverage:
103+
name: Test Coverage
104+
runs-on: ubuntu-latest
105+
strategy:
106+
fail-fast: false
107+
steps:
108+
- uses: actions/checkout@v4
109+
- name: Set up Python
110+
uses: actions/setup-python@v5
111+
with:
112+
python-version: 3.12
113+
- name: Install calculix
114+
run: |
115+
sudo apt-get update -y -qq
116+
sudo apt-get install -qq -y calculix-ccx gmsh libglu1-mesa
117+
- name: Install package and dev dependencies
118+
run: |
119+
python -m pip install --upgrade pip
120+
pip install .
121+
pip install .[tests]
122+
pip install .[support]
123+
rm -r pyccx
124+
- name: Run Pytest coverage
125+
run: |
126+
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=pyccx tests/ | tee pytest-coverage.txt
127+
- name: Pytest coverage comment
128+
uses: MishaKav/pytest-coverage-comment@main
129+
with:
130+
pytest-coverage-path: ./pytest-coverage.txt
131+
junitxml-path: ./pytest.xml
132+
test-examples-build:
133+
name: Test examples ${{ matrix.pyversion }}
134+
runs-on: ${{ matrix.os }}
135+
strategy:
136+
fail-fast: false
137+
matrix:
138+
include:
139+
- os: ubuntu-latest
140+
pyversion: '3.10'
141+
- os: ubuntu-latest
142+
pyversion: '3.12'
143+
steps:
144+
- uses: actions/checkout@v4
145+
- name: Set up Python
146+
uses: actions/setup-python@v5
147+
with:
148+
python-version: 3.12
149+
- name: Install calculix solver
150+
run: |
151+
sudo apt-get update -y -qq
152+
sudo apt-get install -qq -y calculix-ccx gmsh libglu1-mesa
153+
- name: Install dev dependencies
154+
run: |
155+
python -m pip install --upgrade pip
156+
pip install -e .[examples]
157+
- name: Show pyccx version and calculix version
158+
run: |
159+
python -c "import pyccx; print(pyccx.__version__)"
160+
python -c "import pyccx; print(pyccx.Simulation.version())"
161+
162+
release-build:
163+
name: Build release on ubuntu-latest
164+
runs-on: ubuntu-latest
165+
strategy:
166+
fail-fast: false
167+
steps:
168+
- uses: actions/checkout@v4
169+
- name: Set up Python
170+
uses: actions/setup-python@v5
171+
with:
172+
python-version: 3.12
173+
- name: Install Hatch
174+
uses: pypa/hatch@install
175+
- name: Install calculix solver
176+
run: |
177+
sudo apt-get update -y -qq
178+
sudo apt-get install -qq -y calculix-ccx gmsh libglu1-mesa
179+
- name: Install dev dependencies
180+
run: |
181+
python -m pip install --upgrade pip
182+
pip install -U setuptools flit build twine hatchling
183+
- name: Create source distribution
184+
run: |
185+
python -m build -n -s
186+
- name: Build wheel
187+
run: |
188+
python -m build -n -w
189+
- name: Test sdist
190+
shell: bash
191+
run: |
192+
rm -rf ./pyccx
193+
pushd $HOME
194+
pip install $GITHUB_WORKSPACE/dist/*.tar.gz
195+
python -c "import pyccx; print(pyccx.__version__)"
196+
popd
197+
# don't run tests, we just want to know if the sdist can be installed
198+
pip uninstall -y pyccx
199+
git reset --hard HEAD
200+
- name: Twine check
201+
run: |
202+
twine check dist/*
203+
- name: Upload distributions
204+
uses: actions/upload-artifact@v4
205+
with:
206+
path: dist
207+
name: dist

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ PyCCX - a library for creating and running 3D FEA simulations using the opensour
2020
The aims of this project was to provide a simple framework for implemented 3D FEA Analysis using the opensource
2121
`Calculix <http://www.calculix.de>`_ solver.
2222
The analysis is complimented by use of the recent introduction of the
23-
`GMSH-SDK <http://https://gitlab.onelab.info/gmsh/gmsh/api>`_ , an extension to `GMSH <http://gmsh.info/>`_to provide
23+
`GMSH-SDK <http://https://gitlab.onelab.info/gmsh/gmsh/api>`_ , an extension to `GMSH <http://gmsh.info/>`_ to provide
2424
API bindings for different programming languages by the project authors to provide sophisticated 3D FEA mesh
2525
generation outside of the GUI implementation. This project aims to provide an integrated approach for generating full
2626
3D FEA analysis for use in research, development and prototyping in a Python environment. Along with setting up and
2727
processing the analysis, convenience functions are included.
2828

2929
The inception of this project was a result of finding no native Python/Matlab package available to perform full
3030
non-linear FEA analysis of 3D CAD models in order to prototype a concept related to 3D printing. The project aims to
31-
compliment the work of the`PyCalculix project <https://github.com/spacether/pycalculix>`_, which currently is limited
31+
compliment the work of the `PyCalculix project <https://github.com/spacether/pycalculix>`_, which currently is limited
3232
to providing capabilities to generate 2D Meshes and FEA analysis for 2D planar structures. The potential in the
3333
future is to provide a more generic extensible framework compatible with different opensource and commercial FEA
3434
solvers (e.g. Abaqus, Marc, Z88, Elmer).

pyccx/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
from .core import Connector, DOF, ElementSet, MeshSet, NodeSet, SurfaceSet
88
from .loadcase import LoadCaseType, LoadCase
99
from .results import ElementResult, NodalResult, ResultProcessor
10+
from .version import __version__

pyccx/mesh/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
from .mesher import MeshingAlgorithm2D, MeshingAlgorithm3D, RecombinationAlgorithm
1+
from .mesher import (Mesher,
2+
MeshingAlgorithm2D, MeshingAlgorithm3D, RecombinationAlgorithm)
23
from .mesh import getSurfaceFacesFromRegion, getNodesFromRegion, getNodesFromVolume, removeSurfaceMeshes
34
from .utils import Ent

pyproject.toml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ dependencies = [
3131
"matplotlib",
3232
"gmsh>4.13",
3333
"numpy>1.21",
34-
"colorlog"
34+
"colorlog",
35+
"setuptools"
3536
]
3637

3738
[project.optional-dependencies]
@@ -41,11 +42,26 @@ docs = [
4142
'jupyter',
4243
'sphinx_rtd_theme',
4344
'sphinx-paramlinks',
45+
'sphinx_automodapi',
46+
'sphinx_rtd_theme',
47+
'furo',
48+
'sphinx-autodoc-typehints',
49+
'autodocsumm',
50+
'm2r2',
51+
'docutils==0.20',
4452
'pypandoc',
4553
'autodocsumm',
54+
'mock',
4655
'matplotlib',
47-
'trimesh',
56+
'trimesh'
4857
]
58+
59+
tests = [
60+
"pytest",
61+
"pytest-cov",
62+
"coverage-badge"
63+
]
64+
4965
build = ["build", "hatchling", "requests", "twine"]
5066
codegen = ["pytest", "numpy"]
5167
lint = ["ruff", "pre-commit"]

0 commit comments

Comments
 (0)