Chandan Singh pushed to branch chandan/toxify at BuildStream / buildstream
Commits:
-
7557b7fd
by Chandan Singh at 2019-01-03T02:52:07Z
-
e84d5c41
by Tristan Van Berkom at 2019-01-03T02:52:07Z
-
5dbad3b9
by Chandan Singh at 2019-01-03T02:52:07Z
-
26fe7560
by Chandan Singh at 2019-01-03T02:52:07Z
-
b730b3d1
by Chandan Singh at 2019-01-03T02:52:07Z
-
12dbef08
by Chandan Singh at 2019-01-03T02:52:07Z
11 changed files:
- .gitlab-ci.yml
- CONTRIBUTING.rst
- MANIFEST.in
- setup.py
- dev-requirements.in → tools/dev-requirements.in
- dev-requirements.txt → tools/dev-requirements.txt
- plugin-requirements.in → tools/plugin-requirements.in
- plugin-requirements.txt → tools/plugin-requirements.txt
- requirements.in → tools/requirements.in
- requirements.txt → tools/requirements.txt
- tox.ini
Changes:
1 |
-image: buildstream/testsuite-debian:9-06bab030-b848172c
|
|
1 |
+image: buildstream/testsuite-debian:9-5da27168-32c47d1c
|
|
2 | 2 |
|
3 | 3 |
cache:
|
4 | 4 |
key: "$CI_JOB_NAME-"
|
... | ... | @@ -13,7 +13,7 @@ stages: |
13 | 13 |
variables:
|
14 | 14 |
PYTEST_ADDOPTS: "--color=yes"
|
15 | 15 |
INTEGRATION_CACHE: "${CI_PROJECT_DIR}/cache/integration-cache"
|
16 |
- TEST_COMMAND: 'python3 setup.py test --index-url invalid://uri --addopts --integration'
|
|
16 |
+ TEST_COMMAND: "tox -- --color=yes --integration"
|
|
17 | 17 |
|
18 | 18 |
#####################################################
|
19 | 19 |
# Prepare stage #
|
... | ... | @@ -68,10 +68,6 @@ source_dist: |
68 | 68 |
- mount
|
69 | 69 |
- df -h
|
70 | 70 |
|
71 |
- # Unpack
|
|
72 |
- - cd dist && ./unpack.sh
|
|
73 |
- - cd buildstream
|
|
74 |
- |
|
75 | 71 |
script:
|
76 | 72 |
- useradd -Um buildstream
|
77 | 73 |
- chown -R buildstream:buildstream .
|
... | ... | @@ -83,7 +79,7 @@ source_dist: |
83 | 79 |
after_script:
|
84 | 80 |
# Collect our reports
|
85 | 81 |
- mkdir -p ${COVERAGE_DIR}
|
86 |
- - cp dist/buildstream/.coverage ${COVERAGE_DIR}/coverage."${CI_JOB_NAME}"
|
|
82 |
+ - cp .coverage ${COVERAGE_DIR}/coverage."${CI_JOB_NAME}"
|
|
87 | 83 |
except:
|
88 | 84 |
- schedules
|
89 | 85 |
artifacts:
|
... | ... | @@ -91,19 +87,19 @@ source_dist: |
91 | 87 |
- ${COVERAGE_DIR}
|
92 | 88 |
|
93 | 89 |
tests-debian-9:
|
94 |
- image: buildstream/testsuite-debian:9-06bab030-b848172c
|
|
90 |
+ image: buildstream/testsuite-debian:9-5da27168-32c47d1c
|
|
95 | 91 |
<<: *tests
|
96 | 92 |
|
97 | 93 |
tests-fedora-27:
|
98 |
- image: buildstream/testsuite-fedora:27-06bab030-b848172c
|
|
94 |
+ image: buildstream/testsuite-fedora:27-5da27168-32c47d1c
|
|
99 | 95 |
<<: *tests
|
100 | 96 |
|
101 | 97 |
tests-fedora-28:
|
102 |
- image: buildstream/testsuite-fedora:28-06bab030-b848172c
|
|
98 |
+ image: buildstream/testsuite-fedora:28-5da27168-32c47d1c
|
|
103 | 99 |
<<: *tests
|
104 | 100 |
|
105 | 101 |
tests-ubuntu-18.04:
|
106 |
- image: buildstream/testsuite-ubuntu:18.04-06bab030-b848172c
|
|
102 |
+ image: buildstream/testsuite-ubuntu:18.04-5da27168-32c47d1c
|
|
107 | 103 |
<<: *tests
|
108 | 104 |
|
109 | 105 |
overnight-fedora-28-aarch64:
|
... | ... | @@ -120,7 +116,7 @@ overnight-fedora-28-aarch64: |
120 | 116 |
tests-unix:
|
121 | 117 |
# Use fedora here, to a) run a test on fedora and b) ensure that we
|
122 | 118 |
# can get rid of ostree - this is not possible with debian-8
|
123 |
- image: buildstream/testsuite-fedora:27-06bab030-b848172c
|
|
119 |
+ image: buildstream/testsuite-fedora:27-5da27168-32c47d1c
|
|
124 | 120 |
<<: *tests
|
125 | 121 |
variables:
|
126 | 122 |
BST_FORCE_BACKEND: "unix"
|
... | ... | @@ -140,7 +136,7 @@ tests-unix: |
140 | 136 |
|
141 | 137 |
tests-fedora-missing-deps:
|
142 | 138 |
# Ensure that tests behave nicely while missing bwrap and ostree
|
143 |
- image: buildstream/testsuite-fedora:28-06bab030-b848172c
|
|
139 |
+ image: buildstream/testsuite-fedora:28-5da27168-32c47d1c
|
|
144 | 140 |
<<: *tests
|
145 | 141 |
|
146 | 142 |
script:
|
... | ... | @@ -158,20 +154,18 @@ tests-fedora-missing-deps: |
158 | 154 |
|
159 | 155 |
# Automatically build documentation for every commit, we want to know
|
160 | 156 |
# if building documentation fails even if we're not deploying it.
|
161 |
-# Note: We still do not enforce a consistent installation of python3-sphinx,
|
|
162 |
-# as it will significantly grow the backing image.
|
|
163 | 157 |
docs:
|
164 | 158 |
stage: test
|
159 |
+ variables:
|
|
160 |
+ BST_FORCE_SESSION_REBUILD: 1
|
|
161 |
+ before_script:
|
|
162 |
+ # FIXME: this deps should ideally be provided by the testsuite images
|
|
163 |
+ - pip3 install tox
|
|
164 |
+ - |
|
|
165 |
+ bash -c '( apt-get update && apt-get install -y python3-dev gcc libcairo2-dev pkg-config libgirepository1.0-dev ) || ( dnf install -y gcc python3-devel gobject-introspection-devel glib2-devel cairo-gobject-devel )'
|
|
165 | 166 |
script:
|
166 |
- - export BST_SOURCE_CACHE="$(pwd)/cache/integration-cache/sources"
|
|
167 |
- # Currently sphinx_rtd_theme does not support Sphinx >1.8, this breaks search functionality
|
|
168 |
- - pip3 install sphinx==1.7.9
|
|
169 |
- - pip3 install sphinx-click
|
|
170 |
- - pip3 install sphinx_rtd_theme
|
|
171 |
- - cd dist && ./unpack.sh && cd buildstream
|
|
172 |
- - make BST_FORCE_SESSION_REBUILD=1 -C doc
|
|
173 |
- - cd ../..
|
|
174 |
- - mv dist/buildstream/doc/build/html public
|
|
167 |
+ - env BST_SOURCE_CACHE="$(pwd)/cache/integration-cache/sources" tox -e docs
|
|
168 |
+ - mv doc/build/html public
|
|
175 | 169 |
except:
|
176 | 170 |
- schedules
|
177 | 171 |
artifacts:
|
... | ... | @@ -275,6 +269,7 @@ coverage: |
275 | 269 |
coverage: '/TOTAL +\d+ +\d+ +(\d+\.\d+)%/'
|
276 | 270 |
script:
|
277 | 271 |
- cd dist && ./unpack.sh && cd buildstream
|
272 |
+ - pip3 install -r tools/requirements.txt
|
|
278 | 273 |
- pip3 install --no-index .
|
279 | 274 |
- mkdir report
|
280 | 275 |
- cd report
|
... | ... | @@ -1222,27 +1222,13 @@ For further information about using the reStructuredText with sphinx, please see |
1222 | 1222 |
|
1223 | 1223 |
Building Docs
|
1224 | 1224 |
~~~~~~~~~~~~~
|
1225 |
-The documentation build is not integrated into the ``setup.py`` and is
|
|
1226 |
-difficult (or impossible) to do so, so there is a little bit of setup
|
|
1227 |
-you need to take care of first.
|
|
1228 |
- |
|
1229 |
-Before you can build the BuildStream documentation yourself, you need
|
|
1230 |
-to first install ``sphinx`` along with some additional plugins and dependencies,
|
|
1231 |
-using pip or some other mechanism::
|
|
1232 |
- |
|
1233 |
- # Install sphinx
|
|
1234 |
- pip3 install --user sphinx
|
|
1235 |
- |
|
1236 |
- # Install some sphinx extensions
|
|
1237 |
- pip3 install --user sphinx-click
|
|
1238 |
- pip3 install --user sphinx_rtd_theme
|
|
1239 |
- |
|
1240 |
- # Additional optional dependencies required
|
|
1241 |
- pip3 install --user arpy
|
|
1225 |
+Before you can build the docs, you will end to ensure that you have installed
|
|
1226 |
+the required :ref:`buid dependencies <contributing_build_deps>` as mentioned
|
|
1227 |
+in the testing section above.
|
|
1242 | 1228 |
|
1243 | 1229 |
To build the documentation, just run the following::
|
1244 | 1230 |
|
1245 |
- make -C doc
|
|
1231 |
+ tox -e docs
|
|
1246 | 1232 |
|
1247 | 1233 |
This will give you a ``doc/build/html`` directory with the html docs which
|
1248 | 1234 |
you can view in your browser locally to test.
|
... | ... | @@ -1260,9 +1246,10 @@ will make the docs build reuse already downloaded sources:: |
1260 | 1246 |
|
1261 | 1247 |
export BST_SOURCE_CACHE=~/.cache/buildstream/sources
|
1262 | 1248 |
|
1263 |
-To force rebuild session html while building the doc, simply build the docs like this::
|
|
1249 |
+To force rebuild session html while building the doc, simply run `tox` with the
|
|
1250 |
+``BST_FORCE_SESSION_REBUILD`` environment variable set, like so::
|
|
1264 | 1251 |
|
1265 |
- make BST_FORCE_SESSION_REBUILD=1 -C doc
|
|
1252 |
+ env BST_FORCE_SESSION_REBUILD=1 tox -e docs
|
|
1266 | 1253 |
|
1267 | 1254 |
|
1268 | 1255 |
Man pages
|
... | ... | @@ -1468,58 +1455,121 @@ regenerate them locally in order to build the docs. |
1468 | 1455 |
|
1469 | 1456 |
Testing
|
1470 | 1457 |
-------
|
1471 |
-BuildStream uses pytest for regression tests and testing out
|
|
1472 |
-the behavior of newly added components.
|
|
1458 |
+BuildStream uses `tox <https://tox.readthedocs.org/>`_ as a frontend to run the
|
|
1459 |
+tests which are implemented using `pytest <https://pytest.org/>`_. We use
|
|
1460 |
+pytest for regression tests and testing out the behavior of newly added
|
|
1461 |
+components.
|
|
1473 | 1462 |
|
1474 | 1463 |
The elaborate documentation for pytest can be found here: http://doc.pytest.org/en/latest/contents.html
|
1475 | 1464 |
|
1476 | 1465 |
Don't get lost in the docs if you don't need to, follow existing examples instead.
|
1477 | 1466 |
|
1478 | 1467 |
|
1468 |
+.. _contributing_build_deps:
|
|
1469 |
+ |
|
1470 |
+Installing build dependencies
|
|
1471 |
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
1472 |
+Some of BuildStream's dependencies have non-python build dependencies. When
|
|
1473 |
+running tests with ``tox``, you will first need to install these dependencies.
|
|
1474 |
+Exact steps to install these will depend on your oprtation systemm. Commands
|
|
1475 |
+for installing them for some common distributions are lised below.
|
|
1476 |
+ |
|
1477 |
+For Fedora-based systems::
|
|
1478 |
+ |
|
1479 |
+ dnf install gcc pkg-config python3-devel cairo-gobject-devel glib2-devel gobject-introspection-devel
|
|
1480 |
+ |
|
1481 |
+ |
|
1482 |
+For Debian-based systems::
|
|
1483 |
+ |
|
1484 |
+ apt install gcc pkg-config python3-dev libcairo2-dev libgirepository1.0-dev
|
|
1485 |
+ |
|
1486 |
+ |
|
1479 | 1487 |
Running tests
|
1480 | 1488 |
~~~~~~~~~~~~~
|
1481 |
-To run the tests, just type::
|
|
1489 |
+To run the tests, simply navigate to the toplevel directory of your BuildStream
|
|
1490 |
+checkout and run::
|
|
1491 |
+ |
|
1492 |
+ tox
|
|
1482 | 1493 |
|
1483 |
- ./setup.py test
|
|
1494 |
+By default, the test suite will be run against every supported python version
|
|
1495 |
+found on your host. If you have multiple python versions installed, you may
|
|
1496 |
+want to run tests against only one version and you can do that using the ``-e``
|
|
1497 |
+option when running tox::
|
|
1484 | 1498 |
|
1485 |
-At the toplevel.
|
|
1499 |
+ tox -e py37
|
|
1486 | 1500 |
|
1487 |
-When debugging a test, it can be desirable to see the stdout
|
|
1488 |
-and stderr generated by a test, to do this use the ``--addopts``
|
|
1489 |
-function to feed arguments to pytest as such::
|
|
1501 |
+The output of all failing tests will always be printed in the summary, but
|
|
1502 |
+if you want to observe the stdout and stderr generated by a passing test,
|
|
1503 |
+you can pass the ``-s`` option to pytest as such::
|
|
1490 | 1504 |
|
1491 |
- ./setup.py test --addopts -s
|
|
1505 |
+ tox -- -s
|
|
1506 |
+ |
|
1507 |
+.. tip::
|
|
1508 |
+ |
|
1509 |
+ The ``-s`` option is `a pytest option <https://docs.pytest.org/latest/usage.html>`_.
|
|
1510 |
+ |
|
1511 |
+ Any options specified before the ``--`` separator are consumed by ``tox``,
|
|
1512 |
+ and any options after the ``--`` separator will be passed along to pytest.
|
|
1492 | 1513 |
|
1493 | 1514 |
You can always abort on the first failure by running::
|
1494 | 1515 |
|
1495 |
- ./setup.py test --addopts -x
|
|
1516 |
+ tox -- -x
|
|
1496 | 1517 |
|
1497 | 1518 |
If you want to run a specific test or a group of tests, you
|
1498 | 1519 |
can specify a prefix to match. E.g. if you want to run all of
|
1499 | 1520 |
the frontend tests you can do::
|
1500 | 1521 |
|
1501 |
- ./setup.py test --addopts 'tests/frontend/'
|
|
1522 |
+ tox -- tests/frontend/
|
|
1502 | 1523 |
|
1503 | 1524 |
Specific tests can be chosen by using the :: delimeter after the test module.
|
1504 | 1525 |
If you wanted to run the test_build_track test within frontend/buildtrack.py you could do::
|
1505 | 1526 |
|
1506 |
- ./setup.py test --addopts 'tests/frontend/buildtrack.py::test_build_track'
|
|
1527 |
+ tox -- tests/frontend/buildtrack.py::test_build_track
|
|
1507 | 1528 |
|
1508 | 1529 |
We also have a set of slow integration tests that are disabled by
|
1509 | 1530 |
default - you will notice most of them marked with SKIP in the pytest
|
1510 | 1531 |
output. To run them, you can use::
|
1511 | 1532 |
|
1512 |
- ./setup.py test --addopts '--integration'
|
|
1533 |
+ tox -- --integration
|
|
1513 | 1534 |
|
1514 | 1535 |
By default, buildstream also runs pylint on all files. Should you want
|
1515 | 1536 |
to run just pylint (these checks are a lot faster), you can do so
|
1516 | 1537 |
with::
|
1517 | 1538 |
|
1518 |
- ./setup.py test --addopts '-m pylint'
|
|
1539 |
+ tox -- -m pylint
|
|
1519 | 1540 |
|
1520 | 1541 |
Alternatively, any IDE plugin that uses pytest should automatically
|
1521 | 1542 |
detect the ``.pylintrc`` in the project's root directory.
|
1522 | 1543 |
|
1544 |
+In case BuildStream's dependencies were updated since you last ran the
|
|
1545 |
+tests, you might see some errors like
|
|
1546 |
+``pytest: error: unrecognized arguments: --codestyle``. If this happens, you
|
|
1547 |
+will need to force ``tox`` to recreate the test environment(s). To do so, you
|
|
1548 |
+can run ``tox`` with ``-r`` or ``--recreate`` option.
|
|
1549 |
+ |
|
1550 |
+.. note::
|
|
1551 |
+ |
|
1552 |
+ By default, we do not allow use of site packages in our ``tox``
|
|
1553 |
+ confguration to enable running the tests in an isolated environment.
|
|
1554 |
+ If you need to enable use of site packages for whatever reason, you can
|
|
1555 |
+ do so by passing the ``--sitepackages`` option to ``tox``. Also, you will
|
|
1556 |
+ not need to install any of the build dependencies mentioned above if you
|
|
1557 |
+ use this approach.
|
|
1558 |
+ |
|
1559 |
+.. note::
|
|
1560 |
+ |
|
1561 |
+ While using ``tox`` is practical for developers running tests in
|
|
1562 |
+ more predictable execution environments, it is still possible to
|
|
1563 |
+ execute the test suite against a specific installation environment
|
|
1564 |
+ using pytest directly::
|
|
1565 |
+ |
|
1566 |
+ ./setup.py test
|
|
1567 |
+ |
|
1568 |
+ Specific options can be passed to ``pytest`` using the ``--addopts``
|
|
1569 |
+ option::
|
|
1570 |
+ |
|
1571 |
+ ./setup.py test --addopts 'tests/frontend/buildtrack.py::test_build_track'
|
|
1572 |
+ |
|
1523 | 1573 |
|
1524 | 1574 |
Adding tests
|
1525 | 1575 |
~~~~~~~~~~~~
|
... | ... | @@ -32,12 +32,12 @@ include .pylintrc |
32 | 32 |
recursive-include buildstream/_protos *.proto
|
33 | 33 |
|
34 | 34 |
# Requirements files
|
35 |
-include requirements.in
|
|
36 |
-include requirements.txt
|
|
37 |
-include dev-requirements.in
|
|
38 |
-include dev-requirements.txt
|
|
39 |
-include plugin-requirements.in
|
|
40 |
-include plugin-requirements.txt
|
|
35 |
+include tools/requirements.in
|
|
36 |
+include tools/requirements.txt
|
|
37 |
+include tools/dev-requirements.in
|
|
38 |
+include tools/dev-requirements.txt
|
|
39 |
+include tools/plugin-requirements.in
|
|
40 |
+include tools/plugin-requirements.txt
|
|
41 | 41 |
|
42 | 42 |
# Versioneer
|
43 | 43 |
include versioneer.py
|
... | ... | @@ -270,10 +270,10 @@ def get_cmdclass(): |
270 | 270 |
#####################################################
|
271 | 271 |
# Gather requirements #
|
272 | 272 |
#####################################################
|
273 |
-with open('dev-requirements.in') as dev_reqs:
|
|
273 |
+with open('tools/dev-requirements.in') as dev_reqs:
|
|
274 | 274 |
dev_requires = dev_reqs.read().splitlines()
|
275 | 275 |
|
276 |
-with open('requirements.in') as install_reqs:
|
|
276 |
+with open('tools/requirements.in') as install_reqs:
|
|
277 | 277 |
install_requires = install_reqs.read().splitlines()
|
278 | 278 |
|
279 | 279 |
#####################################################
|
... | ... | @@ -5,9 +5,29 @@ skip_missing_interpreters = true |
5 | 5 |
[testenv]
|
6 | 6 |
commands = pytest {posargs}
|
7 | 7 |
deps =
|
8 |
- -rrequirements.txt
|
|
9 |
- -rdev-requirements.txt
|
|
10 |
- -rplugin-requirements.txt
|
|
8 |
+ -rtools/requirements.txt
|
|
9 |
+ -rtools/dev-requirements.txt
|
|
10 |
+ -rtools/plugin-requirements.txt
|
|
11 | 11 |
passenv =
|
12 |
+ BST_FORCE_BACKEND
|
|
12 | 13 |
GI_TYPELIB_PATH
|
13 | 14 |
INTEGRATION_CACHE
|
15 |
+ |
|
16 |
+[testenv:docs]
|
|
17 |
+commands =
|
|
18 |
+ make -C doc
|
|
19 |
+# Currently sphinx_rtd_theme does not support Sphinx >1.8, this breaks search functionality
|
|
20 |
+deps =
|
|
21 |
+ sphinx==1.7.9
|
|
22 |
+ sphinx-click
|
|
23 |
+ sphinx_rtd_theme
|
|
24 |
+ -rtools/requirements.txt
|
|
25 |
+ -rtools/plugin-requirements.txt
|
|
26 |
+passenv =
|
|
27 |
+ BST_FORCE_SESSION_REBUILD
|
|
28 |
+ BST_SOURCE_CACHE
|
|
29 |
+ HOME
|
|
30 |
+ LANG
|
|
31 |
+ LC_ALL
|
|
32 |
+whitelist_externals =
|
|
33 |
+ make
|