This repository has been archived by the owner on Aug 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
.travis.yml
91 lines (91 loc) · 6.49 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
dist: xenial
language: python
matrix:
include:
# In addition to the base python version, we need the full python version to identify the docker
# images. It is defined as the DOCKER_PYTHON_VERSION because it may not be the same version as point
# release as used on Travis (ie 2.7.14 on Travis vs 2.7.15 in the docker image as of Sept 2018).
- python: 2.7
env: DOCKER_PYTHON_VERSION=2.7.15
- python: 3.6
env: DOCKER_PYTHON_VERSION=3.6.7
- python: 3.7
env: DOCKER_PYTHON_VERSION=3.7.1
sudo: required
services:
- docker
# Use cache with pip to save time.
cache: pip
before_install:
- docker pull rehlers/overwatch:latest-py${DOCKER_PYTHON_VERSION}
# Needed for ZODB python 3 compatibility
- if [[ "${DOCKER_PYTHON_VERSION}" == "3."* ]]; then pip install git+https://github.com/SpotlightKid/flask-zodb.git; fi
install: pip install --upgrade -e .[tests,dev,docs]
before_script:
# Runs the tests in a docker container. Necessary because we can't install ROOT easily here.
# Further, we run in the tests directory to avoid any possible config.yaml interfering with the tests.
# Since we mount the Travis overwatch directory inside of the container, the results should still be
# available even after this docker container has stopped
# To use codecov, we first retrieve the variables necessary to pass to the container (via codecov),
# and then we send the results from inside the container to codecov. If we try to send afterwards from
# outside the container, the paths will be wrong and the coverage report will fail!
- ci_env=`bash <(curl -s https://codecov.io/env)`
# Needs to run as root so that it can successfully write back into the travis environment.
- docker run --user root -v ${PWD}:/opt/overwatch $ci_env rehlers/overwatch:latest-py${DOCKER_PYTHON_VERSION} /bin/bash -c "pip install --user --upgrade -e .[tests,dev,docs]; cd tests; pytest -l -vv --cov=overwatch --cov-branch --durations=5 . && bash <(curl -s https://codecov.io/bash)"
# Install polymer and jsRoot so it they will be avialable and included in a built package
# We can't easily install nodejs to install polymer and jsRoot, so instead, we extract it from the
# docker image. Yes, it's super hacky, but it seems to work, so why not?
- docker run --user root -v ${PWD}/overwatch/webApp/static/:/opt/extractJS rehlers/overwatch:latest-py${DOCKER_PYTHON_VERSION} /bin/bash -c "cd overwatch/webApp/static && cp -r bower_components /opt/extractJS/. && cp -r jsRoot /opt/extractJS/."
script:
# Since we ran the tests above, we don't need to run them here.
# Check code quality
- flake8 .
# Check that the docs build successfully
- pushd doc && make html && popd
after_success:
# This will work for both tags and standard buidls. The build is performed for PRs, but it won't be
# deplyoed. First, determine the Overwatch branch. If ${TRAVIS_BRANCH} is the same as ${TRAVIS_TAG},
# then means that we're working with a tag and we should use the master branch (which won't be
# available under $TRAVIS_BRANCH because the branch is not available when building a tag). Otherwise,
# we just use $TRAVIS_BRANCH
- if [[ ${TRAVIS_BRANCH} == ${TRAVIS_TAG} ]]; then OVERWATCH_BRANCH="master"; else OVERWATCH_BRANCH=${TRAVIS_BRANCH}; fi
# NOTE: To be clear about what is done here, we set PYTHON_VERSION in the docker build to the variable
# ${DOCKER_PYTHON_VERSION}.
# NOTE: For an unclear reason, the docker build exit code doesn't seem to always propagate to fully
# propagate to Travis.
- pushd docker && docker build --build-arg PYTHON_VERSION=${DOCKER_PYTHON_VERSION} --build-arg OVERWATCH_BRANCH=${OVERWATCH_BRANCH} -f Dockerfile -t "${DOCKER_USERNAME}/overwatch:${TRAVIS_TAG:-latest}-py${DOCKER_PYTHON_VERSION}" . && popd
# Print out to see if we've build it as expected.
- docker images
before_deploy:
# Check for the required files and error out in case something when wrong.
# We only check for a few directories because if they exist, it is likely that everything worked.
- if [[ -d ${PWD}/overwatch/webApp/static/jsRoot/scripts && -d ${PWD}/overwatch/webApp/static/bower_components/polymer ]]; then true; else false; fi
deploy:
- provider: pypi
user: rehlers
password:
secure: jGJTAlpfNsTcZJbU24/m0GjxVzoWKBhKkloaKTqpZkrymDydX5K08DZn/U1y86/8HUB6gCT9L8ecOyecmWjwKQiGYt0wF3lyCjzjwd82nZWeWunsoMkVo9hkWwlh4+7jBd3QdYGH5DpI1DHK2RDwMAN5lUUa+qGTvnZzhxR/DVJcIva9XNFOYNKD6fDr3DvWw25Dhb5xL1ojl0silPYMXu8eXmO+x7Et4bdnzeU5eFZT//IPDJp4OGn1jCy9uXCgvE7s25ScHNPzY7WbTU2L1y07VHBOSPtkT5BIB7/HAipf2ydG7XR2YGl6U3X5cb4eqS4JDh9AUFhP1kNLx1uZWChraqeB7gXCbTcl6hNGNIQ16pEbFuwLaZkbmn75EvVBFkAzM0RpDMr+zCY4Sc0uJnEYj5xX1IDvS4qtAQdr31t0POwtuuUe6S0eL/8ikzGMHuX/OqwSPqlW4vvcvhdJkMwwL5RcJ2icBxuN5mK+JdmgMRHLuSopgA0d7v4Hi3EWPtcmjZ/vcS9gfx3cNQykqHYNCWCwWUaUQgbgn+SUb4efSxvqTtQizU40q9KJRbPEf1mQNFDF8nPb8a2f006LcR9Mnsb4l69azGBCRVTKPcF/UqK+B917pqJmXNOOeNomqHiNaEJej9ADJG0WrM2CqqyGAXye2eZz+iux9V7kKXI=
distributions: sdist bdist_wheel
# Skip cleanup because we added files from polymer and jsRoot.
skip_cleanup: true
on:
tags: true
# Only deploy the python 3 build by selecting on versions which start with 3. Either 2 or 3
# would be fine, but we only want to do one. Using build stages would be nice, but then we
# would need to upload the docker image and the polymer and jsRoot files. So we take the
# easier solution by just selecting one.
# Further, since there are multiple python 3 versions used in testing, we explicitly select 3.7 to
# deploy the tag to ensure that it doesn't try to deploy to PyPI twice (which will fail).
condition: ${DOCKER_PYTHON_VERSION} =~ ^3.7
- provider: script
# Variables are defined in the travis CI interface
# They include: $DOCKER_USERNAME, $DOCKER_PASSWORD
script: bash docker/pushToDockerHub.sh
# We don't need to skip cleanup here because the docker image is already built!
on:
# Build a docker image for master or if it has "-docker" in the branch name.
all_branches: true
# For whatever reason, since Travis is parsing this line, we can't quote the variable here
# We want it to build for branches that end in "-docker", "master" or for any tags of the form
# [number]+.[number]+ (ie tags which conform to semantic versioning).
condition: ${TRAVIS_BRANCH} =~ [a-zA-Z]+-docker|master|[0-9]+.[0-9]+