Skip to content

Commit

Permalink
Fix continuous integration (again) (#1173)
Browse files Browse the repository at this point in the history
* Update Python versions tested against, and stop using deprecated setuptools test feature.
  • Loading branch information
glados-verma authored Oct 4, 2024
1 parent ecd0690 commit 7a5acb8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 56 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9"]
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
Expand All @@ -44,6 +44,8 @@ jobs:
sudo cp -r include/. /usr/include && sudo chmod -R +r /usr/include/google
protoc --version
sudo apt-get install -y libusb-1.0-0-dev libprotobuf-dev swig libevent-dev
- name: Build protobufs
run: python setup.py build_proto
- name: Test with tox
run: tox
- name: Publish to Coveralls with GitHub Action
Expand Down
46 changes: 1 addition & 45 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from distutils.cmd import Command
from setuptools import find_packages
from setuptools import setup
from setuptools.command.test import test


class CleanCommand(clean):
Expand Down Expand Up @@ -145,41 +144,6 @@ def run(self):
]


class PyTestCommand(test): # pylint: disable=missing-class-docstring
# Derived from
# https://github.com/chainreactionmfg/cara/blob/master/setup.py
user_options = [
('pytest-args=', None, 'Arguments to pass to py.test'),
('pytest-cov=', None, 'Enable coverage. Choose output type: '
'term, html, xml, annotate, or multiple with comma separation'),
]

def initialize_options(self):
test.initialize_options(self)
self.pytest_args = ['test']
self.pytest_cov = None

def finalize_options(self):
test.finalize_options(self)
self.test_args = []
self.test_suite = True

def run_tests(self):
self.run_command('build_proto')

import pytest # pylint: disable=g-import-not-at-top
cov = []
if self.pytest_cov is not None:
outputs = []
for output in self.pytest_cov.split(','):
outputs.extend(['--cov-report', output])
cov = ['--cov', 'openhtf'] + outputs

sys.argv = [sys.argv[0]]
print('invoking pytest.main with %s' % (self.pytest_args + cov))
sys.exit(pytest.main(self.pytest_args + cov))


_README_PATH = os.path.join(
os.path.dirname(os.path.realpath(__file__)), 'README.md')
with open(_README_PATH, 'rb') as fp:
Expand All @@ -202,11 +166,10 @@ def run_tests(self):
'output/web_gui/dist/img/*', 'output/web_gui/*.*'
]
},
python_requires='>=3.7',
python_requires='>=3.9',
cmdclass={
'build_proto': BuildProtoCommand,
'clean': CleanCommand,
'test': PyTestCommand,
},
install_requires=INSTALL_REQUIRES,
extras_require={
Expand All @@ -218,11 +181,4 @@ def run_tests(self):
'serial_collection_plug': ['pyserial>=3.3.0',],
'examples': ['pandas>=0.22.0',],
},
tests_require=[
'absl-py>=0.10.0',
'pandas>=0.22.0',
'numpy',
'pytest>=2.9.2',
'pytest-cov>=2.2.1',
],
)
5 changes: 1 addition & 4 deletions test_reqs.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
pytest
pytest-cov

# We also want everything as specified by setup.py
# We want everything as specified by setup.py
-e .
17 changes: 11 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
[tox]
envlist = py37,py38,py39
envlist = py39,py310,py311

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.11: py311

[testenv]
deps = -r{toxinidir}/test_reqs.txt
commands = {envbindir}/python setup.py build_proto
{envbindir}/python setup.py test --pytest-cov=term-missing,lcov
deps =
-r{toxinidir}/test_reqs.txt
absl-py>=0.10.0
pandas>=0.22.0
numpy
pytest>=2.9.2
pytest-cov>=2.2.1
commands = pytest test --cov openhtf --cov-report=term-missing --cov-report=lcov
# usedevelop causes tox to skip using .tox/dist/openhtf*.zip
# Instead, it does 'python setup.py develop' which only adds openhtf/ to the
# path.
Expand Down

0 comments on commit 7a5acb8

Please sign in to comment.