This repository was archived by the owner on Apr 1, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest
More file actions
executable file
·94 lines (83 loc) · 2.9 KB
/
test
File metadata and controls
executable file
·94 lines (83 loc) · 2.9 KB
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
#!/usr/bin/env bash
set -e
BASEDIR="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
function _cleanup {
cd "$BASEDIR"
set +e
DRUSH_DAEMON_PID="$(lsof -t -i:8888)"
set -e
if [ -n "$DRUSH_DAEMON_PID" ]; then
echo "Killing drush daemon $DRUSH_DAEMON_PID"
kill "$DRUSH_DAEMON_PID" || true
fi
if [ -d "$1" ]; then
rm -rf "$1"
fi
}
function retry {
local n=1
local max=5
local delay=1
while true; do
"$@" && break || {
if [[ $n -lt $max ]]; then
((n++))
sleep $delay;
else
echo "Setup failed."
_cleanup
exit 1
fi
}
done
}
# IMPORTANT: Run it in a subshell to avoid direnv clobber.
function install_silverback_and_test {
_cleanup
cd "$1"
php -r "
\$json = json_decode(file_get_contents('composer.json'), TRUE);
\$json['repositories'][] = ['type' => 'path', 'url' => '$BASEDIR/../../*/*' ];
\$json['extra']['drupal-scaffold']['allowed-packages'][] = 'amazeelabs/silverback-cli';
\$json['config']['allow-plugins']['drupal/core-composer-scaffold'] = true;
\$json['config']['allow-plugins']['composer/installers'] = true;
\$json['config']['allow-plugins']['cweagans/composer-patches'] = true;
\$json['config']['allow-plugins']['drupal/core-project-message'] = true;
\$json['config']['allow-plugins']['zaporylie/composer-drupal-optimizations'] = true;
\$json['config']['allow-plugins']['dealerdirect/phpcodesniffer-composer-installer'] = true;
file_put_contents('composer.json', json_encode(\$json, JSON_PRETTY_PRINT));
"
composer install --no-interaction
# Templates/starters may come with or without settings.php. Silverback CLI
# needs it in advance. Make sure it exists.
if [ -f "$1/web/sites/default/default.settings.php" ]; then
cp -n "$1/web/sites/default/default.settings.php" "$1/web/sites/default/settings.php" || true
fi
composer require amazeelabs/silverback-cli:@dev --no-interaction
# Source env vars in the same way as it would be done by .envrc.
set -o allexport; source .env.local.example; set +o allexport
if ./vendor/bin/silverback setup; then
echo 'Error: `silverback setup` should fail if there is no install cache.';
exit 1;
fi
./vendor/bin/silverback setup --profile=minimal
./vendor/bin/silverback teardown
./vendor/bin/silverback setup
./vendor/bin/silverback snapshot-create
./vendor/bin/silverback snapshot-restore
./vendor/bin/drush status
./vendor/bin/drush serve &
retry curl --silent --head http://localhost:8888
_cleanup "$1"
}
echo "👉 Testing drupal/recommended-project template..."
TMP=$(mktemp -d)
cd "$BASEDIR"
composer create-project drupal/recommended-project "$TMP" --no-interaction
(install_silverback_and_test "$TMP")
echo "👉 Testing lagoon-examples/drupal10-base starter..."
TMP=$(mktemp -d)
cd "$BASEDIR"
git clone https://github.com/lagoon-examples/drupal10-base "$TMP"
cd "$TMP"
(install_silverback_and_test "$TMP")