Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run a script as part of a Travis CI build?

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?

like image 615
orome Avatar asked Nov 13 '15 23:11

orome


People also ask

Which of the following are two main parts of Travis CI job?

The first job is to build the image and the second job is going to be to run the NPM test target.

How do you trigger a Travis CI build?

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.

Which build automation tool can be used with Travis CI?

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.


1 Answers

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
like image 167
Andy Hayden Avatar answered Sep 28 '22 05:09

Andy Hayden