oliverdavies.uk-drupal-old/run

103 lines
2 KiB
Plaintext
Raw Normal View History

2021-12-03 08:44:26 +00:00
#!/bin/bash
set -e
TTY=""
if [[ ! -t 1 ]]; then
TTY="-T"
fi
function task:bash {
task:exec bash "${@}"
2021-12-03 08:44:26 +00:00
}
function task:ci:build {
docker-compose build php
docker-compose push php
}
2021-12-08 20:29:43 +00:00
function task:ci:deploy {
ansible-playbook tools/deployment/deploy.yml \
-i tools/deployment/hosts.yml \
"${@}"
}
function task:ci:test {
task:lint:dockerfile
2021-12-03 08:45:36 +00:00
}
function task:exec {
2021-12-03 08:44:26 +00:00
# Run any command in the php container.
docker-compose exec php "${@}"
2021-12-03 08:44:26 +00:00
}
function task:composer {
2021-12-03 08:44:26 +00:00
# Execute Composer commands.
task:exec composer "${@}"
2021-12-03 08:44:26 +00:00
}
function task:db:export {
task:drush sql:dump \
2021-12-03 08:44:26 +00:00
--gzip \
--result-file=/app/drupal.sql
}
function task:drupal:install {
2021-12-03 08:44:26 +00:00
# Install Drupal.
task:drush site:install -y --account-pass admin123 --existing-config
2021-12-03 08:44:26 +00:00
}
function task:drush {
2021-12-03 08:44:26 +00:00
# Execute Drush commands.
task:exec drush "${@}"
2021-12-03 08:44:26 +00:00
}
function task:frontend:console {
2021-12-03 08:44:26 +00:00
docker-compose run --rm node
}
function task:help {
2021-12-03 08:44:26 +00:00
printf "%s <task> [args]\n\nTasks:\n" "${0}"
# 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"
}
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
}
function task:test:functional {
run-tests --testsuite functional "${@}"
2021-12-03 08:44:26 +00:00
}
function task:test:integration {
2021-12-03 08:44:26 +00:00
# Run integration tests.
run-tests --testsuite kernel "${@}"
2021-12-03 08:44:26 +00:00
}
function task:test:quality {
2021-12-03 08:44:26 +00:00
# Run quality checks (code linting, static analysis, etc.).
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
}
function task:test:unit {
2021-12-03 08:44:26 +00:00
# Run unit tests.
run-tests --testsuite unit "${@}"
2021-12-03 08:44:26 +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
}
eval "task:${@:-help}"