Cd into files and then install requirements?

Hi all

Trying to install Travis CI for the Linux folder on my keylogger repo here: github.com/giacomolaw/keylogger

I can’t get travis to go to the Linux folder first thing - how do I get it to?

Thanks!

Hi!

In the script section of your .travis.yml file you could have multiple lines and just run cd linux as the first line, like this:

script:
  - cd linux
  - python setup.py

That would cd into the linux folder, and then run a setup.py python script. An alternative would be having a bash or python script that runs all the commands you want (including cd), and that might look something like:

script: ci_scripts/test_python_module.sh

That would run a test_python_module.sh script located in the ci_scripts folder of the git repo.

1 Like

Awesome, thank you!

Is there an example script that I can use to simply run the script and warn me of traceback errors?

Thanks

You could try command substitution to assign the output to a bash variable and then use a if to check if it contains a particular string of text.

OUT_LOG=$(ci/scripts/test_python_module.sh)
if [[ "$OUT_LOG" == "*traceback error*" ]]; then echo "traceback error detected" ; fi

Another option would be redirecting the output (stdout and/or stderr) when running the script to a file, and using grep/sed to search the file for output indicating that there is a traceback error.

1 Like

Awesome, thanks!

I added that to test.py in my main files. However I’m getting an error 127 as apparently the command is not found?

I have script: test.py in the yml file…

Have no idea why it’s not working :pensive:

Would this work to test for errors?

script:
  - python -m unittest discover

This isn’t picking up errors :pensive:

I’m trying to add it to a smaller project GitHub - GiacomoLaw/leaguestatistics: Statistics for a specific player on League of Legends however this project requires user input, which I would be able to deanwith, but uses an api key that needs to be kept private and expires every 24 hours.

I’m not seeing any files in your repository that import unittest or implement test cases – that might be related to why it isn’t picking up any errors.

1 Like