forked from slaclab/pysmurf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
158 lines (137 loc) · 4.66 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
146
147
148
149
150
151
152
153
154
155
156
157
158
os: linux
dist: bionic
language: python
python: 3.6
services:
- docker
env:
global:
- DOCKER_ORG_NAME=tidair
- DOCKER_SERVER_REPO=pysmurf-server-base
- DOCKER_CLIENT_REPO=pysmurf-client
# Install dependencies
addons:
apt:
packages:
- flake8
stages:
- checks
- tests
- name: deploy
if: tag IS present
jobs:
fast_finish: true
include:
# Check stages
## Flake8 checks
- stage: checks
name: "Flake8 Checks"
install:
- pip3 install flake8-rst-docstrings flake8-sfs flake8-import-order
script:
# Run Flake8
- flake8 --count python/
# Test stages
## Documentation automatic build tests
- stage: tests
name: "Documentation Build Tests"
install:
# Install requirements
- pip3 install -r requirements.txt
# Install pysmurf
- pip3 install .
# Install sphinx
- pip3 install sphinx
script:
# Try to build the documentation
- cd docs/
- make html SPHINXOPTS="-W --keep-going"
## Server tests
- stage: tests
name: "Server Tests"
install:
# Build the server docker
- cd docker/server/
- docker build --build-arg branch=$TRAVIS_BRANCH -t server_docker .
- cd -
before_script:
# Start the server container in the background
- |
docker run -dti --rm --name server \
--entrypoint bash \
server_docker
script:
# Try to import the smurf module in the server container
- |
docker exec server \
/bin/bash -c "python3 -c 'import rogue; import smurf;'"
# Try to import the pysmurf's SmurfProcessor module in the server container
- |
docker exec server \
/bin/bash -c "python3 -c 'import pysmurf.core.devices; \
s = pysmurf.core.devices.SmurfProcessor(name=\"\", description=\"\")'"
## Client tests
- stage: tests
name: "Client Tests"
install:
# Build the client docker
- cd docker/client/
- docker build --build-arg branch=$TRAVIS_BRANCH -t client_docker .
- cd -
before_script:
# Start the client container in the background
- |
docker run -dti --rm --name client \
--entrypoint bash \
client_docker
script:
# Try to import the pysmurf.client module in the client container
# Note: we need to disable the matplotlib graphics backend in order to
# be able to run in travis.
- |
docker exec client \
/bin/bash -c "python3 -c 'import matplotlib; matplotlib.use(\"Agg\"); import pysmurf.client'"
# Deployment stages
## Generate release notes
- stage: deploy
name: "Generate Release Notes"
before_script:
# Install dependencies of the releaseGen.py script
- pip3 install GitPython PyGithub
script:
# Generate a release using the releaseGen.py script
- python3 releaseGen.py
## Server docker
- stage: deploy
name: "Server Docker Image"
before_script:
# Use the git tag to tag tag docker image
- export DOCKER_TAG=`git describe --tags --always`
# Login to docker
- echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_ORG_NAME}" --password-stdin;
script:
# Build the docker image
- cd docker/server/
- docker build --build-arg branch=$TRAVIS_BRANCH -t ${DOCKER_ORG_NAME}/${DOCKER_SERVER_REPO} .
after_success:
# Upload docker image (as tagged and latest version)
- docker push ${DOCKER_ORG_NAME}/${DOCKER_SERVER_REPO};
- docker tag ${DOCKER_ORG_NAME}/${DOCKER_SERVER_REPO} ${DOCKER_ORG_NAME}/${DOCKER_SERVER_REPO}:${DOCKER_TAG};
- docker push ${DOCKER_ORG_NAME}/${DOCKER_SERVER_REPO}:${DOCKER_TAG};
## Client docker
- stage: deploy
name: "Client Docker Image"
before_script:
# Use the git tag to tag tag docker image
- export DOCKER_TAG=`git describe --tags --always`
# Login to docker
- echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_ORG_NAME}" --password-stdin;
script:
# Build the docker image
- cd docker/client/
- docker build --build-arg branch=$TRAVIS_BRANCH -t ${DOCKER_ORG_NAME}/${DOCKER_CLIENT_REPO} .
after_success:
# Upload docker image (as tagged and latest version)
- docker push ${DOCKER_ORG_NAME}/${DOCKER_CLIENT_REPO};
- docker tag ${DOCKER_ORG_NAME}/${DOCKER_CLIENT_REPO} ${DOCKER_ORG_NAME}/${DOCKER_CLIENT_REPO}:${DOCKER_TAG};
- docker push ${DOCKER_ORG_NAME}/${DOCKER_CLIENT_REPO}:${DOCKER_TAG};