Check recently updated PHP extensions

pull/123/head
Michele Locati 2020-02-21 13:10:49 +01:00
parent e4cdbdd089
commit 7971155251
No known key found for this signature in database
GPG Key ID: 98B7CE2E7234E28B
7 changed files with 184 additions and 21 deletions

View File

@ -62,7 +62,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v1
- name: Test extensions
run: ./scripts/ci-test-extensions "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
run: ./scripts/ci-test-extensions from-commits "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
test_restoring_packages:
name: Test restoring packages
needs:

View File

@ -0,0 +1,71 @@
name: Test recent
on:
schedule:
- cron: "0 */12 * * *"
repository_dispatch:
types:
- test-recent
jobs:
determine_extension_list:
name: Determine extension list
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Retrieve recently updated extensions
run: ./scripts/ci-retrieve-recent-extensions >extensions-updated.txt
- name: Filter supported extensions
run: |
UPDATED_EXTENSIONS="$(cat extensions-updated.txt)"
if test -z "$UPDATED_EXTENSIONS"; then
EXTENSIONS_TO_TEST=''
else
EXTENSIONS_TO_TEST="$(./scripts/ci-filter-supported-extensions "$UPDATED_EXTENSIONS")"
fi
printf "$EXTENSIONS_TO_TEST" > extensions-to-test.txt
- name: Persist list of extensions to be tested
uses: actions/upload-artifact@v1
with:
name: artifact
path: extensions-to-test.txt
test_extensions:
runs-on: ubuntu-latest
needs: determine_extension_list
strategy:
matrix:
distro:
- alpine3.7
- alpine3.8
- alpine3.9
- alpine3.10
- alpine3.11
- jessie
- stretch
- buster
name: Check on ${{ matrix.distro }}
env:
DOCKER_DISTRO: ${{ matrix.distro }}
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Loading list of extensions to be tested
uses: actions/download-artifact@v1
with:
name: artifact
- name: Test extensions
run: |
EXTENSIONS_TO_TEST="$(cat artifact/extensions-to-test.txt)"
if test -z "$EXTENSIONS_TO_TEST"; then
echo 'No extensions to be tested'
else
./scripts/ci-test-extensions from-list "$EXTENSIONS_TO_TEST"
fi
- name: Notify failures
if: failure()
uses: appleboy/telegram-action@master
with:
token: ${{ secrets.TELEGRAM_TOKEN }}
to: ${{ secrets.TELEGRAM_TO }}
message: Testing recent PHP packages failed on https://github.com/mlocati/docker-php-extension-installer

View File

@ -1,4 +1,5 @@
![Test extensions](https://github.com/mlocati/docker-php-extension-installer/workflows/Test%20extensions/badge.svg)
![Test recent](https://github.com/mlocati/docker-php-extension-installer/workflows/Test%20recent/badge.svg)
# Easy installation of PHP extensions in official PHP Docker images

View File

@ -0,0 +1,34 @@
#!/bin/sh
# Let's set a sane environment
set -o errexit
set -o nounset
set -o noglob
SCRIPTS_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
. "$SCRIPTS_DIR/common"
ROOT_DIR="$(dirname -- "$SCRIPTS_DIR")"
DATA_DIR="$ROOT_DIR/data"
EXTENSIONS_LIST="${1:-}"
if test -z "$EXTENSIONS_LIST"; then
echo 'Extensions list not specified' >&2
exit 1
fi
ALL_SUPPORTED_EXTENSIONS="$(cat "$DATA_DIR/supported-extensions")"
SUPPORTED_EXTENSIONS=''
resetIFS
for EXTENSION in $EXTENSIONS_LIST; do
printf 'Checking extension "%s"... ' "$EXTENSION" >&2
if printf '%s' "$ALL_SUPPORTED_EXTENSIONS" | grep -q "^$EXTENSION\s"; then
printf 'supported.\n' >&2
SUPPORTED_EXTENSIONS="$SUPPORTED_EXTENSIONS $EXTENSION"
else
printf 'not supported.\n' >&2
fi
done
printf '%s' "${SUPPORTED_EXTENSIONS# }"

View File

@ -0,0 +1,42 @@
#!/bin/sh
# Let's set a sane environment
set -o errexit
set -o nounset
set -o noglob
SCRIPTS_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
. "$SCRIPTS_DIR/common"
printf 'Downloading PECL feed... ' >&2
XML="$(curl --fail --silent --show-error --location https://pecl.php.net/feeds/latest.rss)"
printf 'done.\n' >&2
printf 'Formatting XML... ' >&2
XML="$(printf '%s' "$XML" | tr -s ' \t\r\n' ' ' | sed -r 's# *<#\n<#g' | sed -r 's#>\n*#>\n#g' | tr -s '\n' '\n' | sed -r 's#^ +##g')"
printf 'done.\n' >&2
NUM_EXTENSIONS=0
EXTENSIONS=''
printf 'Detecting extension list... ' >&2
IFS='
'
for XML_LINE in $XML; do
case "$XML_LINE" in
\<item\ *)
URL="$(printf '%s' "$XML_LINE" | sed -r 's#^.+ rdf:about\s*=\s*"##' | sed -r 's#".*$##')"
EXTENSION="$(printf '%s' "$URL" | sed -r 's#^.*[?%]package=##' | sed -r 's#&.*$##')"
if test -n "$EXTENSION" && ! stringInList "$EXTENSION" "$EXTENSIONS"; then
EXTENSIONS="$EXTENSIONS $EXTENSION"
NUM_EXTENSIONS=$((NUM_EXTENSIONS + 1))
fi
;;
esac
done
if test -z "$EXTENSIONS"; then
printf 'no extension found.\n' >&2
else
EXTENSIONS="${EXTENSIONS# }"
printf '%d extension(s) found (%s)\n' $NUM_EXTENSIONS "$EXTENSIONS" >&2
fi
printf '%s' "$EXTENSIONS"

View File

@ -252,37 +252,50 @@ testExtensionFor() {
}
echo 'Checking environment'
if test -n "${GITHUB_WORKSPACE:-}" && test -n "${GITHUB_SHA:-}"; then
if test -z "${1:-}"; then
echo 'Missing commit range of the push event' >&2
exit 1
fi
CI_BUILD_DIR="$GITHUB_WORKSPACE"
CI_COMMIT_RANGE="$1"
else
if test -z "${GITHUB_WORKSPACE:-}"; then
echo 'Not in a CI environment' >&2
exit 1
fi
CI_BUILD_DIR="$GITHUB_WORKSPACE"
if test -z "${DOCKER_DISTRO:-}"; then
echo 'DOCKER_DISTRO environment variable not set' >&2
exit 1
fi
. "$CI_BUILD_DIR/scripts/common"
EXTENSIONS_TO_BE_TESTED=''
case "${1:-}" in
from-commits)
if test -z "${2:-}"; then
echo 'Missing commit range of the push event' >&2
exit 1
fi
CI_COMMIT_RANGE="$2"
STOP_EXTENSIONS_FOUND=0
EXTENSIONS_TO_BE_TESTED=''
extractExtensionsFromCommits
if test $STOP_EXTENSIONS_FOUND -eq 0; then
extractExtensionsFromData
fi
;;
from-list)
EXTENSIONS_TO_BE_TESTED="${2:-}"
;;
*)
if test -z "${1:-}"; then
printf 'Missing source of extensions to be tested\n' >&2
else
printf '"%s" is an unknown source of extensions to be tested\n' "$1" >&2
fi
exit 1
;;
esac
if test -z "$EXTENSIONS_TO_BE_TESTED"; then
echo 'No extensions to be tested.'
exit 0
fi
. "$CI_BUILD_DIR/scripts/common"
printf '### EXTENSIONS TO BE TESTED: %s\n' "$EXTENSIONS_TO_BE_TESTED"
SOME_TEST_FAILED=0
IFS='

View File

@ -13,17 +13,19 @@ case "${1:-}" in
PARAMS="$PARAMS -w"
;;
*)
fprintf 'Syntax: %s <check|fix>' "$0" >&2
printf 'Syntax: %s <check|fix>' "$0" >&2
exit 1
;;
esac
shfmt $PARAMS \
install-php-extensions \
scripts/ci-filter-supported-extensions \
scripts/ci-retrieve-recent-extensions \
scripts/ci-test-extensions \
scripts/ci-update-readme \
scripts/common \
scripts/invoke-shfmt \
scripts/lint \
scripts/test-restore-apt \
scripts/ci-test-extensions \
scripts/ci-update-readme \
scripts/update-readme