As part of a Python package I have a script myscript.py
at the root of my project and
setup(scripts=['myscript.py'], ...)
in my setup.py
.
Is there an entry I can provide to my .travis.yml
that will run myscript.py
(e.g. after my tests)?
I've tried
language: python
python:
- "2.7"
install:
- pip install -r requirements.txt
- pip install pytest
script:
- py.test -v --color=yes --exitfirst --showlocals --durations=5
- myscript.py some args
but get a "command not found" error.
I don't need (or really want) the script to be part of the test suite, I just want to see it's output in the Travis log (and, of corse, fail the build if it errors).
How can I run a package script as part of a Travis CI build?
The first job is to build the image and the second job is going to be to run the NPM test target.
Trigger Travis CI builds using the API V3 by sending a POST request to /repo/{slug|id}/requests : Get an API token from your Travis CI settings page. You'll need the token to authenticate most of these API requests.
Travis CI tool can easily integrate with the common cloud repositories like GitHub and Bitbucket. It offers many automated CI options which cut out the need for a dedicated server as the Travis CI server is hosted in the cloud.
As mentioned in the comments (you need to call python):
language: python
python:
- "2.7"
install:
- pip install -r requirements.txt
- pip install pytest
script:
- py.test -v --color=yes --exitfirst --showlocals --durations=5
- python myscript.py some args
(Prepending python in the last line.)
Aside: travis should have pytest preinstalled.
There's also an after_success
block which can be useful in these cases (for running a script only if the tests pass, and not affecting the success of the builds) - often this is used for posting coverage stats.
language: python
python:
- "2.7"
install:
- pip install -r requirements.txt
- pip install pytest
script:
- py.test -v --color=yes --exitfirst --showlocals --durations=5
after_success:
- python myscript.py some args
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