Skip to content

Commit

Permalink
Merge branch 'master' into 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
wodbot committed Dec 17, 2024
2 parents 861ae24 + dce501c commit ae7f433
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
8.4#2024-12-13T06:49:08.017486Z
8.3#2024-12-13T06:49:08.017486Z
8.2#2024-12-13T06:49:08.017486Z
8.1#2024-12-13T06:49:08.017486Z
8.4#2024-12-16T16:30:46.606418Z
8.3#2024-12-16T16:30:46.606418Z
8.2#2024-12-16T16:30:46.606418Z
8.1#2024-12-16T16:30:46.606418Z
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,17 @@ buildx-push:

test:
ifeq ($(PHP_VER),8.3)
@echo "Drupal 7 doesn't support PHP 8.3"
cd ./tests/11 && IMAGE=$(REPO):$(TAG) ./run.sh
# cd ./tests/10 && IMAGE=$(REPO):$(TAG) ./run.sh
cd ./tests/10 && IMAGE=$(REPO):$(TAG) ./run.sh
else ifeq ($(PHP_VER),8.4)
@echo "Drupal 7 doesn't support PHP 8.4"
cd ./tests/11 && IMAGE=$(REPO):$(TAG) ./run.sh
# cd ./tests/10 && IMAGE=$(REPO):$(TAG) ./run.sh
cd ./tests/10 && IMAGE=$(REPO):$(TAG) ./run.sh
else
@echo "Drupal 11 doesn't support PHP <8.3"
cd ./tests/10 && IMAGE=$(REPO):$(TAG) ./run.sh
cd ./tests/7 && IMAGE=$(REPO):$(TAG) ./run.sh
endif

push:
Expand Down
78 changes: 78 additions & 0 deletions tests/7/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
version: "2"

services:
nginx:
image: wodby/nginx
environment:
NGINX_BACKEND_HOST: php
NGINX_VHOST_PRESET: drupal7
NGINX_SERVER_ROOT: /var/www/html/web
NGINX_SERVER_NAME: drupal7.test
volumes:
- codebase:/var/www/html
- files:/mnt/files
depends_on:
- php

mariadb:
image: wodby/mariadb
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
MYSQL_DATABASE: drupal

valkey:
image: wodby/valkey
environment:
VALKEY_PASSWORD: valkey

varnish:
image: wodby/varnish:4
depends_on:
- nginx
environment:
VARNISH_SECRET: secret
VARNISH_BACKEND_HOST: nginx
VARNISH_BACKEND_PORT: 80
VARNISH_CONFIG_PRESET: drupal
VARNISH_PURGE_EXTERNAL_REQUEST_HEADER: X-Real-IP

php:
image: $IMAGE
environment:
DEBUG: 1
PHP_SESSION_COOKIE_LIFETIME: 2000000
PHP_SESSION_GC_DIVISOR: 100
PHP_SESSION_GC_MAXLIFETIME: 200000
DOCROOT_SUBDIR: web
DRUPAL_ENABLE_REDIS_CACHE: 1
DRUPAL_VERSION: 7
DRUPAL_SITE: default
DRUPAL_HASH_SALT: drupal-bad-hash-salt
DRUPAL_FILES_SYNC_SALT: drupal-files-sync-bad-salt
WODBY_HOSTS: |-
["drupal7.test","drupal7.wodby.wod.by","test.drupal7.wodby.wod.by"]
WODBY_HOST_PRIMARY: drupal7.test
WODBY_URL_PRIMARY: http://drupal7.test
DB_HOST: mariadb
DB_USER: drupal
DB_PASSWORD: drupal
DB_NAME: drupal
DB_DRIVER: mysql
VARNISH_HOST: varnish
VARNISH_TERMINAL_PORT: 6082
VARNISH_SECRET: secret
VARNISH_VERSION: 4
REDIS_HOST: valkey
REDIS_PORT: 6379
REDIS_PASSWORD: valkey
PHP_SENDMAIL_PATH: /bin/true
volumes:
- codebase:/var/www/html
- files:/mnt/files
- ./tests.sh:/usr/local/bin/tests.sh

volumes:
codebase:
files:
28 changes: 28 additions & 0 deletions tests/7/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

set -e

if [[ -n "${DEBUG}" ]]; then
set -x
fi

check_ready() {
docker compose exec -T "${1}" make check-ready "${@:2}" -f /usr/local/bin/actions.mk
}

docker compose up -d

check_ready nginx max_try=10
check_ready php max_try=10
check_ready mariadb max_try=12 wait_seconds=5

# Fix php volumes permissions again
# Docker sets ephemeral shared volume ownership to default user (wodby) in nginx container (started after php)
# In case of -dev-macos version of php images wodby owner uid/gid in php and nginx containers do not match
if [[ "${IMAGE}" =~ "-dev-macos" ]]; then
docker compose exec -T php sudo init_container
fi

docker compose exec -T --user=0 php apk add --update jq
docker compose exec -T php tests.sh
docker compose down -v
84 changes: 84 additions & 0 deletions tests/7/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bash

# TODO: test sites.php entries

set -e

if [[ -n "${DEBUG}" ]]; then
set -x
fi

check_rq() {
echo "Checking requirement: ${1} must be ${2}"
# TODO: remove COLUMNS=0 with drush 8.1.17 release
# see https://github.com/drush-ops/drush/issues/3410
COLUMNS=0 drush rq --format=json | jq ".\"${1}\".value" | grep -q "${2}"
echo "OK"
}

check_status() {
echo "Checking status: ${1} must be ${2}"
# TODO: remove COLUMNS=0 with drush 8.1.17 release
# see https://github.com/drush-ops/drush/issues/3410
COLUMNS=0 drush status --format=yaml | grep -q "${1}: ${2}"
echo "OK"
}

run_action() {
make "${@}" -f /usr/local/bin/actions.mk
}

echo -n "Checking environment variables... "
env | grep -q ^DOCROOT_SUBDIR=
env | grep -q ^DRUPAL_VERSION=
env | grep -q ^DRUPAL_SITE=
echo "OK"

if [[ -n "${DOCROOT_SUBDIR}" ]]; then
DRUPAL_ROOT="${APP_ROOT}/${DOCROOT_SUBDIR}"
else
DRUPAL_ROOT="${APP_ROOT}"
fi

FILES_ARCHIVE_URL="https://s3.amazonaws.com/wodby-sample-files/drupal-php-import-test/files.tar.gz"
GIT_URL="https://github.com/drupal-composer/drupal-project.git"

make git-clone url="${GIT_URL}" -f /usr/local/bin/actions.mk
make git-checkout target=7.x -f /usr/local/bin/actions.mk

COMPOSER_MEMORY_LIMIT=-1 composer install -n
composer require drupal/varnish drupal/redis

cd "${DRUPAL_ROOT}"

run_action files-import source="${FILES_ARCHIVE_URL}"
run_action init-drupal

echo -n "Checking drush... "
drush version --format=yaml
echo "OK"

drush si -vvv -y --db-url="${DB_DRIVER}://${DB_USER}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}"
drush en varnish redis -y --quiet

run_action cache-clear

check_status "root" "${DRUPAL_ROOT}"
check_status "drupal-settings-file" "sites/${DRUPAL_SITE}/settings.php"
check_status "site" "sites/${DRUPAL_SITE}"
check_status "files" "sites/${DRUPAL_SITE}/files"
check_status "private" "${FILES_DIR}/private"
check_status "temp" "/tmp"

check_rq "redis" "Connected, using the <em>PhpRedis</em> client"
check_rq "varnish" "Running"
check_rq "file system" "Writable (<em>public</em> download method)"
check_rq "settings.php" "Protected"

echo -n "Checking imported files... "
curl -s -I -H "host: ${WODBY_HOST_PRIMARY}" "nginx/sites/default/files/logo.png" | grep -q "200 OK"
echo "OK"

echo -n "Checking Drupal homepage... "
curl -s -H "host: ${WODBY_HOST_PRIMARY}" "nginx" | grep -q "Drupal ${DRUPAL_VERSION} (http://drupal.org)"
echo "OK"

0 comments on commit ae7f433

Please sign in to comment.