2022-01-13 22:03:05 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Based on https://github.com/adriancooney/Taskfile and
|
|
|
|
# https://nickjanetakis.com/blog/replacing-make-with-a-shell-script-for-running-your-projects-tasks.
|
|
|
|
|
2022-04-06 21:02:33 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
APP_BUILD="${APP_BUILD:=dynamic}"
|
2022-01-13 22:03:05 +00:00
|
|
|
DOCKER_TAG=meetup-raffle-winner-picker
|
|
|
|
|
2022-04-06 21:22:13 +00:00
|
|
|
function task:build {
|
2022-01-13 22:03:05 +00:00
|
|
|
# Build the Docker image.
|
|
|
|
docker image build . --tag ${DOCKER_TAG}
|
|
|
|
}
|
|
|
|
|
2022-04-06 21:22:13 +00:00
|
|
|
function task:ci:test {
|
2022-04-06 21:02:33 +00:00
|
|
|
# Run continuous integration (CI) checks.
|
|
|
|
APP_BUILD=static
|
|
|
|
|
2022-04-06 21:22:13 +00:00
|
|
|
task:build
|
|
|
|
task:test --testdox "${@}"
|
2022-01-13 22:09:58 +00:00
|
|
|
}
|
|
|
|
|
2022-04-06 21:22:13 +00:00
|
|
|
function task:composer {
|
2022-01-14 00:31:54 +00:00
|
|
|
# Run Composer commands.
|
|
|
|
docker container run --rm -it \
|
|
|
|
-v $(pwd):/app \
|
|
|
|
--entrypoint composer \
|
|
|
|
${DOCKER_TAG} "${@}"
|
|
|
|
}
|
|
|
|
|
2022-04-06 21:22:13 +00:00
|
|
|
function task:console {
|
2022-04-06 21:15:40 +00:00
|
|
|
docker container run --rm -t \
|
|
|
|
--entrypoint php \
|
|
|
|
${DOCKER_TAG} \
|
|
|
|
bin/console ${@}
|
|
|
|
}
|
|
|
|
|
2022-04-06 21:22:13 +00:00
|
|
|
function task:help {
|
2022-01-13 22:03:05 +00:00
|
|
|
printf "%s <task> [args]\n\nTasks:\n" "${0}"
|
|
|
|
|
2022-04-06 21:22:13 +00:00
|
|
|
compgen -A function | sed -En 's/task:(.*)/\1/p' | cat -n
|
2022-01-13 22:03:05 +00:00
|
|
|
|
|
|
|
printf "\nExtended help:\n Each task has comments for general usage\n"
|
|
|
|
}
|
|
|
|
|
2022-04-06 21:22:13 +00:00
|
|
|
function task:test {
|
2022-01-13 22:03:05 +00:00
|
|
|
# Run PHPUnit tests.
|
2022-04-06 21:02:33 +00:00
|
|
|
if [[ $APP_BUILD == "dynamic" ]]; then
|
2022-04-06 22:02:07 +00:00
|
|
|
docker container run --rm -t \
|
|
|
|
-v $PWD:/app \
|
|
|
|
--entrypoint phpunit \
|
|
|
|
${DOCKER_TAG} "${@}"
|
2022-04-06 21:02:33 +00:00
|
|
|
elif [[ $APP_BUILD == "static" ]]; then
|
2022-04-06 22:02:07 +00:00
|
|
|
docker container run --rm -t \
|
|
|
|
--entrypoint phpunit \
|
|
|
|
${DOCKER_TAG} "${@}"
|
2022-04-06 21:02:33 +00:00
|
|
|
fi
|
2022-01-13 22:03:05 +00:00
|
|
|
}
|
|
|
|
|
2022-04-06 21:22:13 +00:00
|
|
|
eval "task:${@:-help}"
|