forked from drevops/behat-steps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.ahoy.yml
171 lines (146 loc) · 6.89 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
---
ahoyapi: v2
commands:
# Docker commands.
build:
usage: Build or rebuild project.
cmd: |
ahoy title "Building project for Drupal $DRUPAL_VERSION"
ahoy clean
(docker network prune -f > /dev/null && docker network inspect amazeeio-network > /dev/null || docker network create amazeeio-network)
ahoy up -- --build --force-recreate
ahoy install-dev
ahoy install-site
ahoy title "Build complete"
ahoy info 1
info:
usage: Print information about this project.
cmd: |
ahoy line "Project : " $(ahoy cli echo \${PROJECT})
ahoy line "Drupal version : " $(ahoy cli echo \$DRUPAL_VERSION)
ahoy line "Site local URL : " $(ahoy cli echo \$LOCALDEV_URL)
ahoy line "Path to project : " $(ahoy cli echo /app)
ahoy line "Path to web root : " $(ahoy cli echo /app/build/web)
ahoy line "DB port on host : " $(docker port $(docker-compose ps -q mariadb) 3306 | cut -d : -f 2)
ahoy line "Xdebug : " $(ahoy cli php -v|grep -q Xdebug && echo "Enabled" || echo "Disabled")
if [ "$1" ]; then
ahoy line "One-time login : " $(ahoy login -- --no-browser)
fi
up:
usage: Build and start Docker containers.
cmd: |
docker-compose up -d "$@"
sleep 10 # Wait for DB container to come up without using Dockerize.
if docker-compose logs | grep -q "\[Error\]"; then docker-compose logs; exit 1; fi
docker ps -a --filter name=^/${COMPOSE_PROJECT_NAME:-behat-steps}_
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 -i $(docker-compose ps -q cli) bash -c "$*"; else docker exec -it $(docker-compose ps -q cli) bash; fi
drush:
usage: Run drush commands in the CLI service container.
cmd: docker-compose exec -T cli bash -c "drush -r /app/build/web -l \${LOCALDEV_URL} $*"
# Application commands.
login:
usage: Login to a website.
cmd: ahoy drush uublk 1 -q && ahoy drush uli "$@"
install-site:
usage: Install a fixture test site.
cmd: |
ahoy title "Installing fixture Drupal $DRUPAL_VERSION site"
# Remove exiting build assets.
ahoy cli "chmod -Rf 777 /app/build/web || true; rm -Rf /app/build/web || true; rm -Rf /app/build/vendor || true; mkdir -p /app/build/web"
# Copy fixture files to the build dir.
ahoy cli "cp -Rf /app/tests/behat/fixtures/d\$DRUPAL_VERSION/. /app/build/"
# In CI, where volume mounting into container is not supported, copy all files into container.
[ ${CI+x} ] && docker cp -L . $(docker-compose ps -q cli):/app/ || true
# Copy tool configs and tests into build dir.
docker cp -L phpcs.xml $(docker-compose ps -q cli):/app/build
docker cp -L behat.yml $(docker-compose ps -q cli):/app/build
docker cp -L tests $(docker-compose ps -q cli):/app/build
# Install Composer dependencies inside of the build dir.
ahoy cli "COMPOSER_MEMORY_LIMIT=-1 composer --working-dir=/app/build install --prefer-dist --no-suggest"
# Install Drupal site.
ahoy cli "/usr/bin/env PHP_OPTIONS='-d sendmail_path=/bin/true' /app/build/vendor/bin/drush -r /app/build/web si standard -y --db-url=mysql://drupal:drupal@mariadb/drupal --account-name=admin --account-pass=admin install_configure_form.enable_update_status_module=NULL install_configure_form.enable_update_status_emails=NULL --uri=http://nginx"
# Run post-install commands defined in the composer.json for each sepecific fixture.
ahoy cli "composer --working-dir=/app/build drupal-post-install"
# Copy test fixture.
ahoy cli "cp /app/tests/behat/fixtures/relative.html /app/build/web/sites/default/files/relative.html"
clean:
usage: Remove containers and all build files.
cmd: |
ahoy down
sleep 5
chmod -Rf 777 build 2>&1 > /dev/null || true
rm -rf \
./vendor \
./composer.lock \
./build \
2>&1 > /dev/null || true
reset:
usage: "Reset environment: remove containers, all build, manually created and Drupal-Dev files."
cmd: |
ahoy clean
rm -rf ./screenshots \
./composer.lock
install-dev:
usage: Install dependencies for this package.
cmd: |
ahoy cli "mkdir -p /app/build"
[ ${CI+x} ] && docker cp -L . $(docker-compose ps -q cli):/app/ || true
docker cp -L tests $(docker-compose ps -q cli):/app/
docker cp -L phpcs.xml $(docker-compose ps -q cli):/app/
docker cp -L behat.yml $(docker-compose ps -q cli):/app/build/
ahoy cli "COMPOSER_MEMORY_LIMIT=-1 composer install -n --ansi --prefer-dist"
hide: true
update-fixtures:
usage: Update fixture files for Drupal
cmd: rsync -av --delete --no-progress --exclude-from=tests/behat/fixtures/d$DRUPAL_VERSION/.rsync-exclude build/ tests/behat/fixtures/d$DRUPAL_VERSION/
lint:
usage: Lint all code.
cmd: |
ahoy cli "vendor/bin/parallel-lint --exclude vendor --exclude node_modules -e \$PHP_LINT_EXTENSIONS \${PHP_LINT_TARGETS//,/ }" && \
ahoy cli "vendor/bin/phpcs -v \${PHPCS_TARGETS//,/ }"
test-bdd:
usage: Run BDD tests.
cmd: ahoy cli "cd /app/build && BEHAT_SCREENSHOT_DIR=/app/screenshots BEHAT_SCREENSHOT_PURGE=${BEHAT_SCREENSHOT_PURGE:-} vendor/bin/behat --strict --colors --profile=d$DRUPAL_VERSION $@"
debug:
usage: Enable debug configuration.
cmd: ahoy cli php -v | grep -q Xdebug || XDEBUG_ENABLE=true ahoy up cli php nginx && ahoy cli php -v | grep -q Xdebug && echo "Enabled debug confguration. Use 'ahoy up' to disable."
# Utilities.
confirm:
cmd: read -r -p "${@} [y/N] " response; [ ${response} = "y" ]
hide: true
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
entrypoint:
- bash
- "-c"
- "-e"
- |
[ -f .env ] && [ -s .env ] && export $(grep -v '^#' .env | xargs) && if [ -f .env.local ] && [ -s .env.local ]; then export $(grep -v '^#' .env.local | xargs); fi
export DRUPAL_VERSION=${DRUPAL_VERSION:-9}
bash -e -c "$0" "$@"
- '{{cmd}}'
- '{{name}}'