monkey/.travis.yml

104 lines
3.0 KiB
YAML
Raw Normal View History

# Infection Monkey travis.yml. See Travis documentation for information about this file structure.
2019-11-07 21:02:49 +08:00
# If you change this file, you can validate using Travis CI's Build Config Explorer https://config.travis-ci.com/explore
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
cache:
- pip
- directories:
- "$HOME/.npm"
2021-05-10 22:30:14 +08:00
- $PIP_CACHE_DIR
- $PIPENV_CACHE_DIR
python:
- 3.7
os: linux
before_install:
# Init server_config.json to default
- cp monkey/monkey_island/cc/server_config.json.develop monkey/monkey_island/cc/server_config.json
install:
2019-11-07 22:29:10 +08:00
# Python
2021-04-14 21:01:10 +08:00
- pip install pipenv
# Install island and monkey requirements as they are needed by UT's
2021-04-14 21:01:10 +08:00
- pushd monkey/monkey_island
- pipenv sync --dev # This installs dependencies from lock
2021-04-14 21:01:10 +08:00
- popd
- pushd monkey/infection_monkey
- pipenv sync --dev # This installs dependencies from lock
2021-04-14 21:01:10 +08:00
- popd
# node + npm + eslint
- node --version
- npm --version
- nvm --version
- nvm install 12
- nvm use node
- npm i -g eslint
- node --version
- npm --version
2020-06-16 18:04:24 +08:00
# hugo (for documentation)
- 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
# print hugo version (useful for debugging documentation build errors)
- tar -zxf hugo.tar.gz
- ./hugo version
script:
# Check Python code
## Check syntax errors and fail the build if any are found.
- flake8 .
## Check import order
2021-04-06 19:58:40 +08:00
- python -m isort ./monkey --check-only
## Check that all python is properly formatted. Fail otherwise.
- python -m black --check .
## Check that there is no dead python code
- python -m vulture .
## Run unit tests and generate coverage data
- cd monkey # This is our source dir
- python -m pytest --cov=. # Have to use `python -m pytest` instead of `pytest` to add "{$builddir}/monkey/monkey" to sys.path.
# 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 ci # See https://docs.npmjs.com/cli/ci.html
- eslint ./src --quiet # Test for errors
- JS_WARNINGS_AMOUNT_UPPER_LIMIT=0
- eslint ./src --max-warnings $JS_WARNINGS_AMOUNT_UPPER_LIMIT # Test for max warnings
2020-06-16 18:04:24 +08:00
# Build documentation
- cd $TRAVIS_BUILD_DIR/docs
- ../hugo --verbose --environment staging
2020-06-16 18:04:24 +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
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)
notifications:
slack: # Notify to slack
rooms:
- infectionmonkey:QaXbsx4g7tHFJW0lhtiBmoAg#ci # room: #ci
on_success: change
on_failure: always
email:
on_success: change
on_failure: always