Skip to content

Commit 546b333

Browse files
authored
Remove tox dependency (#882)
* Remove tox from GitHub workflow * Allow the `make` program to be set as a variable * Fix pathing in coverage reports * push even more configuration into the setup.cfg for the coverage runs * fix `make clean` target to clean up coverage files and not deal with .pyc files any more (since these are unlikely to be generated in the source tree) * Enable code coverage in ci (break up run function) * break out ci-prebuild and ci-postbuild commands, which ensures that the linter and check-manifest run _before_ builds and that coverage runs _after_ builds. * Add output to CMake if building w/ coverage * comment out tox configuration from setup.cfg * setup.py no longer checks coverage options * check if lcov is installed for lcov target * switch to using parallel mode for python coverage * add lcov target for C++ coverage report generation * use the GITHUB_WORKSPACE variable from github actions to specify where the build directory lives * apt-get instead of apt * delete tox setup.cfg block * Delete Cxx coverage option code from setup.py * Update readme with notes about C++ coverage
1 parent 2a33b58 commit 546b333

File tree

7 files changed

+125
-110
lines changed

7 files changed

+125
-110
lines changed

.github/workflows/python-package.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ jobs:
1717
matrix:
1818
python-version: [2.7, 3.7, 3.8]
1919

20+
env:
21+
OTIO_CXX_COVERAGE_BUILD: ON
22+
OTIO_CXX_BUILD_TMP_DIR: ${{ github.workspace }}/build
23+
2024
steps:
2125
- uses: actions/checkout@v2
2226
with:
@@ -25,12 +29,18 @@ jobs:
2529
uses: actions/setup-python@v2
2630
with:
2731
python-version: ${{ matrix.python-version }}
28-
- name: Install Tox and any other packages
32+
- name: Install build dependencies
33+
run: |
34+
sudo apt-get install lcov
35+
python -m pip install --upgrade pip setuptools wheel flake8>=3.5 check-manifest
36+
- name: Run check-manifest and lint check
37+
run: make ci-prebuild
38+
- name: Build and Install
2939
run: |
30-
pip install tox
31-
sudo apt install lcov
32-
- name: Build and Test
33-
run: tox -e py
40+
# compile and install into virtualenv/virtual machine (verbosely)
41+
pip install .[dev] -v
42+
- name: Run tests and generate coverage report
43+
run: make ci-postbuild
3444
- name: Upload coverage to Codecov
3545
uses: codecov/codecov-action@v1
3646
with:

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ if(OTIO_CXX_COVERAGE AND NOT MSVC)
142142
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
143143
# this causes cmake to produce file.gcno instead of file.cpp.gcno
144144
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
145+
message(STATUS "Building C++ with Coverage: ON")
146+
else()
147+
message(STATUS "Building C++ with Coverage: OFF")
145148
endif()
146149

147150
if(WIN32)

Makefile

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.PHONY: coverage test test_first_fail clean autopep8 lint doc-html \
2-
python-version
2+
python-version manifest lcov
33

44
# Special definition to handle Make from stripping newlines
55
define newline
@@ -19,10 +19,17 @@ $(ccred)You can install this and other development dependencies with$(newline)$(
1919
$(ccblue) pip install -e .[dev]$(newline)$(ccend)
2020
endef
2121

22+
# variables
23+
DOC_OUTPUT_DIR ?= /var/tmp/otio-docs
24+
MAKE_PROG ?= make
25+
26+
# external programs
2227
COV_PROG := $(shell command -v coverage 2> /dev/null)
28+
LCOV_PROG := $(shell command -v lcov 2> /dev/null)
2329
PYCODESTYLE_PROG := $(shell command -v pycodestyle 2> /dev/null)
2430
PYFLAKES_PROG := $(shell command -v pyflakes 2> /dev/null)
2531
FLAKE8_PROG := $(shell command -v flake8 2> /dev/null)
32+
CHECK_MANIFEST_PROG := $(shell command -v check-manifest 2> /dev/null)
2633
# AUTOPEP8_PROG := $(shell command -v autopep8 2> /dev/null)
2734
TEST_ARGS=
2835

@@ -42,35 +49,69 @@ test-core: python-version
4249

4350
test-contrib: python-version
4451
@echo "$(ccgreen)Running Contrib tests...$(ccend)"
45-
@make -C contrib/opentimelineio_contrib/adapters test VERBOSE=$(VERBOSE)
52+
@${MAKE_PROG} -C contrib/opentimelineio_contrib/adapters test VERBOSE=$(VERBOSE)
53+
54+
# CI
55+
###################################
56+
ci-prebuild: manifest lint
57+
ci-postbuild: coverage lcov
58+
###################################
4659

4760
python-version:
4861
@python --version
4962

5063
coverage: coverage-core coverage-contrib coverage-report
5164

5265
coverage-report:
53-
@${COV_PROG} combine .coverage contrib/opentimelineio_contrib/adapters/.coverage
66+
@${COV_PROG} combine .coverage* contrib/opentimelineio_contrib/adapters/.coverage*
5467
@${COV_PROG} report -m
5568

69+
# NOTE: coverage configuration is done in setup.cfg
70+
5671
coverage-core: python-version
5772
ifndef COV_PROG
5873
$(error $(newline)$(ccred) Coverage is not available please see:$(newline)$(ccend)\
5974
$(ccblue) https://coverage.readthedocs.io/en/coverage-4.2/install.html $(newline)$(ccend)\
6075
$(dev_deps_message))
6176
endif
62-
@${COV_PROG} run --source=opentimelineio -m unittest discover tests
77+
@${COV_PROG} run -p -m unittest discover tests
6378

6479
coverage-contrib: python-version
65-
@make -C contrib/opentimelineio_contrib/adapters coverage VERBOSE=$(VERBOSE)
80+
@${MAKE_PROG} -C contrib/opentimelineio_contrib/adapters coverage VERBOSE=$(VERBOSE)
81+
82+
lcov:
83+
ifndef LCOV_PROG
84+
$(error $(newline)$(ccred) lcov is not available please see:$(newline)$(ccend)\
85+
$(ccblue) https://github.com/linux-test-project/lcov/blob/master/README $(ccend))
86+
endif
87+
ifneq (OTIO_CXX_COVERAGE_BUILD, 'ON')
88+
$(warning $(newline)Warning: unless compiled with \
89+
OTIO_CXX_COVERAGE_BUILD="ON", C++ coverage will not work.)
90+
endif
91+
ifndef OTIO_CXX_BUILD_TMP_DIR
92+
$(error $(newline)Error: unless compiled with OTIO_CXX_BUILD_TMP_DIR, \
93+
C++ coverage will not work, because intermediate build products will \
94+
not be found.)
95+
endif
96+
lcov --capture -b . --directory ${OTIO_CXX_BUILD_TMP_DIR} \
97+
--output-file=${OTIO_CXX_BUILD_TMP_DIR}/coverage.info -q
98+
cat ${OTIO_CXX_BUILD_TMP_DIR}/coverage.info | sed "s/SF:.*src/SF:src/g"\
99+
> ${OTIO_CXX_BUILD_TMP_DIR}/coverage.filtered.info
100+
lcov --remove ${OTIO_CXX_BUILD_TMP_DIR}/coverage.filtered.info '/usr/*' \
101+
--output-file=${OTIO_CXX_BUILD_TMP_DIR}/coverage.filtered.info -q
102+
lcov --remove ${OTIO_CXX_BUILD_TMP_DIR}/coverage.filtered.info '*/deps/*' \
103+
--output-file=${OTIO_CXX_BUILD_TMP_DIR}/coverage.filtered.info -q
104+
lcov --list ${OTIO_CXX_BUILD_TMP_DIR}/coverage.filtered.info
66105

67106
# run all the unit tests, stopping at the first failure
68107
test_first_fail: python-version
69108
@python -m unittest discover -s tests --failfast
70109

71-
# remove pyc files
72110
clean:
73-
rm */*.pyc */*/*.pyc
111+
ifdef COV_PROG
112+
@${COV_PROG} erase
113+
endif
114+
@${MAKE_PROG} -C contrib/opentimelineio_contrib/adapters clean VERBOSE=$(VERBOSE)
74115

75116
# conform all files to pep8 -- WILL CHANGE FILES IN PLACE
76117
# autopep8:
@@ -99,6 +140,16 @@ ifndef FLAKE8_PROG
99140
endif
100141
@python -m flake8
101142

143+
manifest:
144+
ifndef CHECK_MANIFEST_PROG
145+
$(error $(newline)$(ccred)check-manifest is not available on $$PATH please see:$(newline)$(ccend)\
146+
$(ccblue) https://github.com/mgedmin/check-manifest#quick-start$(newline)$(ccend)\
147+
$(dev_deps_message))
148+
endif
149+
@check-manifest
150+
@echo "check-manifest succeeded"
151+
152+
102153
doc-model:
103154
@python src/py-opentimelineio/opentimelineio/console/autogen_serialized_datamodel.py --dryrun
104155

@@ -113,7 +164,6 @@ doc-plugins-update:
113164

114165
# generate documentation in html
115166
doc-html:
116-
@# if you just want to build the docs yourself outside of RTD and don't want
117-
@# to bother with tox, uncomment this line:
118-
@# cd docs ; sphinx-build -j8 -E -b html -d /var/tmp/otio-docs/doctrees . /var/tmp/otio-docs/html
119-
@tox -e build-docs
167+
@# if you just want to build the docs yourself outside of RTD
168+
@echo "Writing documentation to $(DOC_OUTPUT_DIR), set variable DOC_OUTPUT_DIR to change output directory."
169+
@cd docs ; sphinx-build -j8 -E -b html -d $(DOC_OUTPUT_DIR)/doctrees . $(DOC_OUTPUT_DIR)/html

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,30 @@ You can install development dependencies with `pip install .[dev]`
108108

109109
You can also install the PySide2 dependency with `pip install .[view]`
110110

111-
Currently the code base is written against python 2.7, python 3.6 and 3.7, in keeping
112-
with the pep8 style. We ask that before you submit a pull request, you:
111+
Currently the code base is written against python2.7, python3.7 and python3.8,
112+
in keeping with the pep8 style. We ask that before developers submit pull
113+
request, they:
113114

114115
- run `make test` -- to ensure that none of the unit tests were broken
115-
- run `make lint` -- to conform to pep8
116+
- run `make lint` -- to ensure that coding conventions conform to pep8
116117
- run `make coverage` -- to detect code which isn't covered
117118

118119
PEP8: https://www.python.org/dev/peps/pep-0008/
119120

121+
Additionaly, to reproduce CI failures regarding the file manifest, run:
122+
`make manifest` locally to run the python `check-manifest` program.
123+
124+
## C++ Coverage Builds
125+
126+
To enable C++ code coverage reporting via gcov/lcov for builds, set the
127+
following environment variables:
128+
129+
- `OTIO_CXX_COVERAGE_BUILD=ON`
130+
- `OTIO_CXX_BUILD_TMP_DIR=path/to/build/dir`
131+
132+
When building/installing through `pip`/`setup.py`, these variables must be set
133+
before running the install command (`pip install .` for example).
134+
120135
License
121136
-------
122137
OpenTimelineIO is open source software. Please see the [LICENSE.txt](LICENSE.txt) for details.

contrib/opentimelineio_contrib/adapters/Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ ifeq ($(VERBOSE), 1)
77
TEST_ARGS:=-v
88
endif
99

10-
1110
test:
1211
@python -m unittest discover tests $(TEST_ARGS)
1312

@@ -16,7 +15,13 @@ ifndef COV_PROG
1615
$(error "coverage is not available please see: "\
1716
"https://coverage.readthedocs.io/en/coverage-4.2/install.html")
1817
endif
19-
@${COV_PROG} run -m unittest discover tests
18+
@${COV_PROG} run --rcfile=../../../setup.cfg -p -m unittest discover tests
2019

2120
coverage-report: coverage
2221
@${COV_PROG} report -m
22+
23+
clean:
24+
ifdef COV_PROG
25+
@${COV_PROG} erase
26+
endif
27+

setup.cfg

Lines changed: 12 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -30,78 +30,6 @@ ignore =
3030
W504
3131

3232

33-
###############################################################################
34-
# TOX
35-
###############################################################################
36-
[tox:tox]
37-
envlist = clean,py27,py37,py38,stats
38-
skip_missing_interpreters = true
39-
40-
[testenv]
41-
# C++ coverage means that compiling will produce .gcno and running .gcda files
42-
# putting them all in this directory makes it predictable where to find them
43-
# in order to build coverage reports later
44-
cmake_build_dir = {toxworkdir}/build-{envname}
45-
# the setup.py listens for these environment variables so that they don't have
46-
# to be passed via commandline arguments.
47-
#
48-
# tox passes ALL commandline arguments to ALL pip commands (including
49-
# dependencies) which means you can't have custom flags, or your dependencies
50-
# will break when installing them.
51-
setenv =
52-
OTIO_CXX_COVERAGE_BUILD = 1
53-
OTIO_CXX_BUILD_TMP_DIR = {[testenv]cmake_build_dir}
54-
# these dependencies are similar to the .[dev] option.
55-
deps =
56-
coverage
57-
check-manifest
58-
flake8
59-
Pillow
60-
mock
61-
commands_pre=
62-
# remove any old cmakecache file just in case you're working locally
63-
rm -f {[testenv]cmake_build_dir}/CMakeCache.txt
64-
whitelist_externals=
65-
rm
66-
lcov
67-
commands =
68-
check-manifest
69-
python -m flake8
70-
coverage run -a -m unittest discover tests -vvv
71-
coverage run -a -m unittest discover contrib/opentimelineio_contrib/adapters/tests -vvv
72-
coverage report
73-
lcov --capture -b {toxinidir} --directory {[testenv]cmake_build_dir} --output-file {[testenv]cmake_build_dir}/coverage.info -q
74-
# remove coverage of dependency files
75-
lcov --remove {[testenv]cmake_build_dir}/coverage.info '/usr/*' --output-file {[testenv]cmake_build_dir}/coverage.info -q
76-
lcov --remove {[testenv]cmake_build_dir}/coverage.info '*/deps/*' --output-file {toxinidir}/coverage.info -q
77-
lcov --list {toxinidir}/coverage.info # debug info
78-
79-
[testenv:clean]
80-
commands =
81-
coverage erase
82-
rm {[testenv]cmake_build_dir} -f coverage.info
83-
84-
[testenv:stats]
85-
commands =
86-
coverage report
87-
coverage html
88-
lcov --list {toxinidir}/coverage.info # debug info
89-
90-
[testenv:build-docs]
91-
changedir = docs
92-
deps =
93-
sphinx
94-
sphinx-rtd-theme
95-
recommonmark
96-
commands =
97-
sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
98-
99-
[testenv:dist]
100-
skip_install = True
101-
deps = wheel
102-
commands =
103-
python setup.py bdist_wheel --universal
104-
10533
###############################################################################
10634
# Check-Manifest
10735
###############################################################################
@@ -121,6 +49,18 @@ ignore-bad-ideas =
12149
###############################################################################
12250
[coverage:run]
12351
branch = True
52+
source =
53+
opentimelineio
54+
opentimelineio_contrib
55+
./tests
56+
57+
[coverage:paths]
58+
otio =
59+
src/py-opentimelineio/opentimelineio
60+
*site-packages/opentimelineio
61+
contrib =
62+
contrib/opentimelineio_contrib
63+
*site-packages/opentimelineio_contrib
12464

12565
[coverage:report]
12666
include =*

setup.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ def cmake_generate():
9797
if sys.maxsize > 2**32:
9898
cmake_args += ['-A', 'x64']
9999

100+
if _ctx.cxx_coverage and not os.environ.get("OTIO_CXX_BUILD_TMP_DIR"):
101+
raise RuntimeError(
102+
"C++ code coverage requires that both OTIO_CXX_COVERAGE_BUILD=ON "
103+
"and OTIO_CXX_BUILD_TMP_DIR are specified as environment "
104+
"variables, otherwise coverage cannot be generated."
105+
)
106+
100107
if _ctx.cxx_coverage:
101108
cmake_args += ['-DOTIO_CXX_COVERAGE=1']
102109

@@ -156,30 +163,15 @@ def __init__(self, name):
156163

157164

158165
class OTIO_build_ext(setuptools.command.build_ext.build_ext):
159-
# At the moment, we've only got code coverage set up for Linux, using gcov,
160-
# which is specific to gcc.
161-
if platform.system() == "Linux":
162-
user_options = setuptools.command.build_ext.build_ext.user_options + [
163-
(
164-
'cxx-coverage',
165-
None,
166-
'Enable code coverage for C++ code. NOTE: you will likely want to'
167-
' also set the build_tmp directory to something that does not get '
168-
'cleaned up.',
169-
)
170-
]
171-
172166
def initialize_options(self):
173167
self.cxx_coverage = False
174168
setuptools.command.build_ext.build_ext.initialize_options(self)
175169

176170
def run(self):
177-
# because tox passes all commandline arguments to _all_ things being
178-
# installed by setup.py (including dependencies), environment variables
179171
_ctx.cxx_coverage = (
180172
self.cxx_coverage is not False
181173
or bool(os.environ.get("OTIO_CXX_COVERAGE_BUILD"))
182-
) and platform.system() == "Linux"
174+
)
183175

184176
self.build()
185177

@@ -417,9 +409,9 @@ def test_otio():
417409
},
418410
extras_require={
419411
'dev': [
412+
'check-manifest',
420413
'flake8>=3.5',
421414
'coverage>=4.5',
422-
'tox>=3.0',
423415
'urllib3>=1.24.3'
424416
],
425417
'view': [

0 commit comments

Comments
 (0)