forked from govCMS/lagoon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
239 lines (217 loc) · 6.28 KB
/
.gitlab-ci.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
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
---
image: govcms/govcms-ci:latest
services:
- "docker:dind"
stages:
- validate
- build
- test
- deploy
.before_script_common: &before_script_common |-
cp .env.default .env
.variables: &vars
# LAGOON_IMAGE_VERSION: "v1.1.2"
# DRUPAL_CORE_VERSION: "8.7.9 "
# GOVCMS_PROJECT_VERSION: "1.x-dev"
# SITE_AUDIT_VERSION: "7.x-3.x"
# PHP_IMAGE_VERSION: "7.2"
DOCKERHUB_NAMESPACE: "govcms8lagoon"
IMAGE_VERSION_TAG_PREFIX: ""
IMAGE_VERSION_TAG: ""
IMAGE_TAG_EDGE: $CI_COMMIT_SHA
.test: &test
variables:
<< : *vars
before_script:
- *before_script_common
# @TODO: Re-instate container caching.
# - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
# - IMAGE_TAG_EDGE=$CI_COMMIT_SHA DOCKER_REGISTRY_HOST=$CI_REGISTRY/ DOCKERHUB_NAMESPACE=dof-dev/govcms8lagoon .docker/pull.sh
- docker network prune -f && docker network inspect amazeeio-network >/dev/null || docker network create amazeeio-network
- ahoy build
- ahoy up
.test-diff: &test-diff
variables:
<<: *vars
DOCKER_CONFIG: ~/.docker
stage: test
artifacts:
paths:
- $CI_PROJECT_DIR/logs
before_script:
- curl -LO https://storage.googleapis.com/container-diff/latest/container-diff-linux-amd64 && chmod +x container-diff-linux-amd64
- mkdir -p $HOME/bin
- export PATH=$PATH:$HOME/bin
- mv container-diff-linux-amd64 $HOME/bin/container-diff
- docker network prune -f && docker network inspect amazeeio-network >/dev/null || docker network create amazeeio-network
- ahoy build
script:
- mkdir logs
- |
for SERVICE in chrome govcms8 mariadb-drupal php redis solr test varnish-drupal; do
$HOME/bin/container-diff diff --type=file daemon://${DOCKERHUB_NAMESPACE}/$SERVICE remote://registry.hub.docker.com/${DOCKERHUB_NAMESPACE}/$SERVICE:latest --output logs/$SERVICE.txt
done
needs:
- build:containers
.deploy: &deploy
stage: deploy
before_script:
- *before_script_common
# @TODO: Re-instate container caching.
# - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
# - IMAGE_TAG_EDGE=$CI_COMMIT_SHA DOCKER_REGISTRY_HOST=$CI_REGISTRY/ DOCKERHUB_NAMESPACE=dof-dev/govcms8lagoon .docker/pull.sh
# - docker logout
- docker login -u $DOCKER_USER -p $DOCKER_PASS
- docker network prune -f && docker network inspect amazeeio-network >/dev/null || docker network create amazeeio-network
- ahoy build
script:
- ahoy push
validate:containers:
stage: validate
script:
- docker-compose config -q
build:containers:
variables:
<<: *vars
DOCKER_REGISTRY_HOST: $CI_REGISTRY/
DOCKERHUB_NAMESPACE: dof-dev/govcms8lagoon
stage: build
before_script:
- *before_script_common
script:
# @TODO: Re-instate container caching.
# - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- docker network prune -f && docker network inspect amazeeio-network >/dev/null || docker network create amazeeio-network
- ahoy -v build
- docker-compose exec -T test dockerize -wait tcp://mariadb:3306 -timeout 1m
# @TODO: Re-instate container caching.
# - .docker/push.sh
#
# Container diffing requires pushing images into the gitlab registry.
# This should be reinstated when container caching has been ironed out.
#
# test:diff-edge:
# <<: *test-diff
# variables:
# <<: *vars
# IMAGE_TAG_EDGE: edge
# IMAGE_VERSION_TAG: edge
# only:
# - develop
# test:diff-beta:
# <<: *test-diff
# variables:
# <<: *vars
# IMAGE_TAG_EDGE: beta
# IMAGE_VERSION_TAG: beta
# only:
# - master
# test:diff-latest:
# <<: *test-diff
# variables:
# <<: *vars
# IMAGE_TAG_EDGE: latest
# IMAGE_VERSION_TAG: latest
# only:
# - tags
test:containers:
<<: *test
stage: test
script:
- ./tests/goss/run_all.sh
needs:
- build:containers
test:redis:
<<: *test
stage: test
script:
- ahoy -v install
- docker-compose exec -T --env ENABLE_REDIS=true cli drush status
- |
if [ $(docker-compose exec -T redis redis-cli KEYS '*' | wc -l) -le 1 ]; then
echo 'Redis fail: No valid cache keys.'
exit 1
else
echo "Redis success: Redis contains $redisKeys keys."
fi
needs:
- build:containers
test:site_install:
<<: *test
stage: test
script:
- ahoy -v install -- install_configure_form.update_status_module='array(FALSE,FALSE)'
needs:
- build:containers
test:nginx:
<<: *test
stage: test
script:
# Wait for nginx container.
- docker-compose exec -T test dockerize -wait tcp://nginx:8080 -timeout 1m
# Validate nginx configuration.
- docker-compose exec -T nginx nginx -t
# Validate composer.json and composer.lock configuration for tests.
- composer validate --strict -d .docker/images/nginx/tests
# Install dependencies for tests.
- composer install -d .docker/images/nginx/tests
# Run tests and store logs in artifacts directory.
- .docker/images/nginx/tests/vendor/bin/phpunit -c .docker/images/nginx/tests/phpunit.xml
needs:
- build:containers
test:drupal_versions:
<<: *test
stage: test
variables:
<< : *vars
script:
- ahoy -v install -- install_configure_form.update_status_module='array(FALSE,FALSE)'
- docker-compose exec -T cli drush status
- /govcms/vendor/bin/govcms-module_verify
only:
- schedules
artifacts:
paths:
- modules.csv
deploy:edge:
<<: *deploy
variables:
<<: *vars
IMAGE_TAG_EDGE: edge
DOCKERHUB_NAMESPACE: "govcms8lagoon"
COMPOSE_PROJECT_NAME: "govcms8lagoon"
only:
- develop
except:
- schedules
deploy:beta:
<<: *deploy
variables:
<<: *vars
IMAGE_TAG_EDGE: beta
DOCKERHUB_NAMESPACE: "govcms8lagoon"
COMPOSE_PROJECT_NAME: "govcms8lagoon"
only:
- master
except:
- schedules
# @TODO: Allow automatic deploys of latest and tags after
# the process has been validated.
# deploy:latest:
# <<: *deploy
# variables:
# <<: *vars
# IMAGE_TAG_EDGE: latest
# DOCKERHUB_NAMESPACE: "govcms8lagoon"
# COMPOSE_PROJECT_NAME: "govcms8lagoon"
# only:
# - tags
# deploy:tag:
# <<: *deploy
# variables:
# <<: *vars
# IMAGE_TAG_EDGE: $CI_COMMIT_TAG
# DOCKERHUB_NAMESPACE: "govcms8lagoon"
# COMPOSE_PROJECT_NAME: "govcms8lagoon"
# only:
# - tags