forked from qld-gov-au/ckanext-qgov
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.ahoy.yml
183 lines (155 loc) · 5.83 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
---
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 install-site
ahoy title "Build complete"
ahoy doctor
ahoy info 1
build-network:
usage: Ensure that the amazeeio network exists.
cmd: |
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 $(docker-compose ps -q postgres) 5432 | cut -d : -f 2)
ahoy line "Solr port on host : " $(docker port $(docker-compose 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: |
docker-compose up -d "$@"
sleep 10
docker-compose logs
ahoy cli "dockerize -wait tcp://ckan:5000 -timeout 1m"
if docker-compose logs | grep -q "\[Error\]"; then docker-compose logs; exit 1; fi
if docker-compose logs | grep -q "Exception"; then docker-compose logs; 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: 'if [ -f "docker-compose.yml" ]; then docker-compose down --volumes; fi'
start:
usage: Start existing Docker containers.
cmd: docker-compose start "$@"
stop:
usage: Stop running Docker containers.
cmd: docker-compose stop "$@"
restart:
usage: Restart all stopped and running Docker containers.
cmd: docker-compose restart "$@"
logs:
usage: Show Docker logs.
cmd: docker-compose logs "$@"
pull:
usage: Pull latest docker images.
cmd: if [ ! -z "$(docker image ls -q)" ]; then docker image ls --format \"{{.Repository}}:{{.Tag}}\" | grep amazeeio/ | grep -v none | xargs -n1 docker pull | cat; fi
cli:
usage: Start a shell inside CLI container or run a command.
cmd: if \[ "${#}" -ne 0 \]; then docker exec $(docker-compose ps -q ckan) sh -c '. ${APP_DIR}/scripts/activate; cd $APP_DIR;'" $*"; else docker exec $(docker-compose ps -q ckan) sh -c '. ${APP_DIR}/scripts/activate && cd $APP_DIR && sh'; fi
doctor:
usage: Find problems with current project setup.
cmd: .docker/scripts/doctor.sh "$@"
install-site:
usage: Install a site.
cmd: |
ahoy title "Installing a fresh site"
ahoy cli '$APP_DIR/scripts/init.sh'
clean:
usage: Remove containers and all build files.
cmd: |
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 $(docker-compose ps -q redis) redis-cli flushall > /dev/null
lint:
usage: Lint code.
cmd: |
ahoy cli "flake8 ${@:-ckanext}" || \
[ "${ALLOW_LINT_FAIL:-0}" -eq 1 ]
copy-local-files:
usage: Update files from local repo.
cmd: |
docker cp . $(docker-compose ps -q ckan):/srv/app/
docker cp .docker/scripts $(docker-compose ps -q ckan):/srv/app/
docker cp .docker/scripts/ckan_cli $(docker-compose ps -q ckan):/usr/bin/
ahoy cli 'chmod -v u+x /usr/bin/ckan_cli; cp -v .docker/test.ini $CKAN_INI'
test-unit:
usage: Run unit tests.
cmd: |
ahoy cli 'pytest --ckan-ini=${CKAN_INI} $APP_DIR/ckanext' || \
[ "${ALLOW_UNIT_FAIL:-0}" -eq 1 ]
test-bdd:
usage: Run BDD tests.
cmd: |
ahoy start-mailmock &
sleep 5 &&
ahoy cli "behave -k ${*:-test/features}" --tags @smoke && \
ahoy cli "behave -k ${*:-test/features}" || \
[ "${ALLOW_BDD_FAIL:-0}" -eq 1 ]
ahoy stop-mailmock
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"
# 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}}"