2021-12-03 08:44:26 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
TTY=""
|
|
|
|
if [[ ! -t 1 ]]; then
|
|
|
|
TTY="-T"
|
|
|
|
fi
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
function task:bash {
|
|
|
|
task:exec bash "${@}"
|
2021-12-03 08:44:26 +00:00
|
|
|
}
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
function task:ci:test {
|
|
|
|
task:lint:dockerfile
|
2021-12-03 08:45:36 +00:00
|
|
|
}
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
function task:exec {
|
2021-12-03 08:44:26 +00:00
|
|
|
# Run any command in the php container.
|
2021-12-04 21:20:36 +00:00
|
|
|
docker-compose exec php "${@}"
|
2021-12-03 08:44:26 +00:00
|
|
|
}
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
function task:composer {
|
2021-12-03 08:44:26 +00:00
|
|
|
# Execute Composer commands.
|
2021-12-04 21:20:36 +00:00
|
|
|
task:exec composer "${@}"
|
2021-12-03 08:44:26 +00:00
|
|
|
}
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
function task:db:export {
|
|
|
|
task:drush sql:dump \
|
2021-12-03 08:44:26 +00:00
|
|
|
--gzip \
|
|
|
|
--result-file=/app/drupal.sql
|
|
|
|
}
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
function task:drupal:install {
|
2021-12-03 08:44:26 +00:00
|
|
|
# Install Drupal.
|
2021-12-04 21:20:36 +00:00
|
|
|
task:drush site:install -y --account-pass admin123 --existing-config
|
2021-12-03 08:44:26 +00:00
|
|
|
}
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
function task:drush {
|
2021-12-03 08:44:26 +00:00
|
|
|
# Execute Drush commands.
|
2021-12-04 21:20:36 +00:00
|
|
|
task:exec drush "${@}"
|
2021-12-03 08:44:26 +00:00
|
|
|
}
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
function task:frontend:console {
|
2021-12-03 08:44:26 +00:00
|
|
|
docker-compose run --rm node
|
|
|
|
}
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
function task:help {
|
2021-12-03 08:44:26 +00:00
|
|
|
printf "%s <task> [args]\n\nTasks:\n" "${0}"
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
# Only show functions that have the "task:" prefix.
|
|
|
|
compgen -A function | sed -En 's/task:(.*)/\1/p' | cat -n
|
2021-12-03 08:44:26 +00:00
|
|
|
|
|
|
|
printf "\nExtended help:\n Each task has comments for general usage\n"
|
|
|
|
}
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
function task:lint:dockerfile {
|
2021-12-03 08:44:26 +00:00
|
|
|
docker container run --rm -i \
|
|
|
|
-v $(pwd)/.hadolint.yaml:/.config/hadolint.yaml \
|
|
|
|
hadolint/hadolint hadolint \
|
|
|
|
--ignore DL3008 \
|
|
|
|
--ignore DL3022 \
|
|
|
|
"${@}" - < tools/docker/Dockerfile
|
|
|
|
}
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
function task:test:functional {
|
|
|
|
run-tests --testsuite functional "${@}"
|
2021-12-03 08:44:26 +00:00
|
|
|
}
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
function task:test:integration {
|
2021-12-03 08:44:26 +00:00
|
|
|
# Run integration tests.
|
2021-12-04 21:20:36 +00:00
|
|
|
run-tests --testsuite kernel "${@}"
|
2021-12-03 08:44:26 +00:00
|
|
|
}
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
function task:test:quality {
|
2021-12-03 08:44:26 +00:00
|
|
|
# Run quality checks (code linting, static analysis, etc.).
|
2021-12-04 21:20:36 +00:00
|
|
|
docker-compose run --no-deps php phpcs
|
|
|
|
docker-compose run --no-deps php phpstan "--memory-limit=256M"
|
2021-12-03 08:44:26 +00:00
|
|
|
}
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
function task:test:unit {
|
2021-12-03 08:44:26 +00:00
|
|
|
# Run unit tests.
|
2021-12-04 21:20:36 +00:00
|
|
|
run-tests --testsuite unit "${@}"
|
2021-12-03 08:44:26 +00:00
|
|
|
}
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
function run-tests {
|
|
|
|
# Run PHPUnit tests.
|
|
|
|
docker-compose run php --user ${DOCKER_WEB_USER} php phpunit "${@}"
|
2021-12-03 08:44:26 +00:00
|
|
|
}
|
|
|
|
|
2021-12-04 21:20:36 +00:00
|
|
|
eval "task:${@:-help}"
|