From b19c1882b7074482a0cd7e2782f4d42f2a1677d1 Mon Sep 17 00:00:00 2001 From: Michele Locati Date: Tue, 10 Dec 2019 08:55:09 +0100 Subject: [PATCH] Prepare for Alpine support --- .travis.yml | 33 ++++++++++++------- README.md | 10 +++--- ...ew-extensions => travisci-test-extensions} | 28 ++++++++++------ 3 files changed, 46 insertions(+), 25 deletions(-) rename scripts/{travisci-test-new-extensions => travisci-test-extensions} (86%) diff --git a/.travis.yml b/.travis.yml index 8526d46..7adc463 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,33 @@ sudo: false +notifications: + email: false + branches: only: - - master + - master services: - docker -env: - global: - - secure: "vsl8z41oBky/MDRDKqs74Bif6BJldCPFVdl2lbPcjehOYG5cZ4YRLIEuhgJfnOglCGdyY6gh/2umSowRI4r5mC/ZR42RKJzWj9xQX2usJbzeOeZj+5eQv5im1DVwRmigUMzQOS743bd/zEeR9J3MLMgTGhKWEPKOJI6CHseUIKazAc0Z8vH6055YtkhGMqnolOe9h0gJx/sLP18qo2LTw82SyjOAMfbyYuHpiLznAqIOpNtwyj9WAujE3qN2oCo+9ALOnnrlINPqeLjnIOxRcSgYO4wIGPGSXIDTquuUht0McszOLuC9/kc6RybcyxmcqsssYRK2y0DQuavzyja5UaB4Pzf2vMrlbozAxdtF3oadZzfsAYfbhzaLbx0g1aAzL1CTJvXrWkZQgiy2c7tboXKJ3SvOqDp+GXEw08kCTpUq1AYSLw8ExlqcWZGiQxJfnfA05fWOkf8xM38ZQ+LPUHyGrt+PIw8FPAGhOV4E+BmHUlOoXOwoNllCEJ4QNkwxYT90eAMS5Rw8q6KASedwDFwyPCv8VtpNEtsl/FVa3m8/6wA7QmtuPxg7E2wceSkzsqHEcGLzERb4DnhVfrW0wv8zRw92vsnBmZdxusBT5uuyp9h5asjj6YhhVJ52g2NdCAGJlobiPk5X4uifshcdlcS8vF/jBMpI03XyJU4V4xc=" +test-extensions-job-template: &test-extensions-job-template + stage: Test extensions + if: type = pull_request + script: ./scripts/travisci-test-extensions -install: - - true +jobs: + include: + - <<: *test-extensions-job-template + name: Test extensions on Alpine Linux + env: DOCKER_DISTRO=alpine -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 + - <<: *test-extensions-job-template + name: Test extensions on Debian Linux + env: DOCKER_DISTRO=debian -notifications: - email: false \ No newline at end of file + - stage: Update docs + name: Update README.md + if: branch = master AND type = push + env: + - secure: "vsl8z41oBky/MDRDKqs74Bif6BJldCPFVdl2lbPcjehOYG5cZ4YRLIEuhgJfnOglCGdyY6gh/2umSowRI4r5mC/ZR42RKJzWj9xQX2usJbzeOeZj+5eQv5im1DVwRmigUMzQOS743bd/zEeR9J3MLMgTGhKWEPKOJI6CHseUIKazAc0Z8vH6055YtkhGMqnolOe9h0gJx/sLP18qo2LTw82SyjOAMfbyYuHpiLznAqIOpNtwyj9WAujE3qN2oCo+9ALOnnrlINPqeLjnIOxRcSgYO4wIGPGSXIDTquuUht0McszOLuC9/kc6RybcyxmcqsssYRK2y0DQuavzyja5UaB4Pzf2vMrlbozAxdtF3oadZzfsAYfbhzaLbx0g1aAzL1CTJvXrWkZQgiy2c7tboXKJ3SvOqDp+GXEw08kCTpUq1AYSLw8ExlqcWZGiQxJfnfA05fWOkf8xM38ZQ+LPUHyGrt+PIw8FPAGhOV4E+BmHUlOoXOwoNllCEJ4QNkwxYT90eAMS5Rw8q6KASedwDFwyPCv8VtpNEtsl/FVa3m8/6wA7QmtuPxg7E2wceSkzsqHEcGLzERb4DnhVfrW0wv8zRw92vsnBmZdxusBT5uuyp9h5asjj6YhhVJ52g2NdCAGJlobiPk5X4uifshcdlcS8vF/jBMpI03XyJU4V4xc=" + script: ./scripts/travisci-update-readme diff --git a/README.md b/README.md index aa38a97..58fc04f 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/scripts/travisci-test-new-extensions b/scripts/travisci-test-extensions similarity index 86% rename from scripts/travisci-test-new-extensions rename to scripts/travisci-test-extensions index 572ca57..bf48a99 100755 --- a/scripts/travisci-test-new-extensions +++ b/scripts/travisci-test-extensions @@ -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