Prepare for Alpine support

pull/56/head
Michele Locati 2019-12-10 08:55:09 +01:00
parent cc7956a231
commit b19c1882b7
No known key found for this signature in database
GPG Key ID: 98B7CE2E7234E28B
3 changed files with 46 additions and 25 deletions

View File

@ -1,5 +1,8 @@
sudo: false
notifications:
email: false
branches:
only:
- master
@ -7,16 +10,24 @@ branches:
services:
- docker
test-extensions-job-template: &test-extensions-job-template
stage: Test extensions
if: type = pull_request
script: ./scripts/travisci-test-extensions
jobs:
include:
- <<: *test-extensions-job-template
name: Test extensions on Alpine Linux
env: DOCKER_DISTRO=alpine
- <<: *test-extensions-job-template
name: Test extensions on Debian Linux
env: DOCKER_DISTRO=debian
- stage: Update docs
name: Update README.md
if: branch = master AND type = push
env:
global:
- secure: "vsl8z41oBky/MDRDKqs74Bif6BJldCPFVdl2lbPcjehOYG5cZ4YRLIEuhgJfnOglCGdyY6gh/2umSowRI4r5mC/ZR42RKJzWj9xQX2usJbzeOeZj+5eQv5im1DVwRmigUMzQOS743bd/zEeR9J3MLMgTGhKWEPKOJI6CHseUIKazAc0Z8vH6055YtkhGMqnolOe9h0gJx/sLP18qo2LTw82SyjOAMfbyYuHpiLznAqIOpNtwyj9WAujE3qN2oCo+9ALOnnrlINPqeLjnIOxRcSgYO4wIGPGSXIDTquuUht0McszOLuC9/kc6RybcyxmcqsssYRK2y0DQuavzyja5UaB4Pzf2vMrlbozAxdtF3oadZzfsAYfbhzaLbx0g1aAzL1CTJvXrWkZQgiy2c7tboXKJ3SvOqDp+GXEw08kCTpUq1AYSLw8ExlqcWZGiQxJfnfA05fWOkf8xM38ZQ+LPUHyGrt+PIw8FPAGhOV4E+BmHUlOoXOwoNllCEJ4QNkwxYT90eAMS5Rw8q6KASedwDFwyPCv8VtpNEtsl/FVa3m8/6wA7QmtuPxg7E2wceSkzsqHEcGLzERb4DnhVfrW0wv8zRw92vsnBmZdxusBT5uuyp9h5asjj6YhhVJ52g2NdCAGJlobiPk5X4uifshcdlcS8vF/jBMpI03XyJU4V4xc="
install:
- true
script:
- if test "${TRAVIS_EVENT_TYPE:-}" = 'pull_request'; then ./scripts/travisci-test-new-extensions; fi
- if test "${TRAVIS_EVENT_TYPE:-}" = 'push' && test "${TRAVIS_BRANCH:-}" = 'master'; then ./scripts/travisci-update-readme; fi
notifications:
email: false
script: ./scripts/travisci-update-readme

View File

@ -4,10 +4,7 @@
This repository contains a script that can be used to easily install a PHP extension inside the [official PHP Docker images](https://hub.docker.com/_/php/).
## Known limits
Currently the script requires the Debian-based images (no Alpine).
The script works both for Alpine and Debian Linux.
## Usage
@ -157,3 +154,8 @@ Some extension has special requirements:
Test: gd, zip
```
## Do you want to really say thank you?
You can offer me a [monthly coffee](https://github.com/sponsors/mlocati) or a [one-time coffee](https://paypal.me/mlocati) :wink:

View File

@ -26,20 +26,28 @@ fi
#
# Outputs:
# the full docker image ID
getExtensionImage () {
getDockerImageName () {
case "${2}" in
*)
getExtensionImage_version="${2}"
getDockerImageName_version="${2}"
;;
esac
getExtensionImage_result="php:${getExtensionImage_version}-cli"
getExtensionImage_reqs="${TRAVIS_BUILD_DIR}/data/special-requirements"
if test -f "${getExtensionImage_reqs}"; then
if test -n "$(cat "${getExtensionImage_reqs}" | grep -E "^${1}[ \t]+zts[ \t]*$")"; then
getExtensionImage_result="php:${getExtensionImage_version}-zts"
getDockerImageName_suffix='-cli'
getDockerImageName_reqs="${TRAVIS_BUILD_DIR}/data/special-requirements"
if test -f "${getDockerImageName_reqs}"; then
if test -n "$(cat "${getDockerImageName_reqs}" | grep -E "^${1}[ \t]+zts[ \t]*$")"; then
getDockerImageName_suffix="-zts"
fi
fi
printf '%s' "${getExtensionImage_result}"
case "${DOCKER_DISTRO:-}" in
alpine)
getDockerImageName_distro="-$DOCKER_DISTRO"
;;
*)
getDockerImageName_distro=''
;;
esac
printf 'php:%s%s%s' "${getDockerImageName_version}" "${getDockerImageName_suffix}" "${getDockerImageName_distro}"
}
@ -58,10 +66,10 @@ testExtension () {
printf ' INVALID PHP VERSION: %s\n' "${2}" >&2
return 1
fi
testExtension_Image="$(getExtensionImage "${1}" "${2}")"
testExtension_Image="$(getDockerImageName "${1}" "${2}")"
printf ' - Docker image: %s\n' "${testExtension_Image}"
testExtension_out=`mktemp`
if $(docker run --rm --volume "${TRAVIS_BUILD_DIR}:/app" --workdir /app "${testExtension_Image}" bash -c "./install-php-extensions '${1}' && php ./scripts/check-installed-extension.php '${1}'" >"${testExtension_out}" 2>&1); then
if $(docker run --rm --volume "${TRAVIS_BUILD_DIR}:/app" --workdir /app "${testExtension_Image}" sh -c "./install-php-extensions --cleanup '${1}' && php ./scripts/check-installed-extension.php '${1}'" >"${testExtension_out}" 2>&1); then
rm -rf "${testExtension_out}"
printf ' - Passed\n'
return 0