mirror of
https://github.com/opdavies/build-configs.git
synced 2025-01-23 10:37:31 +00:00
Oliver Davies
696aa5d617
For Commerce Kickstart, there are no custom modules so these checks will fail in the CI pipeline.
137 lines
2.5 KiB
Twig
Executable file
137 lines
2.5 KiB
Twig
Executable file
#!/usr/bin/env bash
|
|
|
|
# {{ managedText | raw }}
|
|
|
|
set -eu
|
|
|
|
# Run automated tests as part of the Continuous Integration (CI) pipeline.
|
|
function ci:test {
|
|
lint:dockerfile
|
|
|
|
docker compose version
|
|
|
|
docker network create traefik_proxy
|
|
|
|
cp --no-clobber .env.example .env
|
|
|
|
docker compose build --progress plain
|
|
|
|
docker compose up --detach
|
|
docker compose logs
|
|
|
|
composer install --quiet --no-progress
|
|
|
|
{% if not php.phpcs is same as false %}
|
|
test --testdox
|
|
{% endif %}
|
|
|
|
{% if not php.phpcs is same as false and not php.phpstan is same as false %}
|
|
quality
|
|
{% endif %}
|
|
}
|
|
|
|
# Run a command within the php container.
|
|
function cmd {
|
|
docker compose exec php "${@}"
|
|
}
|
|
|
|
{% if not php.phpcs is same as false %}
|
|
function coding-standards {
|
|
cmd phpcs "${@}"
|
|
}
|
|
{% endif %}
|
|
|
|
function composer {
|
|
_exec php composer "${@}"
|
|
}
|
|
|
|
function drush {
|
|
_exec php drush "${@}"
|
|
}
|
|
|
|
function git-hooks:off {
|
|
git config --unset core.hooksPath
|
|
}
|
|
|
|
function git-hooks:on {
|
|
git config core.hooksPath .githooks
|
|
}
|
|
|
|
# Display a list of all available commands.
|
|
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 -t style "${@}" - < Dockerfile
|
|
}
|
|
|
|
{% if not php.phpcs is same as false and not php.phpstan is same as false %}
|
|
function quality {
|
|
{% if not php.phpcs is same as false %}
|
|
coding-standards
|
|
{% endif %}
|
|
{% if not php.phpstan is same as false %}
|
|
static-analysis
|
|
{% endif %}
|
|
}
|
|
{% endif %}
|
|
|
|
function start {
|
|
cp -v --no-clobber .env.example .env
|
|
|
|
docker compose up -d
|
|
}
|
|
|
|
{% if not php.phpstan is same as false %}
|
|
function static-analysis {
|
|
cmd phpstan --memory-limit=-1 --no-progress "${@}"
|
|
}
|
|
{% endif %}
|
|
|
|
function stop {
|
|
docker compose down
|
|
}
|
|
|
|
{% if not php.phpunit is same as false %}
|
|
function test {
|
|
_exec php phpunit --colors=always "${@}"
|
|
}
|
|
{% endif %}
|
|
|
|
function test:commit {
|
|
{% if not php.phpunit is same as false %}
|
|
test --testdox --testsuite functional
|
|
test --testdox --testsuite kernel
|
|
test --testdox --testsuite unit
|
|
{% endif %}
|
|
|
|
quality
|
|
}
|
|
|
|
function _exec {
|
|
docker compose exec -T "${@}"
|
|
}
|
|
|
|
function _run {
|
|
local service="${1}"
|
|
local command="${2}"
|
|
|
|
docker compose run \
|
|
--entrypoint "${command}" \
|
|
--no-deps \
|
|
--rm \
|
|
-T \
|
|
"${service}" "${@}"
|
|
}
|
|
|
|
TIMEFORMAT=$'\nTask completed in %3lR'
|
|
time "${@:-help}"
|
|
|
|
# vim: ft=bash
|