Skip to content

Commit

Permalink
Adapt to newer versions of Robot Framework and KiCad, updating FOR lo…
Browse files Browse the repository at this point in the history
…op syntax as well as deprecating LM555.

Ensure Python3 is used.
Stop building for Python 2.7
Fix code smell (is not -> !=).
Update security token for GH releases.
  • Loading branch information
madworx committed Sep 12, 2020
1 parent e993271 commit a231412
Show file tree
Hide file tree
Showing 8 changed files with 293 additions and 415 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ addons:
organization: madworx

python:
- "2.7"
- "3.7"

sudo: required
Expand All @@ -28,7 +27,7 @@ script:
deploy:
- provider: releases
api_key:
secure: e7LRwziBqApiSkXYmlMQinSZfds/ksRkbq9zsAkXPue7LY2Ew+SdmreQbiC/axducyoPMYSr7IrmvH+1QQW0ciBmmzWb1kIPi0F60+noEbwoRrn3UuF3LLSN57X67kP5fh9cnz54+DsSax+8t6ccqg/tIM5Bk9baMTXxNLh3TzxbED1O/foWSJ0SzSINSMr+4YfT/IjVQPU/1LODSwlQYbuJxgWy0Du8GvJzC5KElR0LCUkLuAS74GXm+8vcebI4cp+cOs/QLub1jPyZNSsJK41lZpUUU1VnZe9LIvML0DsBVmJg23z5gFAsf5D3fhmRKoVbCQhuidaM/Fogk57tOj+gBuucCO3GiPeE3phZfBOVDqNhr2immfho5Ves0sVNvt+yPo2gLX1S5svLP3LpsNHtTMmJ23EeyA0wHzt3YXYxkbVsLxY9OWc9HUCwVPZvB3Wr3e5OiVRHWPnKTRKteA/wdJHjYE61GJb1ppZZJDY42s1p3J1Xgm9c5v5zJ3dJe543BZ81pcbqUrAxmuMGmQdYeFVRiLmyaaMrySAewLb6PJ45ja+BNrJMOKFYdH3jiavcevglD46bN4XPWhnFkOyB28hwwMuwM0C9tfhHPLGpXhJiJIKV6diGJzPdSIlp55tKfU8IN+Ez2dRkfq8H+2FwJ1NRvlnRFW4Np3el25M=
secure: C1kLaMxE7K7yx4biiZednKLA5TQNUG6Rt+oqQZLCuaXuzYJi2jMYH1XENoB73cpi321NNGMEo8WqmiZDVQsN96ulv3OYDGK2VAZ6nJcM5HDDCnj04l1hUydXh3JinchY0Z4Tqn6XeOoWsg0iDrMVCxp3O/NbhHEUtmmUjzXRaBJHorEZ7vtadmik3YzZgyqSeOLlDEs9xBFbTPK2gNPYFdYK0z+va0WDPAx3H5oXGUa5Puz3v+T0ZFzqWWg6Nc55K6eBI96pzhEw1xdVO7shM0f38QaUUTI+tDw49XV4O/Q7S1u9T4Y/lZP3QqjwqdG6oG61n8gPb8b1uhP1739xnRHhKs8p9iugiYMva/+AQFr2QYp6D5GwCfCr0LB1lxzq1Xxf3vU+E4jEkvljCb64Unn0AGt9TQOINHIolT7GssYlXyFmKW5u6FnPUsROFQPsjA8z5CpDNAkJT7pakikyHKtrdpCjDk51RptQPt6qN60z//ry2MOHv0VQS7qznOl21RNCL3EGeulpN38Sb9hGUcAerbnfo1DhFTf4lUy/E9hIqLcEzDzGh7ojlanbBG3fIaVeHSr8FDFlgZYTExfb4awx+JXkjeN7y6FaKik2HUyxVt81wGXDHml734f8P/reSNVwV/FfS2JSf96crm4dMrr8MkfHL3jPsUKWfxbN+58=
file_glob: true
file:
- build/KiCadLibrary*.html
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ LABEL org.label-schema.vcs-url="https://github.com/madworx/robotframework-kicadl
SHELL [ "/bin/bash", "-c" ]

RUN if [[ "${PYTHON_VERSION}" == 3* ]] ; then PYPKG="python3" ; KIREPO="5.1" ; else PYPKG="python" ; KIREPO="5" ; fi \
&& echo "Adding 'ppa:ja-reynaud/kicad-${KIREPO}' with '${PYPKG}'..." \
&& echo "Adding 'ppa:kicad/kicad-${KIREPO}-releases' with '${PYPKG}'..." \
&& apt-get -qq update < /dev/null > ${DEBUG_APT} \
&& apt-get -qq install --no-install-recommends --assume-yes software-properties-common locales make < /dev/null > ${DEBUG_APT} \
&& echo "C.UTF-8 UTF-8" > /etc/locale.gen && locale-gen \
&& add-apt-repository -y ppa:js-reynaud/kicad-${KIREPO} < /dev/null > ${DEBUG_APT} \
&& add-apt-repository -y ppa:kicad/kicad-${KIREPO}-releases < /dev/null > ${DEBUG_APT} \
&& dpkg --purge software-properties-common < /dev/null > ${DEBUG_APT} \
&& apt-get -qq update < /dev/null > ${DEBUG_APT} \
&& apt-get install --assume-yes --no-install-recommends "${PYPKG}" "${PYPKG}-pip" < /dev/null > ${DEBUG_APT} \
Expand Down
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
SHELL = bash
PYTHON_VERSION = 3

all: tests doc

setup:

tests: setup
LC_CTYPE=C.UTF8 python setup.py test
LC_CTYPE=C.UTF8 python3 setup.py test

dist: clean tests
python setup.py sdist bdist_wheel
python3 setup.py sdist bdist_wheel

docker:
export KICADLIBRARY_VERSION="$$(python setup.py --get-version)" ; \
export KICADLIBRARY_VERSION="$$(python3 setup.py --get-version)" ; \
export VCS_REF="$$(git rev-parse --short HEAD)" ; \
export PYTHON_VERSION=$(PYTHON_VERSION) ; \
docker build -t "madworx/robotframework-kicadlibrary:$${KICADLIBRARY_VERSION/+/-}" --build-arg=KICADLIBRARY_VERSION --build-arg=VCS_REF --build-arg=PYTHON_VERSION .

docker-extract-artifacts:
export KICADLIBRARY_VERSION="$$(python setup.py --get-version)" ; \
export KICADLIBRARY_VERSION="$$(python3 setup.py --get-version)" ; \
docker run --rm --entrypoint /bin/tar "madworx/robotframework-kicadlibrary:$${KICADLIBRARY_VERSION/+/-}" cf - build | tar xvf -

setup-environment:
pip install . --user
pip install coverage --user

doc:
python setup.py build_rf_docs
python3 setup.py build_rf_docs

clean:
find . -type f \( -name '*.pyc' -o -name coverage.xml -o -name .coverage -o -name nosetests.xml -o -name pylint-report.txt -o -name '*~' -o -name '#*#' \) -delete
Expand Down
42 changes: 23 additions & 19 deletions examples/identity-comparator/example.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,44 @@ Suite Setup Setup Suite
*** Test cases ****
Reference pins should be correctly connected to data bus
[Documentation] The (P0--P7) pins on the 74688 are supposed
\ ... to be connected to the main data bus' d0-d7.
:FOR ${identity_comparator} IN @{identity_comparator_list}
\ Reference Pins Should Be Connected To Correct Net
\ ... ${identity_comparator} P([0-9]+) d([0-9]+)
... to be connected to the main data bus' d0-d7.
FOR ${identity_comparator} IN @{identity_comparator_list}
Reference Pins Should Be Connected To Correct Net
... ${identity_comparator} P([0-9]+) d([0-9]+)
END

VDD Pins should be connected to VDD
[Documentation] Modules with schematic pins named VDD should
\ ... be connected to VDD net.
... be connected to VDD net.
${components}= Find Modules value=.*
:FOR ${component} IN @{components}
\ Reference Pins Should Be Connected To Correct Net
\ ... ${component} VCC VCC
FOR ${component} IN @{components}
Reference Pins Should Be Connected To Correct Net
... ${component} VCC VCC
END

GND Pins should be connected to GND
[Documentation] Modules with schematic pins named GND should
\ ... be connected to GND net.
... be connected to GND net.
${components}= Find Modules value=.*
:FOR ${component} IN @{components}
\ Reference Pins Should Be Connected To Correct Net
\ ... ${component} GND GND
FOR ${component} IN @{components}
Reference Pins Should Be Connected To Correct Net
... ${component} GND GND
END

*** Keywords ***
Reference Pins Should Be Connected To Correct Net
[Arguments] ${ic} ${pins_regexp} ${pads_regexp}
[Documentation] Ensure that the pads on the given module (matching
\ ... ${pads_regexp}) align with the schematics reference
\ ... pins (matchting ${pins_regexp}).
... ${pads_regexp}) align with the schematics reference
... pins (matchting ${pins_regexp}).
${pins}= Get Component Pins For Module ${ic} ${pins_regexp}
${pads}= Get Pad Netnames For Module ${ic}
:FOR ${pin} IN @{pins}
\ ${pin_id}= Should Match Regexp ${pins["${pin}"]["name"]} ${pins_regexp}
\ ${pad_id}= Should Match Regexp ${pads["${pin}"]} ${pads_regexp}
\ Should Be Equal ${pin_id[1]} ${pad_id[1]}
FOR ${pin} IN @{pins}
${pin_id}= Should Match Regexp ${pins["${pin}"]["name"]} ${pins_regexp}
${pad_id}= Should Match Regexp ${pads["${pin}"]} ${pads_regexp}
Should Be Equal ${pin_id[1]} ${pad_id[1]}
END

Setup Suite
@{identity_comparator_list}= Find Modules value=74LS688
Set Suite Variable @{identity_comparator_list}
Set Suite Variable @{identity_comparator_list}
3 changes: 1 addition & 2 deletions src/KiCadLibrary/KiCadLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError
from robot.api import logger

# pylint: disable=relative-import
from .kicad_library_utils.schlib import schlib
from .kicad_library_utils.sch import sch

Expand Down Expand Up @@ -448,7 +447,7 @@ def matching_modules_should_have_same_pads_and_netnames(self, modules=None,

for mod in modlist:
# All matching modules should have the same pin-count:
if mod.GetPadCount() is not len(aggregates.keys()):
if mod.GetPadCount() != len(aggregates.keys()):
ret = False
logger.error("Module {0} has unexpected pad count: {1} (should be {2})".
format(mod, mod.GetPadCount(), len(aggregates.keys())))
Expand Down
37 changes: 19 additions & 18 deletions src/tests/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ def test_get_valid_module_pins_with_loaded_library_should_work():
assert bool(pins)

def test_module_intersection():
list1 = lib.find_modules(reference="U1")
list2 = lib.find_modules(reference="nonexistent")
assert lib.intersect_modules_by_reference(list1, list2) == list1
assert lib.intersect_modules_by_reference(list2, list1) == list1
assert lib.intersect_modules_by_reference(list1, list1) == list1
lst1 = lib.find_modules(reference="U1")
lst2 = lib.find_modules(reference="nonexistent")
assert lib.intersect_modules_by_reference(lst1, lst2) == lst1
assert lib.intersect_modules_by_reference(lst2, lst1) == lst1
assert lib.intersect_modules_by_reference(lst1, lst1) == lst1

def test_module_complement():
list1 = lib.find_modules(reference="U.+")
list2 = lib.find_modules(reference="nonexistent")
list3 = lib.find_modules(reference="U3")
assert len(list1) == 3
assert bool(list2) is False
assert len(list3) == 1
assert lib.complement_modules_by_reference(list1, list2) == list1
assert lib.complement_modules_by_reference(list2, list1) == []
assert lib.complement_modules_by_reference(list1, list1) == []
c = lib.complement_modules_by_reference(list1, list3)
lst1 = lib.find_modules(reference="U.+")
lst2 = lib.find_modules(reference="nonexistent")
lst3 = lib.find_modules(reference="U3")
assert len(lst1) == 3
assert bool(lst2) is False
assert len(lst3) == 1
assert lib.complement_modules_by_reference(lst1, lst2) == lst1
assert lib.complement_modules_by_reference(lst2, lst1) == []
assert lib.complement_modules_by_reference(lst1, lst1) == []
c = lib.complement_modules_by_reference(lst1, lst3)
assert len(c) == 2
assert ((c[0].GetReference() == 'U2' and c[1].GetReference() == 'U1')
or (c[0].GetReference() == 'U1' and c[1].GetReference() == 'U2'))
Expand All @@ -50,8 +50,9 @@ def test_module_pads_should_have_same_netnames_should_fail():
lib.matching_modules_should_have_same_pads_and_netnames(reference=r'U.*')

def test_module_pads_should_have_same_netnames_should_work():
lib.matching_modules_should_have_same_pads_and_netnames(value='LM555')
lib.modules_should_have_same_pads_and_netnames(value='LM555')
assert len(lib.find_modules(value='NA555P')) == 2
lib.matching_modules_should_have_same_pads_and_netnames(value='NA555P')
lib.modules_should_have_same_pads_and_netnames(value='NA555P')

def test_find_modules_by_netname():
l = lib.find_modules(pad_netname='CV')
Expand All @@ -66,7 +67,7 @@ def test_edge_cuts_grid_should_work():

def test_module_pads_should_be_on_grid_should_fail():
with pytest.raises(AssertionError, match=r'not on grid'):
lib.module_pads_should_be_on_grid("50mil", reference=r'.*')
lib.module_pads_should_be_on_grid("127mil", reference=r'.*')

def test_module_pads_should_be_on_grid_should_work():
lib.module_pads_should_be_on_grid("25mil", reference=r'.*')
Expand Down
Loading

0 comments on commit a231412

Please sign in to comment.