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

As part of the Python package, I have a myscript.py script in the root of my project and

 setup(scripts=['myscript.py'], ...) 

in my setup.py .

Is there an entry that I can provide to my .travis.yml that will run myscript.py (e.g. after my tests)?

I 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 the error "command not found".

I don’t need (or really want) the script to be part of the test suite, I just want to see its output in the Travis log (and, from the root, the build failed if these are errors).

How can I run a script package as part of the Travis CI assembly?

+6
source share
1 answer

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 on the last line.)

In addition, travis must have pytest installed.


There is also an after_success block that can be useful in these cases (to run a script only if the tests pass and do not affect the success of the build) - this is often used to publish coverage statistics.

 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 
+7
source

All Articles