meetup-raffle-winner-picker/run

62 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

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
function task:build {
2022-01-13 22:03:05 +00:00
# Build the Docker image.
docker image build . --tag ${DOCKER_TAG}
}
function task:ci:test {
2022-04-06 21:02:33 +00:00
# Run continuous integration (CI) checks.
APP_BUILD=static
task:build
task:test --testdox "${@}"
2022-01-13 22:09:58 +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} "${@}"
}
function task:console {
2022-04-06 21:15:40 +00:00
docker container run --rm -t \
--entrypoint php \
${DOCKER_TAG} \
bin/console ${@}
}
function task:help {
2022-01-13 22:03:05 +00:00
printf "%s <task> [args]\n\nTasks:\n" "${0}"
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"
}
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
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
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
}
eval "task:${@:-help}"