Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate After All #93

Merged
merged 1 commit into from
Nov 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,27 @@ install:
- pip install wheel codecov coverage
- python setup.py bdist_wheel
- pip install ./dist/tox_travis-*.whl
script:
- tox --installpkg ./dist/tox_travis-*.whl --travis-after
script: tox --installpkg ./dist/tox_travis-*.whl
after_success: coverage combine && codecov

branches:
only:
- master
- /^\d+(\.\d+)*$/
matrix:
if: tag IS present OR branch = master
jobs:
fast_finish: true
include:
- python: 3.6
env: TOXENV=docs
- python: 3.6
env: TOXENV=desc
- stage: deploy
python: 3.6
env: TRAVIS_STAGE=deploy
install: true
script: true
after_success: true

stages:
- name: deploy
if: tag IS present

deploy:
provider: pypi
Expand All @@ -41,6 +47,5 @@ deploy:
secure: KjQrEjwmfP+jqdHNQ6bJoNjOJHHz0kirrSORat2uJTulXaUs/nuDcZqTu7gxMFaM92z3eJZzTZmxO71cDhJiBt+FQhEtL/q8wd7Fv5d5v5EIlLFNqdEyCaTthSgXQa/HJTtbzjdFIEN8qCofHu+zEWMnb1ZHgUcK7hZHMCrHcVF4kD+k1myNro+1Pp/sGIUMUOkqocz+8OI2FuEQh0txXl0MLf2UEk53EK2noD4D/fm/YDDYJbAWlNPBbCBaU/ZGfzuFivh00bx9lAg7UB6t/A3iIasRUiAJbHdxvrxxGFAeOV/t09TcTtEcwBRyPe8JzSuReCROccyFB2TLOzfkt9h7TkdC2CWrMmXpI6UogTct++r3kavdsJuAZMbSy1jrnxkxtB1CW7DOly4v4JuyewpET7CnTjkhd9zIowESwJFjxwmns63AS2okQdPTCqsbbNp53Jk5fpf6qXwMFdaHT1kU1MpwoQPT0HnwLz3xybvjgfgu3t4KfEBvc0DCp89VMjCM9xkKTlziZkwOhXqaNhu+cVqo1/eUY/HDT/7V7xiL/U6U11UOrqtxkdDofoIl4NuiT7uoVaVctm/Y4kBEkJRZCwcjRsZJ0c06SvMvxhMDBUEM5IiXS6tH6Zp08MDYlclpKFGKdzOrxP2X0rVFIZ99KLyhfRNZuZcu92tDpP8=
on:
tags: true
python: 3.6
condition: $TOXENV != docs && $TOXENV != desc
condition: $TRAVIS_STAGE = deploy
distributions: bdist_wheel
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
0.10 (TBD)
++++++++++

* Deprecate the After All feature.
Travis now has `Build Stages`_, which are a better solution.

.. _`Build Stages`: https://docs.travis-ci.com/user/build-stages


0.9 (2017-11-12)
++++++++++++++++
Expand Down
18 changes: 17 additions & 1 deletion docs/after.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
After All
=========

.. deprecated:: 0.10

.. warning::

This feature is deprecated.

Travis has added `Build Stages`_,
which are a better solution to this problem.
You will also likely want to check out `Conditions`_,
which make it much easier to determine
which jobs, stages, and builds will run.

.. _`Build Stages`: https://docs.travis-ci.com/user/build-stages
.. _`Conditions`: https://docs.travis-ci.com/user/conditional-builds-stages-jobs


Inspired by `travis-after-all`_ and `travis_after_all`_,
this feature allows a job to wait for other jobs to finish
before it calls itself complete.
Expand Down Expand Up @@ -77,7 +93,7 @@ that corresponds to using the above ``travis:after`` section:
This example deploys when the build is from a tag
and the build is on Python 3.5
and the build is using DJANGO="1.8".
Together ``tox --travis-after`` and Tox's ``on`` conditions
Together ``tox --travis-after`` and Travis' ``on`` conditions
make sure that the deploy only happens after all tests pass.

If any configuration item does not match,
Expand Down
7 changes: 7 additions & 0 deletions src/tox_travis/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ def tox_configure(config):
for envconfig in config.envconfigs.values():
envconfig.ignore_outcome = False

# after
if config.option.travis_after:
print('The after all feature has been deprecated. Check out Travis\' '
'build stages, which are a better solution. '
'See https://tox-travis.readthedocs.io/en/stable/after.html '
'for more details.', file=sys.stderr)


def tox_subcommand_test_post(config):
"""Wait for this job if the configuration matches."""
Expand Down
50 changes: 50 additions & 0 deletions tests/test_after.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,65 @@
"""Tests of the --travis-after flag."""
import pytest
import py
import subprocess
from contextlib import contextmanager
from tox_travis.after import (
travis_after,
after_config_matches,
)


ini = b"""
[tox]
envlist = py35, py36
"""

coverage_config = b"""
[run]
branch = True
parallel = True
source = tox_travis

[paths]
source =
src
*/site-packages
"""


class TestAfter:
"""Test the logic of waiting for other jobs to finish."""

def call(self, command):
"""Return the raw output of the given command."""
proc = subprocess.Popen(
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
return proc.returncode, stdout.decode('utf-8'), stderr.decode('utf-8')

@contextmanager
def configure(self, tmpdir, monkeypatch, tox_ini, version):
"""Configure the environment for a test."""
origdir = tmpdir.chdir()
tmpdir.join('tox.ini').write(tox_ini)
tmpdir.join('.coveragerc').write(coverage_config)
monkeypatch.setenv('TRAVIS', 'true')
monkeypatch.setenv('TRAVIS_PYTHON_VERSION', version)

yield

# Change back to the original directory
# Copy .coverage.* report files
origdir.chdir()
for f in tmpdir.listdir(lambda f: f.basename.startswith('.coverage.')):
f.copy(origdir)

def test_after_deprecated(self, tmpdir, monkeypatch):
"""Show deprecation message when using --travis-after."""
with self.configure(tmpdir, monkeypatch, ini, '3.6'):
_, _, stderr = self.call(['tox', '-l', '--travis-after'])
assert 'The after all feature has been deprecated.' in stderr

def test_pull_request(self, mocker, monkeypatch, capsys):
"""Pull requests should not run after-all."""
mocker.patch('tox_travis.after.after_config_matches',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_envlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def test_not_travis(self, tmpdir, monkeypatch):
assert self.tox_envs() == expected

def test_travis_config_filename(self, tmpdir, monkeypatch):
"""Give the correct env for CPython 2.7."""
"""Give the correct env for manual filename."""
with self.configure(tmpdir, monkeypatch, tox_ini, 'CPython', 3, 6,
ini_filename='spam.ini'):
assert self.tox_envs(ini_filename='spam.ini') == ['py36']
Expand Down
3 changes: 0 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ deps =
commands =
python setup.py check --restructuredtext --strict

[travis:after]
toxenv = py36

[flake8]
ignore = D203

Expand Down