Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

Fix failing Python 3.4 Travis builds + general ci/cd enhancements #195

Merged
merged 3 commits into from
Sep 23, 2019

Conversation

lukpueh
Copy link
Collaborator

@lukpueh lukpueh commented Jul 11, 2019

Purpose of the PR:

  • Fixes failing Python 3.4 Travis builds
  • Enables Python 3.5 testing with tox and Travis
  • Enables build matrix for parallel builds and to publish one coverage report per build on coveralls.io
  • Generally enhances coverage reporting (adds branch coverage, uses relative paths)

Summary of Changes:

Please see very detailed commit messages for background information.

Further Requirements:

(If documentation or the demo needs to be changed due to this PR, has this
already been included in the PR? What still needs to be done?)

Configure a travis build matrix to run each tox build in a
corresponding (by Python version) travis build environment.

This also fixes recent issues were tox couldn't find Python 3.4
in a Travis Python 2.7 environment, which occurred after Travis
has been updated to use Ubuntu Xenial as default environment. See:
https://travis-ci.community/t/error-interpreternotfound-python3-4/3958

The commit also configures tox (and travis) to run tests with Python
3.5 too, which is mentioned in setup.py's version classifiers (I
deliberately left out 3.3, which imho we don't need to support).
Skipping sdist disables tox's default install of uptane. As a
consequence the tests run over the editable install of uptane (see
`--editable .` via `deps=-r dev-requirements.txt` in tox.ini). This
in turn helps coverage to write correct relative paths starting,
e.g. `uptane/__init__.py` instead of absolute paths to the virtual
environment directory, where tox would install it.

Note that tox's `skip_install=True` option is not necessary if
`skipdist=true`.

This commit also moves and updates coverage configuration to a
.-file, to enable branch coverage measurement (in addition to
already used statement coverage) and to ignore unrelated code (test
and demo scripts, installed dependencies, etc.)

__Background information for the interested reader:__

There are several things that affect which `uptane` is used to run
the tests:

- Tox, per default, installs uptane into its virtual environment
  directory.
- We instruct tox to install uptane editable mode, i.e. to use the
  project files. This would be ignored if we don't customize tox to
  skip the installation (which we do now).
- Additionally Python's `unittest.defaultTestLoader.discover`
  patches the PATH, to prioritize the uptane from the project files
  when running the tests.
  - However, this only works if we pass the root of the project to
    the `discover` method, e.g. via `start_dir` or `top_level_dir`
    arguments (which we don't).
  - Moreover, if `uptane` is already in the execution context
    before test discovery. Python won't re-import `uptane` from the
    patched PATH, i.e. the project files, but use whatever uptane was
    available before, e.g. as installed during the tox environment
    setup (This is also the case here, because we import uptane before
    test discovery, to use custom uptane exceptions and set
    `uptane.tuf.conf.METADATA_FORMAT`).
Copy link

@adityasaky adityasaky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I think we should evaluate the python environments we're running on though.

@lukpueh lukpueh merged commit 13e8b8c into uptane:develop Sep 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants