2019-10-28 19:54:07 +08:00
# Infection Monkey travis.yml. See Travis documentation for information about this file structure.
2019-11-07 21:02:49 +08:00
2019-11-07 22:24:36 +08:00
group : travis_latest
language : python
cache : pip
python :
- 3.7
os : linux
install :
2019-11-07 22:29:10 +08:00
# Python
2019-11-07 22:24:36 +08:00
- pip install -r monkey/monkey_island/requirements.txt # for unit tests
- pip install flake8 pytest dlint # for next stages
2019-11-26 19:22:56 +08:00
- pip install -r monkey/infection_monkey/requirements.txt # for unit tests
2019-11-07 22:24:36 +08:00
before_script :
2019-11-08 22:30:43 +08:00
# Set the server config to `testing`. This is required for for the UTs to pass.
2019-11-07 22:24:36 +08:00
- python monkey/monkey_island/cc/set_server_config.py testing
script :
# Check Python code
# Check syntax errors and fail the build if any are found.
- flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
# Warn about linter issues.
# --exit-zero forces Flake8 to use the exit status code 0 even if there are errors, which means this will NOT fail the build.
# --count will print the total number of errors.
# --statistics Count the number of occurrences of each error/warning code and print a report.
# The output is redirected to a file.
- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics > flake8_warnings.txt
# Display the linter issues
- cat flake8_warnings.txt
# Make sure that we haven't increased the amount of warnings.
2019-11-07 23:00:14 +08:00
- PYTHON_WARNINGS_AMOUNT_UPPER_LIMIT=190
- if [ $(tail -n 1 flake8_warnings.txt) -gt $PYTHON_WARNINGS_AMOUNT_UPPER_LIMIT ]; then echo "Too many warnings! Failing this build. Lower the amount of linter errors in this and try again. " && exit 1; fi
2019-11-07 22:24:36 +08:00
- cd monkey # This is our source dir
- python -m pytest # Have to use `python -m pytest` instead of `pytest` to add "{$builddir}/monkey/monkey" to sys.path.
2019-11-07 23:00:14 +08:00
# Check JS code. The npm install must happen AFTER the flake8 because the node_modules folder will cause a lot of errors.
2019-11-07 22:44:00 +08:00
- cd monkey_island/cc/ui
- npm i
- npm i -g eslint
- cd -
2019-11-07 22:24:36 +08:00
- cd monkey_island/cc/ui
- eslint ./src --quiet
2019-11-29 17:07:40 +08:00
- JS_WARNINGS_AMOUNT_UPPER_LIMIT=35
2019-11-07 23:00:14 +08:00
- eslint ./src --max-warnings $JS_WARNINGS_AMOUNT_UPPER_LIMIT
2019-11-07 22:24:36 +08:00
notifications :
slack : # Notify to slack
rooms :
- infectionmonkey:QaXbsx4g7tHFJW0lhtiBmoAg#ci # room : #ci
on_success : change
on_failure : always
email :
on_success : change
on_failure : always