forked from xchem/fragalysis-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
154 lines (139 loc) · 5.38 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
---
# -----------------
# Control variables (Travis Settings)
# -----------------
#
# PUBLISH_IMAGES Should be 'yes' to enable publishing to Docker Hub.
#
# NOTE: Pull requests from forked repositories will not
# result in encrypted variables being set.
# So, regardless of the state of PUBLISH_IMAGES,
# images will only be published if DOCKER_PASSWORD is defined.
#
# If you set PUBLISH_IMAGES you must also set the following: -
#
# DOCKER_USERNAME If PUBLISH_IMAGES is 'yes'
# DOCKER_PASSWORD If PUBLISH_IMAGES is 'yes'
#
# You control the Backend container's source and destination image names with...
#
# BE_NAMESPACE To over-ride the default namespace of the image
# (which is 'xchem')
#
# To trigger the dependent, downstream builds (like the Stack and Loader)...
#
# TRIGGER_DOWNSTREAM Should be set to 'yes'
# Enabling TRIGGER_DOWNSTREAM is only effective
# if PUBLISH_IMAGES is also set.
#
# The following required if TRIGGER_DOWNSTREAM...
#
# TRAVIS_ACCESS_TOKEN A Travis token
#
# STACK_NAMESPACE To define the namespace of the Stack repository (default is 'xchem')
# STACK_BRANCH The branch to trigger (default is 'master')
# LOADER_NAMESPACE To define the namespace of the Loader repository (default is 'xchem')
# LOADER_BRANCH The branch to trigger (default is 'master')
os: linux
language: python
python:
- '3.8'
services:
- docker
stages:
- name: publish latest
if: |
branch = master \
AND env(PUBLISH_IMAGES) = yes
- name: trigger downstream
if: |
branch = master \
AND env(TRIGGER_DOWNSTREAM) = yes \
AND env(PUBLISH_IMAGES) = yes
- name: publish tag
if: |
tag IS present \
AND env(PUBLISH_IMAGES) = yes
- name: publish stable
if: |
tag IS present \
AND tag =~ ^([0-9]+\.){1,2}[0-9]+$ \
AND env(PUBLISH_IMAGES) = yes
# Global variables
# (available to the Job matrix)...
env:
global:
# The origin of the trigger code
- TRIGGER_ORIGIN=https://raw.githubusercontent.com/informaticsmatters/trigger-travis/2020.1
before_install:
# Downstream project triggers (used when we're tagged)
# The downstream projects are the Fragalysis Stack and Fragalysis Loader.
# The user can define the following variables in their Travis Settings.
# If they're not defined then apply sensible defaults.
- export BE_NAMESPACE=${BE_NAMESPACE:-xchem}
- export STACK_NAMESPACE=${STACK_NAMESPACE:-xchem}
- export STACK_BRANCH=${STACK_BRANCH:-master}
- export STACK_VARS=BE_IMAGE_TAG=latest,BE_NAMESPACE=${BE_NAMESPACE}
- export LOADER_NAMESPACE=${LOADER_NAMESPACE:-xchem}
- export LOADER_BRANCH=${LOADER_BRANCH:-master}
- export LOADER_VARS=BE_IMAGE_TAG=latest,BE_NAMESPACE=${BE_NAMESPACE}
install:
# Download trigger code
- curl --location --retry 3 ${TRIGGER_ORIGIN}/requirements.txt --output trigger-travis-requirements.txt
- curl --location --retry 3 ${TRIGGER_ORIGIN}/trigger-travis.py --output trigger-travis.py
- pip install -r trigger-travis-requirements.txt
- chmod +x trigger-travis.py
before_script:
- echo ${BE_NAMESPACE}
- echo ${STACK_NAMESPACE}
- echo ${PUBLISH_IMAGES}
- echo ${TRIGGER_DOWNSTREAM}
jobs:
include:
# Test-stage jobs...
- stage: publish latest
name: Test and Latest Container
script:
- docker build -t ${BE_NAMESPACE}/fragalysis-backend:latest .
- docker-compose -f docker-compose.test.yml up --build --exit-code-from tests --abort-on-container-exit
- if [ -n "$DOCKER_PASSWORD" ]; then
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
docker push ${BE_NAMESPACE}/fragalysis-backend:latest;
fi
# Publish-stage jobs...
# Every successful master build results in a latest image (above)
# and every tag results in a tagged image in Docker Hub.
# Tags that match a RegEx are considered 'official' tags
# and also result in a 'stable' image tag.
- stage: publish tag
name: Tagged Container
script:
- docker build -t ${BE_NAMESPACE}/fragalysis-backend:${TRAVIS_TAG} .
- if [ -n "$DOCKER_PASSWORD" ]; then
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
docker push ${BE_NAMESPACE}/fragalysis-backend:${TRAVIS_TAG};
fi
- stage: publish stable
name: Stable Container
script:
- if [ -n "$DOCKER_PASSWORD" ]; then
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
docker pull ${BE_NAMESPACE}/fragalysis-backend:${TRAVIS_TAG};
docker tag ${BE_NAMESPACE}/fragalysis-backend:${TRAVIS_TAG} ${BE_NAMESPACE}/fragalysis-backend:stable;
docker push ${BE_NAMESPACE}/fragalysis-backend:stable;
fi
- stage: trigger downstream
name: Trigger Downstream
script:
- if [ -n "$DOCKER_PASSWORD" ]; then
echo "STACK_NAMESPACE=${STACK_NAMESPACE}";
echo "STACK_BRANCH=${STACK_BRANCH}";
echo "STACK_VARS=${STACK_VARS}";
./trigger-travis.py --pro ${STACK_NAMESPACE} fragalysis-stack ${TRAVIS_ACCESS_TOKEN} --branch ${STACK_BRANCH} --vars ${STACK_VARS};
echo "LOADER_NAMESPACE=${LOADER_NAMESPACE}";
echo "LOADER_BRANCH=${LOADER_BRANCH}";
echo "LOADER_VARS=${LOADER_VARS}";
./trigger-travis.py --pro ${LOADER_NAMESPACE} fragalysis-loader ${TRAVIS_ACCESS_TOKEN} --branch ${LOADER_BRANCH} --vars ${LOADER_VARS};
fi
notifications:
slack: fragalysis:a6ADA8gLyx8tpHQfyzucMB8B