blob: ed6ce40943250684d63803fbd977898e758e53aa (
plain)
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
# References:
# 1. https://circleci.com/blog/how-to-build-a-docker-image-on-circleci-2-0/
# 2. https://circleci.com/docs/2.0/building-docker-images/
#
version: 2
defaults:
bmo_slim_image: &bmo_slim_image
image: mozillabteam/bmo-slim:20180523.1
user: app
mysql_image: &mysql_image
image: mozillabteam/bmo-mysql:5.6
store_log: &store_log
store_artifacts:
path: /app/bugzilla.log
destination: bugzilla.log
main_filters: &main_filters
branches:
ignore:
- /^(?:release|test)-20\d\d\d\d\d\d\.\d+/
- /\//
- production
bmo_env: &bmo_env
PORT: 8000
LOGGING_PORT: 5880
LOCALCONFIG_ENV: 1
LOG4PERL_CONFIG_FILE: log4perl-test.conf
BMO_db_user: bugs
BMO_db_host: 127.0.0.1
BMO_db_pass: bugs
BMO_db_name: bugs
BMO_memcached_servers: localhost:11211
BMO_memcached_namespace: "bugzilla:"
BMO_urlbase: AUTOMATIC
mysql_env: &mysql_env
MYSQL_DATABASE: bugs
MYSQL_USER: bugs
MYSQL_PASSWORD: bugs
MYSQL_ALLOW_EMPTY_PASSWORD: 1
docker_oldtests: &docker_oldtests
- <<: *bmo_slim_image
environment:
<<: *bmo_env
BZ_QA_CONF_FILE: /app/.circleci/selenium_test.conf
BZ_QA_ANSWERS_FILE: /app/.circleci/checksetup_answers.legacy.txt
BZ_QA_LEGACY_MODE: 1
- <<: *mysql_image
environment: *mysql_env
- image: selenium/standalone-firefox:2.53.1
- image: memcached:latest
default_qa_setup: &default_qa_setup
run:
name: default qa setup
command: |
[[ -f build_info/only_version_changed.txt ]] && exit 0
mv /opt/bmo/local /app/local
perl -MSys::Hostname -i -pE 's/bmo.test/hostname() . ":$ENV{PORT}"/ges' $BZ_QA_CONF_FILE
perl checksetup.pl --no-database --default-localconfig
mkdir artifacts
jobs:
build_info:
parallelism: 1
working_directory: /app
docker:
- <<: *bmo_slim_image
environment:
<<: *bmo_env
steps:
- checkout
- run:
name: build push data
command: |
mv /opt/bmo/local /app/local
perl Makefile.PL
perl -I/app -I/app/local/lib/perl5 -MBugzilla -e 1
perl checksetup.pl --no-database --no-templates --no-permissions
perl scripts/build-bmo-push-data.pl
- run:
name: only publish if tag exists
command: |
tag="$(cat build_info/tag.txt)"
git fetch --tags
if git tag | fgrep -q "$tag"; then
echo "tag $tag exists!"
else
echo "tag $tag does not exist"
echo yes > build_info/publish.txt
fi
- run:
name: check if only version changed
command: |
if git diff 'HEAD~..HEAD' --name-only | grep -qv '^Bugzilla.pm'; then
echo "more files than just Bugzilla.pm changed."
exit 0
fi
if git diff 'HEAD~..HEAD' |grep '^[+-][^+-]' | grep -qv '^[+-]our $VERSION'; then
echo "Something other than the version number changed."
exit 0
fi
if [[ "$CIRCLE_BRANCH" == "master" ]]; then
echo "Can't cut corners on the master branch"
exit 0
fi
echo yes > build_info/only_version_changed.txt
- persist_to_workspace:
root: /app/build_info
paths: ["*.txt"]
- store_artifacts:
path: /app/build_info
- *store_log
build:
working_directory: /app
docker:
- image: docker:17.06.1-ce
steps:
- setup_remote_docker
- run:
name: install git and ssh
command: apk update && apk add git openssh-client
- checkout
- run: |
docker build \
--build-arg CI="$CI" \
--build-arg CIRCLE_SHA1="$CIRCLE_SHA1" \
--build-arg CIRCLE_BUILD_URL="$CIRCLE_BUILD_URL" \
-t bmo .
- attach_workspace:
at: /app/build_info
- run: "docker run --name bmo --entrypoint true bmo"
- run: "docker cp bmo:/app/version.json build_info/version.json"
- store_artifacts:
path: /app/build_info
- *store_log
- deploy:
command: |
TAG="$(cat /app/build_info/tag.txt)"
[[ "$CIRCLE_BRANCH" == "master" ]] || exit 0
[[ -n "$DOCKERHUB_REPO" && -n "$DOCKER_USER" && -n "$DOCKER_PASS" ]] || exit 0
[[ -n "$GITHUB_PERSONAL_TOKEN" ]] || exit 0
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
if [[ -n "$TAG" && -f build_info/publish.txt ]]; then
git config credential.helper "cache --timeout 120"
git config user.email "$GITHUB_EMAIL"
git config user.name "$GITHUB_NAME"
git tag $TAG
git push https://${GITHUB_PERSONAL_TOKEN}:x-oauth-basic@github.com/$GITHUB_REPO.git $TAG
docker tag bmo "$DOCKERHUB_REPO:$TAG"
docker push "$DOCKERHUB_REPO:$TAG"
fi
docker tag bmo "$DOCKERHUB_REPO:latest"
docker push "$DOCKERHUB_REPO:latest"
test_sanity:
parallelism: 1
working_directory: /app
docker:
- <<: *bmo_slim_image
environment: *bmo_env
steps:
- checkout
- attach_workspace:
at: /app/build_info
- run: |
[[ -f build_info/only_version_changed.txt ]] && exit 0
mv /opt/bmo/local /app/local
mkdir artifacts
- run: |
[[ -f build_info/only_version_changed.txt ]] && exit 0
perl -I/app -I/app/local/lib/perl5 -c -E 'use Bugzilla; BEGIN { Bugzilla->extensions }'
- run: |
[[ -f build_info/only_version_changed.txt ]] && exit 0
perl Makefile.PL
- run:
name: run sanity tests
command: |
[[ -f build_info/only_version_changed.txt ]] && exit 0
/app/scripts/entrypoint.pl prove -qf $(circleci tests glob 't/*.t' | circleci tests split) | tee artifacts/$CIRCLE_JOB.txt
- store_artifacts:
path: /app/artifacts
- *store_log
test_webservices:
parallelism: 1
working_directory: /app
docker: *docker_oldtests
steps:
- checkout
- attach_workspace:
at: /app/build_info
- *default_qa_setup
- run: |
[[ -f build_info/only_version_changed.txt ]] && exit 0
/app/scripts/entrypoint.pl load_test_data
- run: |
[[ -f build_info/only_version_changed.txt ]] && exit 0
/app/scripts/entrypoint.pl test_webservices | tee artifacts/$CIRCLE_JOB.txt
- store_artifacts:
path: /app/artifacts
- *store_log
test_selenium:
parallelism: 1
working_directory: /app
docker: *docker_oldtests
steps:
- checkout
- attach_workspace:
at: /app/build_info
- *default_qa_setup
- run: |
[[ -f build_info/only_version_changed.txt ]] && exit 0
/app/scripts/entrypoint.pl load_test_data --legacy
- run: |
[[ -f build_info/only_version_changed.txt ]] && exit 0
/app/scripts/entrypoint.pl test_selenium | tee artifacts/$CIRCLE_JOB.txt
- store_artifacts:
path: /app/artifacts
- *store_log
test_bmo:
parallelism: 1
working_directory: /app
docker:
- <<: *bmo_slim_image
environment:
<<: *bmo_env
BZ_QA_ANSWERS_FILE: /app/.circleci/checksetup_answers.txt
TWD_HOST: localhost
TWD_PORT: 4444
TWD_BROWSER: firefox
- <<: *mysql_image
environment: *mysql_env
- image: memcached:latest
- image: selenium/standalone-firefox:2.53.1
steps:
- checkout
- attach_workspace:
at: /app/build_info
- run: |
[[ -f build_info/only_version_changed.txt ]] && exit 0
mv /opt/bmo/local /app/local
perl checksetup.pl --no-database
/app/scripts/entrypoint.pl load_test_data
mkdir artifacts
- run: |
[[ -f build_info/only_version_changed.txt ]] && exit 0
/app/scripts/entrypoint.pl test_bmo -q -f t/bmo/*.t
- *store_log
workflows:
version: 2
main:
jobs:
- build_info:
filters: *main_filters
- build:
filters: *main_filters
requires:
- build_info
- test_sanity
- test_bmo
- test_webservices
- test_selenium
- test_sanity:
filters: *main_filters
requires:
- build_info
- test_bmo:
filters: *main_filters
requires:
- build_info
- test_webservices:
filters: *main_filters
requires:
- build_info
- test_selenium:
filters: *main_filters
requires:
- build_info
|