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
|
|
|
|
|
2021-05-10 22:30:14 +08:00
|
|
|
env:
|
|
|
|
- PIP_CACHE_DIR=$HOME/.cache/pip PIPENV_CACHE_DIR=$HOME/.cache/pipenv
|
|
|
|
|
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"
|
2021-05-10 22:30:14 +08:00
|
|
|
- $PIP_CACHE_DIR
|
|
|
|
- $PIPENV_CACHE_DIR
|
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
|
2021-04-14 21:01:10 +08:00
|
|
|
- pip install pipenv
|
2021-04-14 22:06:16 +08:00
|
|
|
# Install island and monkey requirements as they are needed by UT's
|
2021-04-14 21:01:10 +08:00
|
|
|
- pushd monkey/monkey_island
|
2021-04-14 22:09:15 +08:00
|
|
|
- pipenv sync --dev # This installs dependencies from lock
|
2021-04-14 21:01:10 +08:00
|
|
|
- popd
|
|
|
|
- pushd monkey/infection_monkey
|
2021-04-14 22:09:15 +08:00
|
|
|
- pipenv sync --dev # This installs dependencies from lock
|
2021-04-14 21:01:10 +08:00
|
|
|
- popd
|
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
|
2021-04-27 07:24:34 +08:00
|
|
|
- nvm install 12
|
2020-05-10 20:42:42 +08:00
|
|
|
- nvm use node
|
|
|
|
- npm i -g eslint
|
|
|
|
- node --version
|
|
|
|
- npm --version
|
|
|
|
|
2020-06-16 18:04:24 +08:00
|
|
|
# hugo (for documentation)
|
2021-05-10 21:43:08 +08:00
|
|
|
- curl --output - -L https://api.github.com/repos/gohugoio/hugo/releases/latest | grep --color=never "browser_download_url.*Linux-64bit.tar.gz" | grep -v extended | cut -d ':' -f2,3 | tr -d '"' | xargs -n 1 curl -L --output hugo.tar.gz
|
2020-06-17 22:36:37 +08:00
|
|
|
# print hugo version (useful for debugging documentation build errors)
|
2021-05-10 21:43:08 +08:00
|
|
|
- tar -zxf hugo.tar.gz
|
|
|
|
- ./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-08 01:41:12 +08:00
|
|
|
- flake8 .
|
2019-11-07 22:24:36 +08:00
|
|
|
|
2020-07-15 23:46:04 +08:00
|
|
|
## Check import order
|
2021-04-06 19:58:40 +08:00
|
|
|
- python -m isort ./monkey --check-only
|
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-05-04 01:05:42 +08:00
|
|
|
## Check that there is no dead python code
|
|
|
|
- python -m vulture .
|
|
|
|
|
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
|
2021-04-12 21:13:37 +08:00
|
|
|
- JS_WARNINGS_AMOUNT_UPPER_LIMIT=0
|
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
|
2021-05-10 21:43:08 +08:00
|
|
|
- ../hugo --verbose --environment staging
|
2020-06-16 18:04:24 +08:00
|
|
|
|
2021-04-07 18:56:10 +08:00
|
|
|
# verify swimm
|
|
|
|
- cd $TRAVIS_BUILD_DIR
|
2021-04-08 19:42:10 +08:00
|
|
|
- curl -s https://api.github.com/repos/swimmio/SwimmReleases/releases/latest | grep 'browser_download_url.*swimm-cli' | cut -d '"' -f 4 | wget -O swimm_cli -qi -
|
|
|
|
- chmod +x swimm_cli
|
|
|
|
- node swimm_cli --version
|
|
|
|
- node swimm_cli verify
|
2021-04-07 18:56:10 +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
|