forked from StackStorm/st2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
145 lines (132 loc) · 7.14 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
os: linux
dist: xenial
language: python
branches:
only:
- master
- /^v[0-9]+\.[0-9]+$/
env:
global:
- IS_NIGHTLY_BUILD=$([ "${TRAVIS_EVENT_TYPE}" = "cron" ] && echo "yes" || echo "no")
# NOTE: We only enable coverage for master builds and not pull requests
# since it has huge performance overhead (tests are 50% or so slower)
- ENABLE_COVERAGE=$([ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${IS_NIGHTLY_BUILD}" = "no" ] && echo "yes" || echo "no")
# We need to explicitly specify terminal width otherwise some CLI tests fail on container
# environments where small terminal size is used.
- COLUMNS=120
- PYLINT_CONCURRENCY=2
# We only run tests with "--with-timer" flag on master and not for PRs since it adds 1-2
# # minutes of overhead to each build.
- NOSE_TIME=$([ "${TRAVIS_PULL_REQUEST}" = "false" ] && [ "${IS_NIGHTLY_BUILD}" = "no" ] && echo "yes" || echo "no")
# Travis-specific st2.conf (with travis user instead of stanley)
- ST2_CONF=conf/st2.travis.conf
jobs:
include:
# NOTE: We combine builds because Travis offers a maximum of 5 concurrent
# builds and having 6 tasks / builds means 1 tasks will need to wait for one
# of the other 5 tasks to finish before it can start
# NOTE: Thresholds only apply to the make target and not to the whole build
# job which also includes "make requirements" and other steps
# "make requirements" can take substantially lower if the cache is purged
# and this would cause too many intermediate failures / false positives
# NOTE: TASK is inspected in commands below and other travis scripts.
# For example, ci-py3* targets trigger an alternate virtualenv build method.
# If you rename or reorder make targets in TASK, you may need to adjust:
# scripts/travis/install-requirements.sh
# scripts/travis/run-nightly-make-task-if-exists.sh
- name: "Unit Tests (Python 2.7 MongoDB 3.4)"
python: 2.7
env: TASK=ci-unit CACHE_NAME=py2 COMMAND_THRESHOLD=700
- name: "Integration Tests (Python 2.7)"
python: 2.7
env: TASK=ci-integration CACHE_NAME=py2 COMMAND_THRESHOLD=700
- name: "Lint Checks, Packs Tests (Python 2.7)"
python: 2.7
env: TASK="ci-checks ci-packs-tests" CACHE_NAME=py2 COMMAND_THRESHOLD=430
- name: "Unit Tests, Pack Tests (Python 3.6)"
python: 3.6
env: TASK="compilepy3 ci-py3-unit ci-py3-packs-tests" CACHE_NAME=py3 PYTHON_VERSION=python3.6 COMMAND_THRESHOLD=750
- name: "Integration Tests (Python 3.6)"
python: 3.6
env: TASK="ci-py3-integration" CACHE_NAME=py3 PYTHON_VERSION=python3.6 COMMAND_THRESHOLD=770
addons:
apt:
sources:
- sourceline: 'deb [arch=amd64] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse'
key_url: 'https://www.mongodb.org/static/pgp/server-3.4.asc'
packages:
- mongodb-org-server=3.4.*
- mongodb-org-shell=3.4.*
- rabbitmq-server
- libffi-dev
cache:
pip: true
directories:
# NOTE: If using a custom "install" step aka overriding "install" step, "cache.pip: true" doesn't work
# and directory needs to be explicitly added to the cache.
# See https://github.com/travis-ci/travis-ci/issues/3239, https://github.com/oppia/oppia/pull/5281 for details.
- $HOME/.cache/pip
- virtualenv/
# NOTE: Caching .tox speeds up py3 build for 30-60 seconds, but causes issues when dependencies
# are updated so it's disabled
#- .tox/
install:
- ./scripts/travis/install-requirements.sh
# prep a travis-specific dev conf file that uses travis instead of stanley
- cp conf/st2.dev.conf "${ST2_CONF}" ; sed -i -e "s/stanley/travis/" "${ST2_CONF}"
- sudo scripts/travis/add-itest-user-key.sh
- sudo .circle/add-itest-user.sh
- if [[ "${TASK}" = *'-packs-tests'* ]] || [[ "${TASK}" = *'-integration'* ]]; then sudo scripts/travis/permissions-workaround.sh; fi
# Let's enable rabbitmqadmin
# See https://github.com/messagebus/lapine/wiki/Testing-on-Travis.
before_script:
# Use a custom mongod.conf which uses various speed optimizations
- sudo cp scripts/travis/mongod.conf /etc/mongod.conf
# Clean up any old MongoDB 3.4 data files laying around and make sure mongodb user can write to it
- sudo rm -rf /var/lib/mongodb ; sudo mkdir /var/lib/mongodb ; sudo chown -R mongodb:mongodb /var/lib/mongodb
- sudo service mongod restart ; sleep 5
- sudo service mongod status
- sudo tail -n 30 /var/log/mongodb/mongod.log
# Use custom RabbitMQ config which enables SSL / TLS listener on port 5671 with test certs
- sudo cp scripts/travis/rabbitmq.config /etc/rabbitmq/rabbitmq.config
# Install rabbitmq_management RabbitMQ plugin
- sudo service rabbitmq-server restart ; sleep 5
- sudo rabbitmq-plugins enable rabbitmq_management
- sudo wget http://guest:guest@localhost:15672/cli/rabbitmqadmin -O /usr/local/bin/rabbitmqadmin
- sudo chmod +x /usr/local/bin/rabbitmqadmin
- sudo service rabbitmq-server restart
# chmod to make glob work (*.log to avoid log dir)
- sudo chmod a+rx /var/log/rabbitmq ; sudo tail -n 30 /var/log/rabbitmq/*.log
# Print various binary versions
- mongod --version
- git --version
- pip --version
- virtualenv --version
# Print out various environment variables info
- make play
script:
# Clean up egg-info directories which get created when installing runners
# NOTE: We enable code coverage and per test timing information on master so build can take twice
# as long as PR builds
- if [[ "${TRAVIS_PULL_REQUEST}" = "false" ]] && [[ "${IS_NIGHTLY_BUILD}" = "no" ]]; then COMMAND_THRESHOLD=$(expr ${COMMAND_THRESHOLD} \* 2); fi; ./scripts/travis/time-command.sh "make ${TASK}" ${COMMAND_THRESHOLD}
# Run any additional nightly checks only as part of a nightly (cron) build
- if [[ "${IS_NIGHTLY_BUILD}" = "yes" ]]; then ./scripts/travis/run-nightly-make-task-if-exists.sh "${TASK}"; fi
# NOTE: We only generate and submit coverage report for master and version branches
# NOTE: We put this here and not after_success so build is marked as failed if this step fails
# See https://docs.travis-ci.com/user/customizing-the-build/#breaking-the-build
# https://github.com/travis-ci/travis-ci/issues/758#issuecomment-266756853
- if [[ ${TASK} = 'ci-unit' ]] || [[ ${TASK} = 'ci-integration' ]] && [[ "${ENABLE_COVERAGE}" = 'yes' ]]; then ./scripts/travis/submit-codecov-coverage.sh; fi
# Don't store cache for target PR branch (typically `master`), because it will be re-used for opened PRs
# See: https://docs.travis-ci.com/user/caching/#Pull-request-builds-and-caches
# Alternative: use strict pip pinning, including git-based pip packages
before_cache:
- if [[ "${TRAVIS_PULL_REQUEST}" = 'false' ]] && [[ "${IS_NIGHTLY_BUILD}" = "no" ]]; then rm -rf virtualenv/; fi
# We want to be notified when a master or nightly build fails
notifications:
# Post build failures to '#development' channel in 'stackstorm-community' Slack
slack:
rooms:
- secure: "FNkr3XL19+a3qYwnQg6GRiS7ixZkHAYzqdmp+Kse2JROOalPy5vVK0wrmBRDJWA1gDDt2mMAnqAwFwID9n7rQv/oD1Ai10q7lCFVMbdAM4+yjYuXJ4i8zW0P6MIvxCb39tvEjq7g55ynE2cInpJRZ11RfbG259jBCbSzBaBtMos="
on_pull_requests: false
on_success: change # default: always
on_failure: always # default: always