meetup-raffle-winner-picker/run

50 lines
1.1 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 build {
# Build the Docker image.
docker image build . --tag ${DOCKER_TAG}
}
2022-01-13 22:09:58 +00:00
function ci:test {
2022-04-06 21:02:33 +00:00
# Run continuous integration (CI) checks.
APP_BUILD=static
2022-01-13 22:09:58 +00:00
build
2022-04-06 21:06:08 +00:00
test --testdox "${@}"
2022-01-13 22:09:58 +00:00
}
2022-01-14 00:31:54 +00:00
function composer {
# Run Composer commands.
docker container run --rm -it \
-v $(pwd):/app \
--entrypoint composer \
${DOCKER_TAG} "${@}"
}
2022-01-13 22:03:05 +00:00
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 test {
# 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} "${@}"
elif [[ $APP_BUILD == "static" ]]; then
docker container run --rm -t --entrypoint phpunit ${DOCKER_TAG} "${@}"
fi
2022-01-13 22:03:05 +00:00
}
eval "${@:-help}"