Skip to content

Commit

Permalink
Fix Travis CI builds
Browse files Browse the repository at this point in the history
Make user for docker image configurable
Upgrade test dependencies
Add .travis.yml and basic FreeCAD integration sanity test
  • Loading branch information
gbroques committed Jun 8, 2020
1 parent bbdd63e commit 406597f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 8 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: python
python:
- '3.6'
services:
- docker
install:
- docker build -t ose-workbench-platform --build-arg USER=$USER --build-arg UID=$(id -u) --build-arg GID=$(id -g) ./osewb
- docker run --name osewb --detach --volume $(pwd):/var/app ose-workbench-platform
script:
- docker exec -it osewb pytest --cov osewb/ test/
after_success:
- docker exec -e TRAVIS="$TRAVIS" -e TRAVIS_JOB_ID="$TRAVIS_JOB_ID" -e TRAVIS_BRANCH="$TRAVIS_BRANCH" -e TRAVIS_PULL_REQUEST="$TRAVIS_PULL_REQUEST" osewb coveralls
12 changes: 8 additions & 4 deletions osewb/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
FROM ubuntu:18.04

RUN useradd -m docker --uid=1000
# Set password of docker user to "docker"
RUN echo "docker:docker" | chpasswd
ARG USER=docker
ARG UID=1000
ARG GID=1000
ARG PASSWORD=docker

RUN useradd -m $USER --uid=$UID
RUN echo "$USER:$PASSWORD" | chpasswd

RUN apt-get update && \
apt-get install --yes --no-install-recommends \
Expand Down Expand Up @@ -44,7 +48,7 @@ ENV PYTHONPATH=/usr/lib/freecad/lib/
RUN ln -s /usr/lib/freecad/Mod /usr/lib/freecad-python3/Mod
RUN ln -s /usr/lib/freecad/Ext /usr/lib/freecad-python3/Ext

USER 1000:1000
USER $UID:$GID

# Keep container running
CMD tail -f /dev/null
8 changes: 4 additions & 4 deletions osewb/test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage==5.0.3
coveralls==1.10.0
pytest==4.6.9
pytest-cov==2.8.1
coverage==5.1
coveralls==2.0.0
pytest==5.4.3
pytest-cov==2.9.0
Empty file added test/__init__.py
Empty file.
22 changes: 22 additions & 0 deletions test/freecad_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import unittest

# Need to import FreeCAD
import FreeCAD as App
import Part


class FreeCADTest(unittest.TestCase):
"""
Sanity test for FreeCAD integration.
"""

def test_freecad(self):
box = Part.makeBox(10, 10, 10)
self.assertEqual(len(box.Faces), 6)
self.assertAlmostEqual(box.Volume, 1000)
self.assertAlmostEqual(box.Area, 600)
self.assertEqual(box.TypeId, 'Part::TopoShape')


if __name__ == '__main__':
unittest.main()

0 comments on commit 406597f

Please sign in to comment.