Skip to content

Commit

Permalink
Add cache for nightly builds
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Nov 23, 2023
1 parent 79758b0 commit 4265145
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 168 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: false
matrix:
container: [22.04, 20.04]
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
builds: ['debug', 'release']
libs: ['true', 'false']
if: "!contains(github.event.head_commit.message, 'skip-cache')"
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-20.04]
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
builds: ['debug', 'release']
if: "!contains(github.event.head_commit.message, 'skip-tests')"
steps:
Expand Down
335 changes: 172 additions & 163 deletions scripts/install-php.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,177 +9,186 @@ enable_pecl_extension() {
phpenmod -v "$PHP_VERSION" "$extension"
}

echo "Installing PHP $PHP_VERSION"

DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends \
php$PHP_VERSION \
php$PHP_VERSION-amqp \
php$PHP_VERSION-apcu \
php$PHP_VERSION-bcmath \
php$PHP_VERSION-bz2 \
php$PHP_VERSION-cgi \
php$PHP_VERSION-cli \
php$PHP_VERSION-common \
php$PHP_VERSION-curl \
php$PHP_VERSION-dba \
php$PHP_VERSION-dev \
php$PHP_VERSION-enchant \
php$PHP_VERSION-fpm \
php$PHP_VERSION-gd \
php$PHP_VERSION-gmp \
php$PHP_VERSION-igbinary \
php$PHP_VERSION-imagick \
php$PHP_VERSION-imap \
php$PHP_VERSION-interbase \
php$PHP_VERSION-intl \
php$PHP_VERSION-ldap \
php$PHP_VERSION-mbstring \
php$PHP_VERSION-memcache \
php$PHP_VERSION-memcached \
php$PHP_VERSION-msgpack \
php$PHP_VERSION-mysql \
php$PHP_VERSION-odbc \
php$PHP_VERSION-opcache \
php$PHP_VERSION-pgsql \
php$PHP_VERSION-phpdbg \
php$PHP_VERSION-pspell \
php$PHP_VERSION-readline \
php$PHP_VERSION-redis \
php$PHP_VERSION-snmp \
php$PHP_VERSION-soap \
php$PHP_VERSION-sqlite3 \
php$PHP_VERSION-sybase \
php$PHP_VERSION-tidy \
php$PHP_VERSION-xdebug \
php$PHP_VERSION-xml \
php$PHP_VERSION-xsl \
php$PHP_VERSION-yaml \
php$PHP_VERSION-zip \
php$PHP_VERSION-zmq

[ "${BUILDS:?}" = "debug" ] && DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends \
php$PHP_VERSION$PHP_PKG_SUFFIX \
php$PHP_VERSION-amqp$PHP_PKG_SUFFIX \
php$PHP_VERSION-apcu$PHP_PKG_SUFFIX \
php$PHP_VERSION-bcmath$PHP_PKG_SUFFIX \
php$PHP_VERSION-bz2$PHP_PKG_SUFFIX \
php$PHP_VERSION-cgi$PHP_PKG_SUFFIX \
php$PHP_VERSION-cli$PHP_PKG_SUFFIX \
php$PHP_VERSION-common$PHP_PKG_SUFFIX \
php$PHP_VERSION-curl$PHP_PKG_SUFFIX \
php$PHP_VERSION-dba$PHP_PKG_SUFFIX \
php$PHP_VERSION-enchant$PHP_PKG_SUFFIX \
php$PHP_VERSION-fpm$PHP_PKG_SUFFIX \
php$PHP_VERSION-gd$PHP_PKG_SUFFIX \
php$PHP_VERSION-gmp$PHP_PKG_SUFFIX \
php$PHP_VERSION-igbinary$PHP_PKG_SUFFIX \
php$PHP_VERSION-imagick$PHP_PKG_SUFFIX \
php$PHP_VERSION-imap$PHP_PKG_SUFFIX \
php$PHP_VERSION-interbase$PHP_PKG_SUFFIX \
php$PHP_VERSION-intl$PHP_PKG_SUFFIX \
php$PHP_VERSION-ldap$PHP_PKG_SUFFIX \
php$PHP_VERSION-mbstring$PHP_PKG_SUFFIX \
php$PHP_VERSION-memcache$PHP_PKG_SUFFIX \
php$PHP_VERSION-memcached$PHP_PKG_SUFFIX \
php$PHP_VERSION-msgpack$PHP_PKG_SUFFIX \
php$PHP_VERSION-mysql$PHP_PKG_SUFFIX \
php$PHP_VERSION-odbc$PHP_PKG_SUFFIX \
php$PHP_VERSION-opcache$PHP_PKG_SUFFIX \
php$PHP_VERSION-pgsql$PHP_PKG_SUFFIX \
php$PHP_VERSION-phpdbg$PHP_PKG_SUFFIX \
php$PHP_VERSION-pspell$PHP_PKG_SUFFIX \
php$PHP_VERSION-readline$PHP_PKG_SUFFIX \
php$PHP_VERSION-redis$PHP_PKG_SUFFIX \
php$PHP_VERSION-snmp$PHP_PKG_SUFFIX \
php$PHP_VERSION-soap$PHP_PKG_SUFFIX \
php$PHP_VERSION-sqlite3$PHP_PKG_SUFFIX \
php$PHP_VERSION-sybase$PHP_PKG_SUFFIX \
php$PHP_VERSION-tidy$PHP_PKG_SUFFIX \
php$PHP_VERSION-xml$PHP_PKG_SUFFIX \
php$PHP_VERSION-yaml$PHP_PKG_SUFFIX \
php$PHP_VERSION-zip$PHP_PKG_SUFFIX \
php$PHP_VERSION-zmq$PHP_PKG_SUFFIX

if [[ $PHP_VERSION == "5.6" || $PHP_VERSION == "7.0" || $PHP_VERSION == "7.1" ]]; then
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-mcrypt php$PHP_VERSION-recode
[ "${BUILDS:?}" = "debug" ] && DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-mcrypt$PHP_PKG_SUFFIX php$PHP_VERSION-recode$PHP_PKG_SUFFIX
fi

if [[ $PHP_VERSION == "7.2" || $PHP_VERSION == "7.3" ]]; then
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-recode
[ "${BUILDS:?}" = "debug" ] && apt-fast install -y --no-install-recommends php$PHP_VERSION-recode$PHP_PKG_SUFFIX
fi

if [[ $PHP_VERSION != "8.0" && $PHP_VERSION != "8.1" && $PHP_VERSION != "8.2" ]]; then
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-xmlrpc php$PHP_VERSION-json
[ "${BUILDS:?}" = "debug" ] && DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-xmlrpc$PHP_PKG_SUFFIX php$PHP_VERSION-json$PHP_PKG_SUFFIX
fi

if [[ $PHP_VERSION != "5.6" ]]; then
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-ds
fi

if [[ $PHP_VERSION = "7.0" || $PHP_VERSION = "7.1" ]]; then
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-sodium
[ "${BUILDS:?}" = "debug" ] && apt-fast install -y --no-install-recommends php$PHP_VERSION-sodium$PHP_PKG_SUFFIX
fi

DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends libpcre3-dev libsodium-dev libpq-dev unixodbc-dev
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php-pear

for extension in ast pcov; do
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends "php$PHP_VERSION-$extension" 2>/dev/null || true
[ "${BUILDS:?}" = "debug" ] && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends "php$PHP_VERSION-$extension$PHP_PKG_SUFFIX" 2>/dev/null || true
done


tools=(pear pecl php phar phar.phar php-cgi php-config phpize phpdbg)
for tool in "${tools[@]}"; do
if [ -e "/usr/bin/$tool$PHP_VERSION" ]; then
sudo update-alternatives --set "$tool" /usr/bin/"$tool$PHP_VERSION"
install_php() {
echo "Installing PHP $PHP_VERSION"

DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends \
php$PHP_VERSION \
php$PHP_VERSION-amqp \
php$PHP_VERSION-apcu \
php$PHP_VERSION-bcmath \
php$PHP_VERSION-bz2 \
php$PHP_VERSION-cgi \
php$PHP_VERSION-cli \
php$PHP_VERSION-common \
php$PHP_VERSION-curl \
php$PHP_VERSION-dba \
php$PHP_VERSION-dev \
php$PHP_VERSION-enchant \
php$PHP_VERSION-fpm \
php$PHP_VERSION-gd \
php$PHP_VERSION-gmp \
php$PHP_VERSION-igbinary \
php$PHP_VERSION-imagick \
php$PHP_VERSION-imap \
php$PHP_VERSION-interbase \
php$PHP_VERSION-intl \
php$PHP_VERSION-ldap \
php$PHP_VERSION-mbstring \
php$PHP_VERSION-memcache \
php$PHP_VERSION-memcached \
php$PHP_VERSION-msgpack \
php$PHP_VERSION-mysql \
php$PHP_VERSION-odbc \
php$PHP_VERSION-opcache \
php$PHP_VERSION-pgsql \
php$PHP_VERSION-phpdbg \
php$PHP_VERSION-pspell \
php$PHP_VERSION-readline \
php$PHP_VERSION-redis \
php$PHP_VERSION-snmp \
php$PHP_VERSION-soap \
php$PHP_VERSION-sqlite3 \
php$PHP_VERSION-sybase \
php$PHP_VERSION-tidy \
php$PHP_VERSION-xdebug \
php$PHP_VERSION-xml \
php$PHP_VERSION-xsl \
php$PHP_VERSION-yaml \
php$PHP_VERSION-zip \
php$PHP_VERSION-zmq

[ "${BUILDS:?}" = "debug" ] && DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends \
php$PHP_VERSION$PHP_PKG_SUFFIX \
php$PHP_VERSION-amqp$PHP_PKG_SUFFIX \
php$PHP_VERSION-apcu$PHP_PKG_SUFFIX \
php$PHP_VERSION-bcmath$PHP_PKG_SUFFIX \
php$PHP_VERSION-bz2$PHP_PKG_SUFFIX \
php$PHP_VERSION-cgi$PHP_PKG_SUFFIX \
php$PHP_VERSION-cli$PHP_PKG_SUFFIX \
php$PHP_VERSION-common$PHP_PKG_SUFFIX \
php$PHP_VERSION-curl$PHP_PKG_SUFFIX \
php$PHP_VERSION-dba$PHP_PKG_SUFFIX \
php$PHP_VERSION-enchant$PHP_PKG_SUFFIX \
php$PHP_VERSION-fpm$PHP_PKG_SUFFIX \
php$PHP_VERSION-gd$PHP_PKG_SUFFIX \
php$PHP_VERSION-gmp$PHP_PKG_SUFFIX \
php$PHP_VERSION-igbinary$PHP_PKG_SUFFIX \
php$PHP_VERSION-imagick$PHP_PKG_SUFFIX \
php$PHP_VERSION-imap$PHP_PKG_SUFFIX \
php$PHP_VERSION-interbase$PHP_PKG_SUFFIX \
php$PHP_VERSION-intl$PHP_PKG_SUFFIX \
php$PHP_VERSION-ldap$PHP_PKG_SUFFIX \
php$PHP_VERSION-mbstring$PHP_PKG_SUFFIX \
php$PHP_VERSION-memcache$PHP_PKG_SUFFIX \
php$PHP_VERSION-memcached$PHP_PKG_SUFFIX \
php$PHP_VERSION-msgpack$PHP_PKG_SUFFIX \
php$PHP_VERSION-mysql$PHP_PKG_SUFFIX \
php$PHP_VERSION-odbc$PHP_PKG_SUFFIX \
php$PHP_VERSION-opcache$PHP_PKG_SUFFIX \
php$PHP_VERSION-pgsql$PHP_PKG_SUFFIX \
php$PHP_VERSION-phpdbg$PHP_PKG_SUFFIX \
php$PHP_VERSION-pspell$PHP_PKG_SUFFIX \
php$PHP_VERSION-readline$PHP_PKG_SUFFIX \
php$PHP_VERSION-redis$PHP_PKG_SUFFIX \
php$PHP_VERSION-snmp$PHP_PKG_SUFFIX \
php$PHP_VERSION-soap$PHP_PKG_SUFFIX \
php$PHP_VERSION-sqlite3$PHP_PKG_SUFFIX \
php$PHP_VERSION-sybase$PHP_PKG_SUFFIX \
php$PHP_VERSION-tidy$PHP_PKG_SUFFIX \
php$PHP_VERSION-xml$PHP_PKG_SUFFIX \
php$PHP_VERSION-yaml$PHP_PKG_SUFFIX \
php$PHP_VERSION-zip$PHP_PKG_SUFFIX \
php$PHP_VERSION-zmq$PHP_PKG_SUFFIX

if [[ $PHP_VERSION == "5.6" || $PHP_VERSION == "7.0" || $PHP_VERSION == "7.1" ]]; then
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-mcrypt php$PHP_VERSION-recode
[ "${BUILDS:?}" = "debug" ] && DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-mcrypt$PHP_PKG_SUFFIX php$PHP_VERSION-recode$PHP_PKG_SUFFIX
fi
done

for extension in sqlsrv pdo_sqlsrv; do
if [[ $PHP_VERSION =~ 7.[0-3] ]]; then
sudo pecl install -f "$extension"-5.9.0 && enable_pecl_extension "$extension"
elif [[ $PHP_VERSION =~ 7.4 ]]; then
sudo pecl install -f "$extension"-5.10.1 && enable_pecl_extension "$extension"
elif [[ $PHP_VERSION =~ 8.[0-2] ]]; then
sudo pecl install -f "$extension" && enable_pecl_extension "$extension"

if [[ $PHP_VERSION == "7.2" || $PHP_VERSION == "7.3" ]]; then
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-recode
[ "${BUILDS:?}" = "debug" ] && apt-fast install -y --no-install-recommends php$PHP_VERSION-recode$PHP_PKG_SUFFIX
fi

if [[ $PHP_VERSION != "8.0" && $PHP_VERSION != "8.1" && $PHP_VERSION != "8.2" ]]; then
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-xmlrpc php$PHP_VERSION-json
[ "${BUILDS:?}" = "debug" ] && DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-xmlrpc$PHP_PKG_SUFFIX php$PHP_VERSION-json$PHP_PKG_SUFFIX
fi

if [[ $PHP_VERSION != "5.6" ]]; then
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-ds
fi

if [[ $PHP_VERSION = "7.0" || $PHP_VERSION = "7.1" ]]; then
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-sodium
[ "${BUILDS:?}" = "debug" ] && apt-fast install -y --no-install-recommends php$PHP_VERSION-sodium$PHP_PKG_SUFFIX
fi
done

if [[ $PHP_VERSION =~ 8.[0-2] ]]; then
sudo pecl install -f memcache && enable_pecl_extension "$extension"
fi
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends libpcre3-dev libsodium-dev libpq-dev unixodbc-dev
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php-pear

for extension in ast pcov; do
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends "php$PHP_VERSION-$extension" 2>/dev/null || true
[ "${BUILDS:?}" = "debug" ] && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends "php$PHP_VERSION-$extension$PHP_PKG_SUFFIX" 2>/dev/null || true
done


tools=(pear pecl php phar phar.phar php-cgi php-config phpize phpdbg)
for tool in "${tools[@]}"; do
if [ -e "/usr/bin/$tool$PHP_VERSION" ]; then
sudo update-alternatives --set "$tool" /usr/bin/"$tool$PHP_VERSION"
fi
done

for extension in sqlsrv pdo_sqlsrv; do
if [[ $PHP_VERSION =~ 7.[0-3] ]]; then
sudo pecl install -f "$extension"-5.9.0 && enable_pecl_extension "$extension"
elif [[ $PHP_VERSION =~ 7.4 ]]; then
sudo pecl install -f "$extension"-5.10.1 && enable_pecl_extension "$extension"
elif [[ $PHP_VERSION =~ 8.[0-2] ]]; then
sudo pecl install -f "$extension" && enable_pecl_extension "$extension"
fi
done

if [[ $PHP_VERSION =~ 8.[0-2] ]]; then
sudo pecl install -f memcache && enable_pecl_extension "$extension"
fi

if [ "$PHP_VERSION" = "5.6" ]; then
if [ "$VERSION_ID" = "20.04" ]; then
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-mongo
else
sudo pecl install -f mongo
enable_pecl_extension mongo
fi
fi

if [ "$PHP_VERSION" = "5.6" ]; then
if [ "$VERSION_ID" = "20.04" ]; then
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-mongo
if [[ $PHP_VERSION =~ 7.4|8.[0-2] ]]; then
sudo pecl install -f mongodb && enable_pecl_extension mongodb
else
sudo pecl install -f mongo
enable_pecl_extension mongo
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-mongodb
[ "${BUILDS:?}" = "debug" ] && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends "php$PHP_VERSION-mongodb$PHP_PKG_SUFFIX" 2>/dev/null || true
fi
fi

if [[ $PHP_VERSION =~ 7.4|8.[0-2] ]]; then
sudo pecl install -f mongodb && enable_pecl_extension mongodb
else
DEBIAN_FRONTEND=noninteractive apt-fast install -y --no-install-recommends php$PHP_VERSION-mongodb
[ "${BUILDS:?}" = "debug" ] && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends "php$PHP_VERSION-mongodb$PHP_PKG_SUFFIX" 2>/dev/null || true
fi
DEBIAN_FRONTEND=noninteractive apt-get autoremove -y

DEBIAN_FRONTEND=noninteractive apt-get autoremove -y
sudo rm -rf /var/cache/apt/archives/*.deb || true
sudo rm -rf /var/cache/apt/archives/*.ddeb || true

sudo rm -rf /var/cache/apt/archives/*.deb || true
sudo rm -rf /var/cache/apt/archives/*.ddeb || true
if [ -d /run/systemd/system ]; then
sudo systemctl daemon-reload 2>/dev/null || true
sudo systemctl enable php"$PHP_VERSION"-fpm 2>/dev/null || true
fi

if [ -d /run/systemd/system ]; then
sudo systemctl daemon-reload 2>/dev/null || true
sudo systemctl enable php"$PHP_VERSION"-fpm 2>/dev/null || true
fi
sed -i 's/TIMEOUT=.*/TIMEOUT=5/g' /etc/init.d/php"$PHP_VERSION"-fpm
service php"$PHP_VERSION"-fpm restart >/dev/null 2>&1 || service php"$PHP_VERSION"-fpm restart >/dev/null 2>&1 || service php"$PHP_VERSION"-fpm start >/dev/null 2>&1
service php"$PHP_VERSION"-fpm status
}

sed -i 's/TIMEOUT=.*/TIMEOUT=5/g' /etc/init.d/php"$PHP_VERSION"-fpm
service php"$PHP_VERSION"-fpm restart >/dev/null 2>&1 || service php"$PHP_VERSION"-fpm restart >/dev/null 2>&1 || service php"$PHP_VERSION"-fpm start >/dev/null 2>&1
service php"$PHP_VERSION"-fpm status
if [[ $PHP_VERSION =~ 8.[3-4] ]]; then
curl -o /tmp/install.sh -sL "https://github.com/shivammathur/php-builder/releases/download/$PHP_VERSION/install.sh"
bash /tmp/install.sh local "$PHP_VERSION" "${BUILDS:?}" nts
else
install_php
fi
6 changes: 3 additions & 3 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ get() {

install() {
get /tmp/"$tar_file" "https://github.com/shivammathur/php-ubuntu/releases/latest/download/$tar_file" "https://dl.cloudsmith.io/public/shivammathur/php-ubuntu/raw/files/$tar_file"
sudo cp /var/lib/dpkg/status /var/lib/dpkg/status-orig
[ -e /var/lib/dpkg/status ] && sudo cp /var/lib/dpkg/status /var/lib/dpkg/status-orig
sudo rm -rf /var/lib/apt/lists/*ondrej*
sudo tar -I zstd -xf /tmp/"$tar_file" -C /
sudo LC_ALL=C.UTF-8 python3 /usr/sbin/merge_status && sudo rm -f /usr/sbin/merge_status
sudo mv /var/lib/dpkg/status-orig /var/lib/dpkg/status
[ -e /usr/sbin/merge_status ] && sudo LC_ALL=C.UTF-8 python3 /usr/sbin/merge_status && sudo rm -f /usr/sbin/merge_status
[ -e /var/lib/dpkg/status-orig ] && sudo mv /var/lib/dpkg/status-orig /var/lib/dpkg/status
}

fix_service() {
Expand Down

0 comments on commit 4265145

Please sign in to comment.