-
Notifications
You must be signed in to change notification settings - Fork 30
/
.ahoy.yml
167 lines (145 loc) · 6.11 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
---
ahoyapi: v2
commands:
up:
usage: Build project.
cmd: |
docker compose up -d "$@" &&
docker compose exec -T test dockerize -wait tcp://mariadb:3306 -timeout 2m;
down:
usage: Delete project.
cmd: docker compose down
build:
usage: Build project locally (single-local architecture only).
cmd: |
cat .env | grep -v "#" | grep -v -e '^$'
if [ "$1" == "y" ]; then
env $(cat .env | grep -v "#" | xargs) docker buildx bake -f docker-compose.yml --no-cache cli --load
env $(cat .env | grep -v "#" | xargs) docker buildx bake -f docker-compose.yml --load
docker compose up -d
docker compose exec -T test dockerize -wait tcp://mariadb:3306 -timeout 2m
else
ahoy confirm "Are you sure environment variables are correct? Update .env if not." &&
# Run this if confirm returns true
env $(cat .env | grep -v "#" | xargs) docker buildx bake -f docker-compose.yml --no-cache cli --load &&
env $(cat .env | grep -v "#" | xargs) docker buildx bake -f docker-compose.yml --load &&
docker compose up -d "$@" &&
docker compose exec -T test dockerize -wait tcp://mariadb:3306 -timeout 2m ||
# Run this if confirm returns false
echo "OK, nothing to do."
fi
# Compile
publish:
usage: Build multi-arch images and publish to dockerhub.
cmd: |
cat .env | grep -v "#" | grep -v -e '^$'
if [ "$1" == "y" ]; then
env $(cat .env | grep -v "#" | xargs) docker buildx bake -f docker-compose.yml -f bake.hcl --builder govcms-amd-arm --push cli
env $(cat .env | grep -v "#" | xargs) docker buildx bake -f docker-compose.yml -f bake.hcl --builder govcms-amd-arm --push
else
ahoy confirm "Running this command will build multi-arch images and publish to dockerhub. Are you sure environment variables are correct?" &&
# Run this if confirm returns true
env $(cat .env | grep -v "#" | xargs) docker buildx bake -f docker-compose.yml -f bake.hcl --builder govcms-amd-arm --push cli &&
env $(cat .env | grep -v "#" | xargs) docker buildx bake -f docker-compose.yml -f bake.hcl --builder govcms-amd-arm --push ||
# Run this if confirm returns false
echo "OK, probably a wise choice..."
fi
cli:
usage: Start a shell inside TEST container.
cmd: docker compose exec cli bash
run:
usage: Run command inside TEST container.
cmd: docker compose exec -T cli bash -c "$@"
drush:
usage: Run drush commands in TEST container.
cmd: docker compose exec -T cli drush "$@"
logs:
usage: Show Docker logs.
cmd: docker compose logs "$@"
ps:
usage: List running Docker containers.
cmd: docker compose ps
restart:
usage: Restart Docker containers.
cmd: docker compose restart
stop:
usage: Stop Docker containers.
cmd: docker compose stop "$@"
install:
usage: Install the profile.
cmd: docker compose exec -T cli drush si -y govcms "$@"
login:
usage: Login to a website.
cmd: docker compose exec -T cli drush uli "$@"
pull:
usage: Pull latest docker images.
cmd: docker image ls --format \"{{.Repository}}:{{.Tag}}\" | grep govcms/ | grep -v none | xargs -n1 docker pull | cat
lint:
usage: Lint code
cmd: docker compose exec cli lint-govcms
test:
usage: Run all tests.
cmd: |
ahoy test-phpunit
ahoy test-behat
test-behat:
usage: Run Behat tests.
cmd: docker compose exec cli behat "$@"
test-phpunit:
usage: Run PHPUnit tests.
cmd: docker compose exec cli phpunit --testsuite govcms
test-redis:
usage: Verify redis can accept connections.
cmd: |
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
test-goss:
usage: Validate images with dgoss.
cmd: |
curl -L https://github.com/goss-org/goss/releases/latest/download/goss-linux-amd64 -o /usr/local/bin/goss
chmod +rx /usr/local/bin/goss
curl -L https://github.com/goss-org/goss/releases/latest/download/dgoss -o /usr/local/bin/dgoss
chmod +rx /usr/local/bin/dgoss
./tests/goss/run_all.sh
test-install:
usage: Test a blank install.
cmd: ahoy -v install -- install_configure_form.update_status_module='array(FALSE,FALSE)'
test-nginx:
usage: Validate the nginx image.
cmd: |
apk update && apk add --no-cache php php-phar php-json php-openssl php-mbstring php-dom php-tokenizer php-xml php-xmlwriter
curl -sS https://getcomposer.org/installer -o composer-setup.php && php composer-setup.php --install-dir=/usr/local/bin --filename=composer && rm composer-setup.php
docker compose exec -T test dockerize -wait tcp://nginx:8080 -timeout 1m
docker compose exec -T nginx nginx -t
composer validate --strict -d .docker/images/nginx/tests
composer install -d .docker/images/nginx/tests
.docker/images/nginx/tests/vendor/bin/phpunit -c .docker/images/nginx/tests/phpunit.xml
info:
usage: Print build info to the current window
cmd: |
echo "[info]: GovCMS Lagoon build information"
echo "---"
echo "[image variables]"
echo " - Image version tag prefix: $IMAGE_VERSION_TAG_PREFIX"
echo " - Image version tag: $IMAGE_VERSION_TAG"
echo " - Image tag edge: $IMAGE_TAG_EDGE"
echo " - Image version tag: $IMAGE_VERSION_TAG"
echo " - Image version tag: $IMAGE_VERSION_TAG"
echo " - CLI Image name: $GOVCMS_CLI_IMAGE_NAME"
echo "[docker variables]:"
echo " - Docker registry: $DOCKER_REGISTRY_HOST"
echo " - Docker namespace: $DOCKERHUB_NAMESPACE"
echo " - Docker namespace: $DOCKERHUB_NAMESPACE"
echo "[version variables]:"
echo " - Lagoon: $LAGOON_IMAGE_VERSION"
echo " - Drupal: $DRUPAL_CORE_VERSION"
echo " - GovCMS Project: $GOVCMS_PROJECT_VERSION"
confirm:
cmd: read -r -p "${@} [y/N] " response; [ ${response} = "y" ]
hide: true