One-liner shell instructions

pull/10/head
Michele Locati 2018-12-11 14:21:07 +01:00
parent b58f5f192c
commit 2635b0bec6
1 changed files with 17 additions and 34 deletions

View File

@ -5,14 +5,12 @@ set -o errexit
set -o nounset set -o nounset
echo 'Checking environment' echo 'Checking environment'
if test -z "${TRAVIS_BUILD_DIR:-}" if test -z "${TRAVIS_BUILD_DIR:-}"; then
then
echo 'Not in a TravisCI environment' >&2 echo 'Not in a TravisCI environment' >&2
exit 1 exit 1
fi fi
if test -z "${TRAVIS_COMMIT_RANGE:-}" if test -z "${TRAVIS_COMMIT_RANGE:-}"; then
then
echo 'The TravisCI commit range is empty' >&2 echo 'The TravisCI commit range is empty' >&2
exit 0 exit 0
fi fi
@ -31,10 +29,8 @@ fi
getExtensionImage () { getExtensionImage () {
getExtensionImage_result="php:${2}-cli" getExtensionImage_result="php:${2}-cli"
getExtensionImage_reqs="${TRAVIS_BUILD_DIR}/data/special-requirements" getExtensionImage_reqs="${TRAVIS_BUILD_DIR}/data/special-requirements"
if test -f "${getExtensionImage_reqs}" if test -f "${getExtensionImage_reqs}"; then
then if test -n "$(cat "${getExtensionImage_reqs}" | grep -E "^${1}[ \t]+zts[ \t]*$")"; then
if test -n "$(cat "${getExtensionImage_reqs}" | grep -E "^${1}[ \t]+zts[ \t]*$")"
then
getExtensionImage_result="php:${2}-zts" getExtensionImage_result="php:${2}-zts"
fi fi
fi fi
@ -53,8 +49,7 @@ getExtensionImage () {
# 1 (false): if test fails # 1 (false): if test fails
testExtension () { testExtension () {
printf 'PHP version: %s\n' "${2}" printf 'PHP version: %s\n' "${2}"
if test -n "$(printf '%s' "${2}" | sed -E 's/^[0-9]+\.[0-9]+$//')" if test -n "$(printf '%s' "${2}" | sed -E 's/^[0-9]+\.[0-9]+$//')"; then
then
printf ' INVALID PHP VERSION: %s\n' "${2}" >&2 printf ' INVALID PHP VERSION: %s\n' "${2}" >&2
return 0 return 0
fi fi
@ -74,24 +69,20 @@ testExtension () {
# 1 (false): if test fails # 1 (false): if test fails
testNewExtensionLine () { testNewExtensionLine () {
testNewExtensionLine_rc=0 testNewExtensionLine_rc=0
if test $# -lt 2 if test $# -lt 2; then
then
printf 'Missing PHP version list for the new extension %s\n' "${1:-}" printf 'Missing PHP version list for the new extension %s\n' "${1:-}"
testNewExtensionLine_rc=1 testNewExtensionLine_rc=1
else else
printf '### TESTING NEW EXTENSION %s ###\n' "${1}" printf '### TESTING NEW EXTENSION %s ###\n' "${1}"
if test -n "$(printf '%s' "${1}" | sed -E 's/^[a-z][a-z0-9\-\_\.]+$//')" if test -n "$(printf '%s' "${1}" | sed -E 's/^[a-z][a-z0-9\-\_\.]+$//')"; then
then
printf ' INVALID PHP EXTENSION NAME: %s\n' "${1}" >&2 printf ' INVALID PHP EXTENSION NAME: %s\n' "${1}" >&2
testNewExtensionLine_rc=1 testNewExtensionLine_rc=1
else else
testNewExtensionLine_extension="${1}" testNewExtensionLine_extension="${1}"
while test $# -ge 2 while test $# -ge 2; do
do
shift shift
testNewExtensionLine_phpVersion="${1}" testNewExtensionLine_phpVersion="${1}"
if ! testExtension "${testNewExtensionLine_extension}" "${1}" if ! testExtension "${testNewExtensionLine_extension}" "${1}"; then
then
testNewExtensionLine_rc=1 testNewExtensionLine_rc=1
fi fi
done done
@ -105,34 +96,26 @@ ADDED_EXTENSION_LINE=
FOUND_ATAT= FOUND_ATAT=
IFS=' IFS='
' '
for DIFF_LINE in $(git -C "${TRAVIS_BUILD_DIR}" diff --no-indent-heuristic --minimal --no-color --word-diff=none -no-renames --unified=0 "${TRAVIS_COMMIT_RANGE:-}" -- data/supported-extensions) for DIFF_LINE in $(git -C "${TRAVIS_BUILD_DIR}" diff --no-indent-heuristic --minimal --no-color --word-diff=none -no-renames --unified=0 "${TRAVIS_COMMIT_RANGE:-}" -- data/supported-extensions); do
do if test -n "${DIFF_LINE}"; then
if test -n "${DIFF_LINE}" if test -z "${FOUND_ATAT}"; then
then if test -z "${DIFF_LINE##@@*}"; then
if test -z "${FOUND_ATAT}"
then
if test -z "${DIFF_LINE##@@*}"
then
FOUND_ATAT=y FOUND_ATAT=y
fi fi
elif test -z "${DIFF_LINE##+*}" elif test -z "${DIFF_LINE##+*}"; then
then
resetIFS resetIFS
ADDED_EXTENSION_LINE="${DIFF_LINE##+}" ADDED_EXTENSION_LINE="${DIFF_LINE##+}"
if ! testNewExtensionLine ${ADDED_EXTENSION_LINE} if ! testNewExtensionLine ${ADDED_EXTENSION_LINE}; then
then
TESTS_RESULTS=1 TESTS_RESULTS=1
fi fi
fi fi
fi fi
done done
if test ${TESTS_RESULTS} -ne 0 if test ${TESTS_RESULTS} -ne 0; then
then
exit ${TESTS_RESULTS} exit ${TESTS_RESULTS}
fi fi
if test -z "${ADDED_EXTENSION_LINE}" if test -z "${ADDED_EXTENSION_LINE}"; then
then
echo 'No new extensions detected.' echo 'No new extensions detected.'
fi fi