-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·121 lines (89 loc) · 2.32 KB
/
run
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
#!/usr/bin/env bash
set -e
TTY=""
if [[ ! -t 1 ]]; then
TTY="-T"
fi
DC="${DC:-exec}"
function ci:test {
docker compose version
cp --no-clobber .env.example .env
DOCKER_BUILDKIT=1 COMPOSE_DOCKER_CLI_BUILD=1 docker compose build --progress plain
docker network create traefik_proxy
docker compose up --detach
docker compose ps
docker compose logs
composer install --quiet --no-progress
cmd phpunit --testdox --colors=always
}
function cmd {
# Run any command in the php container.
_dc php "${@}"
}
function composer {
# Execute Composer commands.
cmd composer "${@}"
}
function drupal:install {
# Install Drupal.
drush site:install -y --account-pass admin123 --site-name "TestConf"
drupal:files-directory-permissions
}
function drush {
# Execute Drush commands.
cmd drush "${@}"
}
function help {
printf "%s <task> [args]\n\nTasks:\n" "${0}"
compgen -A function | grep -v "^_" | cat -n
printf "\nExtended help:\n Each task has comments for general usage\n"
}
function lint:dockerfile {
docker container run --rm -i \
hadolint/hadolint hadolint \
--ignore=DL3008 \
--ignore=DL3059 \
--ignore=DL3022 \
"${@}" - < Dockerfile
}
function shell {
cmd bash "${@}"
}
function test {
. .env
_dc --user ${DOCKER_WEB_USER} php phpunit "${@}"
}
function test:functional {
. .env
_fix_public_files_directory_permissions
_fix_simpletest_directory_permissions
test --testsuite functional "${@}"
}
function test:integration {
# Run integration tests.
test --testsuite kernel "${@}"
}
function test:quality {
# Run quality checks (code linting, static analysis, etc.).
DC="run --no-deps"
cmd phpcs
cmd phpstan
}
function test:unit {
# Run unit tests.
test --testsuite unit "${@}"
}
function _dc {
docker compose ${DC} ${TTY} "${@}"
}
function _fix_public_files_directory_permissions {
# Ensure that the files directory exists and is writable.
cmd mkdir -p ${DRUPAL_DOCROOT}/sites/default/files
cmd chown -R ${DOCKER_WEB_USER}:${DOCKER_WEB_USER} ${DRUPAL_DOCROOT}/sites/default/files
}
function _fix_simpletest_directory_permissions {
# Ensure that the simpletest site directory exists and is writable.
cmd mkdir -p ${DRUPAL_DOCROOT}/sites/simpletest
cmd chown -R ${DOCKER_WEB_USER}:${DOCKER_WEB_USER} ${DRUPAL_DOCROOT}/sites/simpletest
}
eval "${@:-help}"