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
|
|
|
|
2020-05-11 21:39:28 +08:00
|
|
|
# If you change this file, you can validate using Travis CI's Build Config Explorer https://config.travis-ci.com/explore
|
|
|
|
|
2019-11-07 22:24:36 +08:00
|
|
|
group: travis_latest
|
|
|
|
|
|
|
|
language: python
|
|
|
|
|
2020-05-11 21:16:58 +08:00
|
|
|
cache:
|
|
|
|
- pip
|
2020-05-11 21:39:28 +08:00
|
|
|
- directories:
|
2020-05-11 21:16:58 +08:00
|
|
|
- "$HOME/.npm"
|
2019-11-07 22:24:36 +08:00
|
|
|
|
|
|
|
python:
|
|
|
|
- 3.7
|
|
|
|
|
|
|
|
os: linux
|
|
|
|
|
2020-08-17 14:43:13 +08:00
|
|
|
before_install:
|
|
|
|
# Init server_config.json to default
|
2021-02-17 22:55:06 +08:00
|
|
|
- cp monkey/monkey_island/cc/server_config.json.develop monkey/monkey_island/cc/server_config.json
|
2020-08-17 14:43:13 +08:00
|
|
|
|
2019-11-07 22:24:36 +08:00
|
|
|
install:
|
2019-11-07 22:29:10 +08:00
|
|
|
# Python
|
2020-07-08 21:43:52 +08:00
|
|
|
- pip freeze
|
2019-11-07 22:24:36 +08:00
|
|
|
- pip install -r monkey/monkey_island/requirements.txt # for unit tests
|
2021-04-02 00:50:49 +08:00
|
|
|
- pip install black flake8 pytest pytest-cov isort # for next stages
|
2020-03-15 17:20:58 +08:00
|
|
|
- pip install coverage # for code coverage
|
2019-11-26 19:22:56 +08:00
|
|
|
- pip install -r monkey/infection_monkey/requirements.txt # for unit tests
|
2020-07-08 22:03:50 +08:00
|
|
|
- pip install pipdeptree
|
|
|
|
# Fail builds on possible conflicting dependencies.
|
|
|
|
- pipdeptree --warn fail
|
2019-11-07 22:24:36 +08:00
|
|
|
|
2020-05-10 20:42:42 +08:00
|
|
|
# node + npm + eslint
|
|
|
|
- node --version
|
|
|
|
- npm --version
|
2020-05-20 21:09:36 +08:00
|
|
|
- nvm --version
|
2020-05-10 20:42:42 +08:00
|
|
|
- nvm install node
|
|
|
|
- nvm use node
|
|
|
|
- npm i -g eslint
|
|
|
|
- node --version
|
|
|
|
- npm --version
|
|
|
|
|
2020-06-16 18:04:24 +08:00
|
|
|
# linuxbrew (for hugo)
|
2020-06-16 18:08:33 +08:00
|
|
|
- git clone https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew
|
|
|
|
- mkdir ~/.linuxbrew/bin
|
|
|
|
- ln -s ~/.linuxbrew/Homebrew/bin/brew ~/.linuxbrew/bin
|
|
|
|
- eval $(~/.linuxbrew/bin/brew shellenv)
|
2020-06-16 18:04:24 +08:00
|
|
|
|
|
|
|
# hugo (for documentation)
|
|
|
|
- brew install hugo
|
2020-06-17 22:36:37 +08:00
|
|
|
# print hugo version (useful for debugging documentation build errors)
|
|
|
|
- hugo version
|
2019-11-07 22:24:36 +08:00
|
|
|
|
|
|
|
script:
|
|
|
|
# Check Python code
|
2020-03-15 17:20:58 +08:00
|
|
|
## Check syntax errors and fail the build if any are found.
|
2021-04-06 01:45:18 +08:00
|
|
|
- flake8 ./monkey
|
2019-11-07 22:24:36 +08:00
|
|
|
|
2020-07-15 23:46:04 +08:00
|
|
|
## Check import order
|
2021-01-28 22:32:24 +08:00
|
|
|
- python -m isort ./monkey --settings-file ./ci_scripts/isort.cfg
|
2020-07-15 23:46:04 +08:00
|
|
|
|
2021-04-02 00:50:49 +08:00
|
|
|
## Check that all python is properly formatted. Fail otherwise.
|
|
|
|
- python -m black --check .
|
|
|
|
|
2021-01-15 03:00:28 +08:00
|
|
|
## Run unit tests and generate coverage data
|
2019-11-07 22:24:36 +08:00
|
|
|
- cd monkey # This is our source dir
|
2021-01-28 22:32:24 +08:00
|
|
|
- python -m pytest --cov=. # Have to use `python -m pytest` instead of `pytest` to add "{$builddir}/monkey/monkey" to sys.path.
|
2020-03-15 17:20:58 +08:00
|
|
|
|
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
|
2020-05-11 21:16:58 +08:00
|
|
|
- npm ci # See https://docs.npmjs.com/cli/ci.html
|
2020-05-10 20:42:42 +08:00
|
|
|
- eslint ./src --quiet # Test for errors
|
2020-09-23 19:54:30 +08:00
|
|
|
- JS_WARNINGS_AMOUNT_UPPER_LIMIT=7
|
2020-05-10 20:42:42 +08:00
|
|
|
- eslint ./src --max-warnings $JS_WARNINGS_AMOUNT_UPPER_LIMIT # Test for max warnings
|
2019-11-07 22:24:36 +08:00
|
|
|
|
2020-06-16 18:04:24 +08:00
|
|
|
# Build documentation
|
|
|
|
- cd $TRAVIS_BUILD_DIR/docs
|
2020-06-17 22:36:37 +08:00
|
|
|
- hugo --verbose --environment staging
|
2020-06-16 18:04:24 +08:00
|
|
|
|
2020-03-15 17:20:58 +08:00
|
|
|
after_success:
|
|
|
|
# Upload code coverage results to codecov.io, see https://github.com/codecov/codecov-bash for more information
|
|
|
|
- bash <(curl -s https://codecov.io/bash)
|
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
|