I have travis set up to test using tox (Python 2.7 and 3.5) and deploy to pypi.
Travis tries to deploy the package for each test run, and pypi correctly rejects the second attempt.
I want travis to deploy once only when tox completes both runs successfully. How is this accomplished?
Travis config: https://github.com/biocommons/biocommons.seqrepo/blob/master/.travis.yml
And a test run: https://travis-ci.org/biocommons/biocommons.seqrepo/builds/157794212 (68.2 finished first and pushed to pypi. The pypi error is in 68.1.)
Related but stale question: Why does Travis not wait for all builds to pass before deploying?
This can now be accomplished with build stages, which are currently in beta. This looks something like so:
stages: # determines the order everything runs in
- test
- deploy
jobs: # specifies the actual job
include:
- stage: test
# configuration for a stage here
- stage: deploy
# configuration for the next stage here
Given a .travis.yml
like this:
language: python
sudo: false
cache: pip
python:
- 2.7
- 3.4
- 3.5
- 3.6
- pypy
install:
- pip install tox-travis
script:
- tox
deploy:
provider: pypi
user: stephenfin
password:
secure: <key omitted for brevity>
on:
tags: true
distributions: sdist bdist_wheel
You would convert it like so:
language: python
sudo: false
cache: pip
python:
- 2.7
- 3.4
- 3.5
- 3.6
- pypy
install:
- pip install tox-travis
script:
- tox
stages:
- test
- deploy
jobs:
include:
- stage: deploy
python: 3.6
install: skip # no tests, no depedencies needed
script: skip # we're not running tests
deploy:
provider: pypi
user: stephenfin
password:
secure: <key omitted for brevity>
on:
tags: true
distributions: sdist bdist_wheel
Personally, I found this a little counterintuitive: I expected everything that wasn't global to be nested under a stage
. As a result, I had explicitly defined the test
stage and nested the python
, install
and script
keys under there. However, this doesn't work and you instead need to set those keys in the top level and then explicitly override them in individual stages. The global stuff will be called by the test
stage, which is the default job. I've not yet determined if this is an issue with Travis or the tox-travis
plugin (currently 0.10), but it's worth calling out.
Also note that if you're using the Travis Gem, the travis lint
command currently fails because this feature is not supported there yet. There's a bug open for this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With