linux test #750
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: linux test | |
on: | |
workflow_dispatch: | |
inputs: | |
libraries: | |
description: "libraries" | |
required: false | |
default: "zstd,libssh2,curl,zlib,brotli,libffi,openssl,libzip,bzip2,nghttp2,onig,libyaml,xz,libxml2" | |
extensions: | |
description: "extensions" | |
required: false | |
default: "iconv,dom,xml,simplexml,xmlwriter,xmlreader,opcache,bcmath,pdo,phar,mysqlnd,mysqli,pdo,pdo_mysql,mbstring,mbregex,session,ctype,fileinfo,filter,tokenizer,curl,ffi,swow,redis,sockets,openssl,zip,zlib,bz2,yaml,zstd,posix,pcntl,sysvshm,sysvsem,sysvmsg" | |
lib_only: | |
description: "build libraries only" | |
required: false | |
default: "" | |
push: | |
schedule: | |
- cron: "33 4 * * *" | |
env: | |
LWMBS_LIBRARIES: zstd,libssh2,curl,zlib,brotli,libffi,openssl,libzip,bzip2,nghttp2,onig,libyaml,xz,libxml2 | |
LWMBS_EXTENSIONS: iconv,dom,xml,simplexml,xmlwriter,xmlreader,opcache,bcmath,pdo,phar,mysqlnd,mysqli,pdo,pdo_mysql,mbstring,mbregex,session,ctype,fileinfo,filter,tokenizer,curl,ffi,swow,redis,sockets,openssl,zip,zlib,bz2,yaml,zstd,posix,pcntl,sysvshm,sysvsem,sysvmsg | |
jobs: | |
libs: | |
name: ${{ matrix.libc }} PHP ${{ matrix.php-version }} ${{ matrix.arch }} | |
runs-on: ubuntu-latest | |
container: ${{ (matrix.libc == 'musl' && 'alpine:edge') || ( matrix.arch == 'x86_64' && 'centos:7' || 'fedora:rawhide') }} | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: ["8.2", "8.1", "8.0"] | |
libc: ["glibc", "musl"] | |
arch: ["x86_64", "aarch64"] | |
max-parallel: 12 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Fedora mirror | |
if: matrix.libc == 'glibc' && matrix.arch == 'aarch64' | |
run: | | |
set -xeo pipefail | |
FEDORA_MIRROR='mirror.facebook.net/fedora/linux/' | |
find /etc/yum.repos.d -name "*cisco*.repo" -exec rm {} \; | |
sed -i 's/^metalink=/#metalink=/g' /etc/yum.repos.d/*.repo | |
sed -i 's/^mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/*.repo | |
sed -i 's|^#baseurl=http://download.example/pub/fedora/linux/|baseurl=https://'$FEDORA_MIRROR'|g' /etc/yum.repos.d/*.repo | |
- name: Setup CentOS and EPEL mirror | |
if: matrix.libc == 'glibc' && matrix.arch == 'x86_64' | |
run: | | |
set -xeo pipefail | |
CENTOS_MIRROR='mirror.facebook.net/centos/' | |
sed -i 's/^metalink=/#metalink=/g' /etc/yum.repos.d/*.repo | |
sed -i 's/^mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/*.repo | |
sed -i 's|^#\s*baseurl=http://mirror\.centos\.org/centos/|baseurl=https://'$CENTOS_MIRROR'|g' /etc/yum.repos.d/*.repo | |
yum install -yy epel-release centos-release-scl | |
EPEL_MIRROR='mirror.facebook.net/fedora/epel/' | |
SCLO_MIRROR='mirror.facebook.net/centos/7/sclo/' | |
sed -i 's/^metalink=/#metalink=/g' /etc/yum.repos.d/*.repo | |
sed -i 's/^mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/*.repo | |
sed -i 's|^#\s*baseurl=http://mirror.centos.org/centos/7/sclo/|baseurl=https://'$SCLO_MIRROR'|g' /etc/yum.repos.d/*.repo | |
sed -i 's|^#\s*baseurl=http://download.fedoraproject.org/pub/epel/|baseurl=https://'$EPEL_MIRROR'|g' /etc/yum.repos.d/*.repo | |
- name: Cache PHP 8.1 for CentOS | |
uses: actions/cache@v3 | |
id: cache_php | |
if: matrix.libc == 'glibc' && matrix.arch == 'x86_64' | |
with: | |
path: | | |
/opt/cmake | |
/opt/php | |
/usr/bin/tar | |
/usr/libexec/rmt | |
# note: match this | |
key: linux-centos-v3 | |
- name: Cache fedora arm64 things | |
uses: actions/cache@v3 | |
id: cache_arm64 | |
if: matrix.libc == 'glibc' && matrix.arch == 'aarch64' | |
with: | |
path: | | |
/usr/aarch64-linux-gnu/sys-root | |
# note: match this | |
key: linux-fedora-arm64-v1 | |
- name: Cache failed | |
if: | | |
(matrix.libc == 'glibc' && matrix.arch == 'aarch64' && steps.cache_arm64.outputs.cache-hit != 'true') || | |
(matrix.libc == 'glibc' && matrix.arch == 'x86_64' && steps.cache_php.outputs.cache-hit != 'true') | |
run: | | |
false | |
- name: Calc sources hash | |
id: src_hash | |
run: | | |
set -xeo pipefail | |
case "${{ matrix.libc }}-${{ matrix.arch }}" in | |
"musl-x86_64") apk add php81 curl xz tar bzip2 zstd && ln -sf "$(which php81)" /usr/bin/php;; | |
"musl-aarch64") apk add php81 curl xz tar bzip2 zstd && ln -sf "$(which php81)" /usr/bin/php;; | |
"glibc-x86_64") export "PATH=/opt/php/bin:/opt/cmake/bin:$PATH";; | |
"glibc-aarch64") dnf install -yy php-cli;; | |
esac | |
printf 'hash=' >> $GITHUB_OUTPUT | |
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} php fetch_source.php \ | |
"${{ (github.event.inputs && github.event.inputs.libraries) || env.LWMBS_LIBRARIES }}" \ | |
"${{ (github.event.inputs && github.event.inputs.extensions) || env.LWMBS_EXTENSIONS }}" \ | |
--phpVer=${{ matrix.php-version }} \ | |
--hash >> $GITHUB_OUTPUT | |
echo | |
- name: Cache libraries | |
uses: actions/cache@v3 | |
id: cache | |
with: | |
path: | | |
/src | |
/downloads | |
/lib/*.a | |
/lib/pkgconfig | |
/include | |
key: linux-${{ matrix.libc }}-${{ matrix.arch }}-v3-${{ steps.src_hash.outputs.hash }} | |
- name: Prepare tools and sources | |
id: prepare | |
run: | | |
set -xeo pipefail | |
export "PATH=/opt/php/bin:/opt/cmake/bin:$PATH" | |
cd / | |
case "${{ matrix.libc }}-${{ matrix.arch }}" in | |
"musl-aarch64") apk add --no-cache \ | |
alpine-sdk automake autoconf bison flex re2c cmake \ | |
libtool gettext-dev git \ | |
vim \ | |
xz tar && | |
mkdir -p downloads && | |
{ | |
test -f downloads/aarch64-linux-musl-cross.tgz || | |
curl -o downloads/aarch64-linux-musl-cross.tgz https://musl.cc/aarch64-linux-musl-cross.tgz | |
} && | |
{ | |
tar -xvf downloads/aarch64-linux-musl-cross.tgz -C / --strip-components=1 || : | |
} && | |
export LWMBS_CC=aarch64-linux-musl-gcc && | |
export LWMBS_CXX==aarch64-linux-musl-g++ | |
;; | |
"musl-x86_64") apk add --no-cache \ | |
alpine-sdk automake autoconf bison flex re2c cmake clang lld linux-headers \ | |
libtool gettext-dev git \ | |
vim \ | |
zlib-static zlib-dev \ | |
bzip2 bzip2-static bzip2-dev \ | |
zstd && | |
export LWMBS_CC=clang && | |
export LWMBS_CXX=clang++ | |
;; | |
"glibc-aarch64") | |
dnf install -yy \ | |
git diffstat gettext git patch patchutils \ | |
file less make ncurses pkgconf pkgconf-m4 pkgconf-pkg-config \ | |
procps-ng unzip util-linux zip diffutils \ | |
re2c perl bison flex autoconf automake cmake \ | |
libtool gettext-devel \ | |
vim \ | |
xz zstd bzip2 tar curl \ | |
binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu gcc-c++-aarch64-linux-gnu && | |
export LWMBS_CC=aarch64-linux-gnu-gcc && | |
export LWMBS_CXX=aarch64-linux-gnu-g++ | |
;; | |
"glibc-x86_64") | |
yum install -yy \ | |
perl m4 autoconf automake bison byacc cscope ctags \ | |
diffstat elfutils flex gettext \ | |
git libtool make patch patchutils cpp file \ | |
glibc-headers glibc-devel kernel-headers less \ | |
mpfr nettle zip unzip \ | |
re2c perl-IPC-Cmd devtoolset-11-binutils \ | |
devtoolset-11-gcc devtoolset-11-libstdc++-devel \ | |
devtoolset-11-gcc-c++ devtoolset-11-make \ | |
libtool gettext-devel \ | |
vim \ | |
glibc-static \ | |
xz zstd bzip2 tar curl && | |
export LWMBS_CC=gcc && | |
export LWMBS_CXX=g++ | |
;; | |
esac | |
echo "cc=$LWMBS_CC" >> $GITHUB_OUTPUT | |
echo "cxx=$LWMBS_CXX" >> $GITHUB_OUTPUT | |
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} php ${GITHUB_WORKSPACE}/fetch_source.php \ | |
"${{ (github.event.inputs && github.event.inputs.libraries) || env.LWMBS_LIBRARIES }}" \ | |
"${{ (github.event.inputs && github.event.inputs.extensions) || env.LWMBS_EXTENSIONS }}" \ | |
--phpVer=${{ matrix.php-version }} \ | |
--shallowClone | |
mkdir -p \ | |
${GITHUB_WORKSPACE}/micro_shared \ | |
${GITHUB_WORKSPACE}/micro_static \ | |
${GITHUB_WORKSPACE}/micro-cli_shared \ | |
${GITHUB_WORKSPACE}/micro-cli_static \ | |
${GITHUB_WORKSPACE}/cli_shared \ | |
${GITHUB_WORKSPACE}/cli_static | |
php ${GITHUB_WORKSPACE}/dump_licenses.php ${GITHUB_WORKSPACE}/micro_shared/licenses | |
php ${GITHUB_WORKSPACE}/dump_licenses.php ${GITHUB_WORKSPACE}/micro_static/licenses | |
php ${GITHUB_WORKSPACE}/dump_licenses.php ${GITHUB_WORKSPACE}/micro-cli_shared/licenses | |
php ${GITHUB_WORKSPACE}/dump_licenses.php ${GITHUB_WORKSPACE}/micro-cli_static/licenses | |
php ${GITHUB_WORKSPACE}/dump_licenses.php ${GITHUB_WORKSPACE}/cli_shared/licenses | |
php ${GITHUB_WORKSPACE}/dump_licenses.php ${GITHUB_WORKSPACE}/cli_static/licenses | |
php <<EOF | |
<?php | |
preg_match("/project\\(libzip\\s+VERSION\\s+([^\\r\\n]+)/m", file_get_contents('src/libzip/CMakeLists.txt'), \$m); | |
if (version_compare(\$m[1], "1.9.2", "<=")) { | |
echo "patching libzip\n"; | |
chdir('src/libzip'); | |
passthru("curl -sfSL https://github.com/nih-at/libzip/pull/349.patch | patch -p1"); | |
} | |
EOF | |
- name: Prepare libraries | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
set -xeo pipefail | |
export "PATH=/opt/php/bin:/opt/cmake/bin:$PATH" | |
cd / | |
php ${GITHUB_WORKSPACE}/build_libs.php \ | |
"${{ (github.event.inputs && github.event.inputs.libraries) || env.LWMBS_LIBRARIES }}" \ | |
--cc=${{ steps.prepare.outputs.cc }} \ | |
--cxx=${{ steps.prepare.outputs.cxx }} \ | |
--arch=${{ matrix.arch }} | |
- name: Build micro | |
if: "! (github.event.inputs && github.event.inputs.lib_only)" | |
id: micro_shared | |
continue-on-error: true | |
run: | | |
set -xeo pipefail | |
export "PATH=/opt/rh/devtoolset-11/root/usr/bin:/opt/php/bin:/opt/cmake/bin:$PATH" | |
cd / | |
php ${GITHUB_WORKSPACE}/build_micro.php \ | |
"${{ (github.event.inputs && github.event.inputs.libraries) || env.LWMBS_LIBRARIES }}" \ | |
"${{ (github.event.inputs && github.event.inputs.extensions) || env.LWMBS_EXTENSIONS }}" \ | |
--cc=${{ steps.prepare.outputs.cc }} \ | |
--cxx=${{ steps.prepare.outputs.cxx }} \ | |
--arch=${{ matrix.arch }} | |
cp src/php-src/sapi/micro/micro.sfx src/php-src/sapi/micro/micro.sfx.debug ${GITHUB_WORKSPACE}/micro_shared/ | |
- name: Upload artifact for micro | |
if: steps.micro_shared.outcome == 'success' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: micro_shared_${{ matrix.php-version }}_${{ matrix.libc }}_${{ matrix.arch }}_${{ steps.src_hash.outputs.hash }} | |
path: | | |
micro_shared | |
- name: Build micro static | |
if: | | |
(!(github.event.inputs && github.event.inputs.lib_only)) && | |
matrix.libc != 'glibc' | |
id: micro_static | |
continue-on-error: true | |
run: | | |
set -xeo pipefail | |
export "PATH=/opt/rh/devtoolset-11/root/usr/bin:/opt/php/bin:/opt/cmake/bin:$PATH" | |
cd / | |
php ${GITHUB_WORKSPACE}/build_micro.php \ | |
"${{ (github.event.inputs && github.event.inputs.libraries) || env.LWMBS_LIBRARIES }}" \ | |
"${{ (github.event.inputs && github.event.inputs.extensions) || env.LWMBS_EXTENSIONS }}" \ | |
--cc=${{ steps.prepare.outputs.cc }} \ | |
--cxx=${{ steps.prepare.outputs.cxx }} \ | |
--arch=${{ matrix.arch }} \ | |
--allStatic | |
cp src/php-src/sapi/micro/micro.sfx src/php-src/sapi/micro/micro.sfx.debug ${GITHUB_WORKSPACE}/micro_static/ | |
- name: Upload artifact for micro static | |
if: steps.micro_static.outcome == 'success' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: micro_static_${{ matrix.php-version }}_${{ matrix.libc }}_${{ matrix.arch }}_${{ steps.src_hash.outputs.hash }} | |
path: | | |
micro_static | |
- name: Build micro-cli | |
if: "! (github.event.inputs && github.event.inputs.lib_only)" | |
id: micro-cli_shared | |
continue-on-error: true | |
run: | | |
set -xeo pipefail | |
export "PATH=/opt/rh/devtoolset-11/root/usr/bin:/opt/php/bin:/opt/cmake/bin:$PATH" | |
cd / | |
rm -f src/php-src/sapi/micro/php_micro.lo | |
php ${GITHUB_WORKSPACE}/build_micro.php \ | |
"${{ (github.event.inputs && github.event.inputs.libraries) || env.LWMBS_LIBRARIES }}" \ | |
"${{ (github.event.inputs && github.event.inputs.extensions) || env.LWMBS_EXTENSIONS }}" \ | |
--cc=${{ steps.prepare.outputs.cc }} \ | |
--cxx=${{ steps.prepare.outputs.cxx }} \ | |
--arch=${{ matrix.arch }} \ | |
--fakeCli | |
cp src/php-src/sapi/micro/micro.sfx ${GITHUB_WORKSPACE}/micro-cli_shared/micro-cli.sfx | |
cp src/php-src/sapi/micro/micro.sfx.debug ${GITHUB_WORKSPACE}/micro-cli_shared/micro-cli.sfx.debug | |
- name: Upload artifact for micro-cli | |
if: steps.micro-cli_shared.outcome == 'success' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: micro-cli_shared_${{ matrix.php-version }}_${{ matrix.libc }}_${{ matrix.arch }}_${{ steps.src_hash.outputs.hash }} | |
path: | | |
micro-cli_shared | |
- name: Build micro-cli static | |
if: | | |
(!(github.event.inputs && github.event.inputs.lib_only)) && | |
matrix.libc != 'glibc' | |
id: micro-cli_static | |
continue-on-error: true | |
run: | | |
set -xeo pipefail | |
export "PATH=/opt/rh/devtoolset-11/root/usr/bin:/opt/php/bin:/opt/cmake/bin:$PATH" | |
cd / | |
php ${GITHUB_WORKSPACE}/build_micro.php \ | |
"${{ (github.event.inputs && github.event.inputs.libraries) || env.LWMBS_LIBRARIES }}" \ | |
"${{ (github.event.inputs && github.event.inputs.extensions) || env.LWMBS_EXTENSIONS }}" \ | |
--cc=${{ steps.prepare.outputs.cc }} \ | |
--cxx=${{ steps.prepare.outputs.cxx }} \ | |
--arch=${{ matrix.arch }} \ | |
--fakeCli \ | |
--allStatic | |
cp src/php-src/sapi/micro/micro.sfx ${GITHUB_WORKSPACE}/micro-cli_static/micro-cli.sfx | |
cp src/php-src/sapi/micro/micro.sfx.debug ${GITHUB_WORKSPACE}/micro-cli_static/micro-cli.sfx.debug | |
- name: Upload artifact for micro-cli static | |
if: steps.micro-cli_static.outcome == 'success' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: micro-cli_static_${{ matrix.php-version }}_${{ matrix.libc }}_${{ matrix.arch }}_${{ steps.src_hash.outputs.hash }} | |
path: | | |
micro-cli_static | |
- name: Build cli | |
if: "! (github.event.inputs && github.event.inputs.lib_only)" | |
id: cli_shared | |
continue-on-error: true | |
run: | | |
set -xeo pipefail | |
export "PATH=/opt/rh/devtoolset-11/root/usr/bin:/opt/php/bin:/opt/cmake/bin:$PATH" | |
cd / | |
php ${GITHUB_WORKSPACE}/build_cli.php \ | |
"${{ (github.event.inputs && github.event.inputs.libraries) || env.LWMBS_LIBRARIES }}" \ | |
"${{ (github.event.inputs && github.event.inputs.extensions) || env.LWMBS_EXTENSIONS }}" \ | |
--cc=${{ steps.prepare.outputs.cc }} \ | |
--cxx=${{ steps.prepare.outputs.cxx }} \ | |
--arch=${{ matrix.arch }} | |
cp src/php-src/sapi/cli/php src/php-src/sapi/cli/php.debug ${GITHUB_WORKSPACE}/cli_shared/ | |
- name: Upload artifact for cli | |
if: steps.cli_shared.outcome == 'success' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: cli_shared_${{ matrix.php-version }}_${{ matrix.libc }}_${{ matrix.arch }}_${{ steps.src_hash.outputs.hash }} | |
path: | | |
cli_shared | |
- name: Build cli static | |
if: | | |
(!(github.event.inputs && github.event.inputs.lib_only)) && | |
matrix.libc != 'glibc' | |
id: cli_static | |
continue-on-error: true | |
run: | | |
set -xeo pipefail | |
export "PATH=/opt/rh/devtoolset-11/root/usr/bin:/opt/php/bin:/opt/cmake/bin:$PATH" | |
cd / | |
php ${GITHUB_WORKSPACE}/build_cli.php \ | |
"${{ (github.event.inputs && github.event.inputs.libraries) || env.LWMBS_LIBRARIES }}" \ | |
"${{ (github.event.inputs && github.event.inputs.extensions) || env.LWMBS_EXTENSIONS }}" \ | |
--cc=${{ steps.prepare.outputs.cc }} \ | |
--cxx=${{ steps.prepare.outputs.cxx }} \ | |
--arch=${{ matrix.arch }} \ | |
--allStatic | |
cp src/php-src/sapi/cli/php src/php-src/sapi/cli/php.debug ${GITHUB_WORKSPACE}/cli_static/ | |
- name: Upload artifact for cli static | |
if: steps.cli_static.outcome == 'success' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: cli_static_${{ matrix.php-version }}_${{ matrix.libc }}_${{ matrix.arch }}_${{ steps.src_hash.outputs.hash }} | |
path: | | |
cli_static | |
- name: Fail if anything failed | |
if: | | |
steps.micro_shared.outcome == 'failure' || | |
steps.cli_shared.outcome == 'failure' || | |
(steps.micro_static.outcome == 'failure' && matrix.libc != 'glibc') || | |
(steps.cli_static.outcome == 'failure' && matrix.libc != 'glibc') | |
run: | | |
false | |
- name: Remove php src to avoid cache | |
run: | | |
rm -rf /src/php-src |