#!/usr/bin/env bash # NOTE: Parsing curl to tac to circumnvent "failed writing body" # https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body set -e set -u set -o pipefail SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )" DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )" # shellcheck disable=SC1090 . "${SCRIPT_PATH}/../scripts/.lib.sh" RETRIES=10 DISABLED_VERSIONS=() echo echo "# --------------------------------------------------------------------------------------------------" echo "# [PHP cli] ${1:-}" echo "# --------------------------------------------------------------------------------------------------" echo # ------------------------------------------------------------------------------------------------- # Pre-check # ------------------------------------------------------------------------------------------------- PHP_SERVER="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "PHP_SERVER" )" if [[ ${DISABLED_VERSIONS[*]} =~ ${PHP_SERVER} ]]; then printf "[SKIP] Skipping all checks for PHP %s\\n" "${PHP_SERVER}" exit 0 fi if ! command -v curl >/dev/null 2>&1; then >&2 echo "Error 'curl' binary not found, but required." exit 1 fi if ! command -v tac >/dev/null 2>&1; then >&2 echo "Error 'tac' binary not found, but required." exit 1 fi if [ "${#}" -ne "1" ]; then >&2 echo "Error, requires one argument: " exit 1 fi VHOST="${1}" TESTS="${SCRIPT_PATH}/../www/${VHOST}/htdocs" if [ ! -d "${TESTS}" ]; then >&2 echo "Error, test dir does not exist: ${TESTS}" exit 1 fi # ------------------------------------------------------------------------------------------------- # ENTRYPOINT # ------------------------------------------------------------------------------------------------- ### ### Get vhost files ### FILES="$( find "${TESTS}" -name '*.php' )" for file in ${FILES}; do name="$( basename "${file}" )" if ! run "docker-compose exec -T --user devilbox php php /shared/httpd/${VHOST}/htdocs/${name} | grep -E '^OK$' > /dev/null" "${RETRIES}" "${DVLBOX_PATH}"; then run "docker-compose exec -T --user devilbox php php /shared/httpd/${VHOST}/htdocs/${name} || true" "1" "${DVLBOX_PATH}" exit 1 fi if ! run_fail "docker-compose exec -T --user devilbox php php /shared/httpd/${VHOST}/htdocs/${name} 2>&1 | grep -Ei 'fatal|except|err|warn|notice' > /dev/null" "${RETRIES}" "${DVLBOX_PATH}"; then run "docker-compose exec -T --user devilbox php php /shared/httpd/${VHOST}/htdocs/${name} || true" "1" "${DVLBOX_PATH}" exit 1 fi done