#!/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. set -e APP_BUILD="${APP_BUILD:=dynamic}" DOCKER_TAG=meetup-raffle-winner-picker function task:build { # Build the Docker image. docker image build . --tag ${DOCKER_TAG} } function task:ci:test { # Run continuous integration (CI) checks. APP_BUILD=static task:build task:test --testdox "${@}" } function task:composer { # Run Composer commands. docker container run --rm -it \ -v $(pwd):/app \ --entrypoint composer \ ${DOCKER_TAG} "${@}" } function task:console { docker container run --rm -t \ --entrypoint php \ ${DOCKER_TAG} \ bin/console ${@} } function task:help { printf "%s [args]\n\nTasks:\n" "${0}" compgen -A function | sed -En 's/task:(.*)/\1/p' | cat -n printf "\nExtended help:\n Each task has comments for general usage\n" } function task:test { # Run PHPUnit tests. 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 } eval "task:${@:-help}"