-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.ahoy.yml
272 lines (238 loc) · 9.32 KB
/
.ahoy.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
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
---
ahoyapi: v2
commands:
# Docker commands.
build:
usage: Build or rebuild project.
cmd: |
ahoy title "Building project"
ahoy pre-flight
ahoy clean
ahoy build-network
ahoy up -- --build --force-recreate
ahoy title "Build complete"
ahoy doctor
ahoy info 1
build-network:
usage: Ensure that the amazeeio network exists.
cmd: |
ahoy title "Creating amazeeio Docker network"
docker network prune -f > /dev/null
docker network inspect amazeeio-network > /dev/null || docker network create amazeeio-network
info:
usage: Print information about this project.
cmd: |
ahoy line "Project : " ${PROJECT}
ahoy line "Site local URL : " ${LAGOON_LOCALDEV_URL}
ahoy line "DB port on host : " $(docker port $(sh bin/docker-compose.sh ps -q postgres) 5432 | cut -d : -f 2)
ahoy line "Solr port on host : " $(docker port $(sh bin/docker-compose.sh ps -q solr) 8983 | cut -d : -f 2)
ahoy line "Mailhog URL : " http://mailhog.docker.amazee.io/
up:
usage: Build and start Docker containers.
cmd: |
ahoy title "Building and starting Docker containers"
sh bin/docker-compose.sh up -d "$@"
echo "Initialising database schema"
ahoy cli '"${APP_DIR}"/bin/init.sh'
echo "Waiting for containers to start listening..."
for i in `seq 1 60`; do
if (ahoy cli "timeout 1 bash -c 'cat < /dev/null > /dev/tcp/ckan/5000'"); then
echo "CKAN became ready on attempt $i"
break
else
echo "CKAN not yet ready, retrying (attempt $i)..."
sleep 1
fi
done
if sh bin/docker-compose.sh logs | grep -q "\[Error\]"; then exit 1; fi
if sh bin/docker-compose.sh logs | grep -q "Exception"; then exit 1; fi
docker ps -a --filter name=^/${COMPOSE_PROJECT_NAME}_
export DOCTOR_CHECK_CLI=0
down:
usage: Stop Docker containers and remove container, images, volumes and networks.
cmd: |
ahoy title 'Stopping and removing old containers, images, volumes, networks'
if [ -f "docker-compose.yml" ]; then sh bin/docker-compose.sh down --volumes; fi
start:
usage: Start existing Docker containers.
cmd: sh bin/docker-compose.sh start "$@"
stop:
usage: Stop running Docker containers.
cmd: sh bin/docker-compose.sh stop "$@"
restart:
usage: Restart all stopped and running Docker containers.
cmd: sh bin/docker-compose.sh restart "$@"
logs:
usage: Show Docker logs.
cmd: |
ahoy title "Output logs"
# Loop through each container and wrap with github log groups
services=$(bin/docker-compose.sh ps --services)
for service in $services; do
echo "::group::$service"
sh bin/docker-compose.sh logs "$service"
echo "::endgroup::"
done
pull:
usage: Pull latest docker images.
cmd: if [ ! -z "$(docker image ls -q)" ]; then docker image ls --format \"{{.Repository}}:{{.Tag}}\" | grep ckan/ckan- | grep -v none | xargs -n1 docker pull | cat; fi
cli:
usage: Start a shell inside CLI container or run a command.
cmd: |
CKAN_CONTAINER=$(sh bin/docker-compose.sh ps -q ckan)
if [ "${#}" -ne 0 \]; then
docker exec $CKAN_CONTAINER sh -c '. "${APP_DIR}"/bin/activate; cd $APP_DIR;'" $*"
else
docker exec $CKAN_CONTAINER sh -c '. "${APP_DIR}"/bin/activate && cd $APP_DIR && sh'
fi
doctor:
usage: Find problems with current project setup.
cmd: bin/doctor.sh "$@"
install-site:
usage: Install test site data.
cmd: |
ahoy title "Installing a fresh site"
ahoy cli '"${APP_DIR}"/bin/init.sh && "${APP_DIR}"/bin/create-test-data.sh'
clean:
usage: Remove containers and all build files.
cmd: |
ahoy title "Cleaning up old builds"
ahoy down
# Remove other directories.
# @todo: Add destinations below.
rm -rf \
./ckan
reset:
usage: "Reset environment: remove containers, all build, manually created and Drupal-Dev files."
cmd: |
ahoy clean
git ls-files --others -i --exclude-from=.git/info/exclude | xargs chmod 777
git ls-files --others -i --exclude-from=.git/info/exclude | xargs rm -Rf
find . -type d -not -path "./.git/*" -empty -delete
flush-redis:
usage: Flush Redis cache.
cmd: docker exec -i $(sh bin/docker-compose.sh ps -q redis) redis-cli flushall > /dev/null
lint:
usage: Lint code.
cmd: |
ahoy title 'Check for lint'
ahoy cli "flake8 ${@:-ckanext}" || \
[ "${ALLOW_LINT_FAIL:-0}" -eq 1 ]
copy-local-files:
usage: Update files from local repo.
cmd: |
docker cp . $(sh bin/docker-compose.sh ps -q ckan):/srv/app/
docker cp bin/ckan_cli $(sh bin/docker-compose.sh ps -q ckan):/usr/bin/
ahoy cli 'chmod -v u+x /usr/bin/ckan_cli "${APP_DIR}"/bin/*; cp -v .docker/ckan.ini $CKAN_INI; "${APP_DIR}"/bin/process-config.sh'
test-unit:
usage: Run unit tests.
cmd: |
ahoy title 'Run unit tests'
ahoy cli 'pytest --ckan-ini=.docker/test.ini "${APP_DIR}"/ckanext --junit-xml=test/junit/results.xml' || \
[ "${ALLOW_UNIT_FAIL:-0}" -eq 1 ]
test-unit-failed-rerun:
usage: Run unit tests.
cmd: |
ahoy title 'Re-run unit tests'
ahoy cli 'pytest --lf --ckan-ini=.docker/test.ini "${APP_DIR}"/ckanext --junit-xml=test/junit/results.xml' || \
[ "${ALLOW_UNIT_FAIL:-0}" -eq 1 ]
test-bdd:
usage: Run BDD tests.
cmd: |
ahoy title 'Run scenario tests'
ahoy cli "rm -f test/screenshots/*"
ahoy start-ckan-job-workers
ahoy start-mailmock &
sleep 5
JUNIT_OUTPUT="--junit --junit-directory=test/junit/"
if [ "$BEHAVE_TAG" = "" ]; then
# no tag specified, probably running locally
(ahoy cli "behave $JUNIT_OUTPUT -k ${*:-test/features} --tags=smoke" \
&& ahoy cli "behave $JUNIT_OUTPUT -k ${*:-test/features} --tags=-smoke"
) || [ "${ALLOW_BDD_FAIL:-0}" -eq 1 ]
elif [ "$BEHAVE_TAG" = "authenticated" ]; then
# run any tests that don't have a specific tag
ahoy cli "behave $JUNIT_OUTPUT -k ${*:-test/features} --tags=-unauthenticated --tags=-smoke --tags=-OpenData --tags=-multi_plugin" \
|| [ "${ALLOW_BDD_FAIL:-0}" -eq 1 ]
else
if [ "$BEHAVE_TAG" != "multi_plugin" ]; then
BEHAVE_TAG="$BEHAVE_TAG --tags=-multi_plugin"
fi
# run tests with the specified tag
ahoy cli "behave $JUNIT_OUTPUT -k ${*:-test/features} --tags=$BEHAVE_TAG" \
|| [ "${ALLOW_BDD_FAIL:-0}" -eq 1 ]
fi
ahoy stop-mailmock
ahoy stop-ckan-job-workers
start-mailmock:
usage: Starts email mock server used for email BDD tests
cmd: |
ahoy title 'Starting mailmock'
ahoy cli 'mailmock -p 8025 -o "${APP_DIR}"/test/emails' # for debugging mailmock email output remove --no-stdout
stop-mailmock:
usage: Stops email mock server used for email BDD tests
cmd: |
ahoy title 'Stopping mailmock'
ahoy cli "killall -2 mailmock"
start-ckan-job-workers:
usage: Starts CKAN background job workers
cmd: |
ahoy title 'Starting CKAN background job workers'
ahoy start-ckan-job-worker-default &
ahoy start-ckan-job-worker-priority &
ahoy start-ckan-job-worker-bulk &
start-ckan-job-worker-default:
usage: Starts default CKAN background job worker
cmd: |
ahoy title 'Starting default CKAN background job worker'
ahoy cli "ckan_cli jobs worker"
start-ckan-job-worker-priority:
usage: Starts CKAN background job worker for priority tasks
cmd: |
ahoy title 'Starting CKAN background job worker priority'
ahoy cli "ckan_cli jobs worker priority"
start-ckan-job-worker-bulk:
usage: Starts CKAN background job worker for low-priority tasks
cmd: |
ahoy title 'Starting CKAN background job worker bulk'
ahoy cli "ckan_cli jobs worker bulk"
stop-ckan-job-workers:
usage: Stops CKAN background job worker
cmd: |
ahoy title 'Stopping CKAN background job worker'
ahoy cli "ckan_cli jobs clear; \
ckan_cli jobs clear priority; \
ckan_cli jobs clear bulk;
(pgrep 'jobs worker' && pkill -f 'jobs worker') || true"
# Utilities.
title:
cmd: printf "$(tput -Txterm setaf 4)==> ${1}$(tput -Txterm sgr0)\n"
hide: true
line:
cmd: printf "$(tput -Txterm setaf 2)${1}$(tput -Txterm sgr0)${2}\n"
hide: true
getvar:
cmd: eval echo "${@}"
hide: true
pre-flight:
cmd: |
export DOCTOR_CHECK_DB=${DOCTOR_CHECK_DB:-1}
export DOCTOR_CHECK_TOOLS=${DOCTOR_CHECK_TOOLS:-1}
export DOCTOR_CHECK_PORT=${DOCTOR_CHECK_PORT:-0}
export DOCTOR_CHECK_PYGMY=${DOCTOR_CHECK_PYGMY:-1}
export DOCTOR_CHECK_CLI=${DOCTOR_CHECK_CLI:-0}
export DOCTOR_CHECK_SSH=${DOCTOR_CHECK_SSH:-0}
export DOCTOR_CHECK_WEBSERVER=${DOCTOR_CHECK_WEBSERVER:-0}
export DOCTOR_CHECK_BOOTSTRAP=${DOCTOR_CHECK_BOOTSTRAP:-0}
ahoy doctor
hide: true
entrypoint:
- bash
- "-c"
- "-e"
- |
export LAGOON_LOCALDEV_URL=http://$PROJECT.docker.amazee.io
[ -f .env ] && [ -s .env ] && export $(grep -v '^#' .env | xargs) && if [ -f .env.local ] && [ -s .env.local ]; then export $(grep -v '^#' .env.local | xargs); fi
bash -e -c "$0" "$@"
- "{{cmd}}"
- "{{name}}"