Skip to content

Commit 50325a9

Browse files
authored
Fix tests, restore Alpine tests, fix PHP 8.1+ deprecation warning (#39)
* Fix test failures because of precision difference * Restore testing Alpine, fix Alpine dependencies * Fix config.m4 for building with Alpine * Address PHP 8.1 deprecation warnings * git-ignore .dep files * Delete .dep files * Run zephir fullclean + zephir generate + build-ext * Use actions/checkout v3 v2 is deprecated: see https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default * Run GitHub Action steps directly within docker containers
1 parent 47e524d commit 50325a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+263
-5521
lines changed

.github/workflows/ci-ext.sh

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/ci-ext.yml

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,72 @@ jobs:
2222
matrix:
2323
image:
2424
- php:7.4-cli
25+
- php:7.4-cli-alpine
2526
- php:8.0-cli
27+
- php:8.0-cli-alpine
2628
- php:8.1-cli
29+
- php:8.1-cli-alpine
2730
- php:8.2-cli
31+
- php:8.2-cli-alpine
2832

2933
name: Image ${{ matrix.image }}
3034
runs-on: ubuntu-latest
35+
container: ${{ matrix.image }}
3136
steps:
32-
- name: Pull docker image
33-
run: docker pull ${{ matrix.image }}
34-
3537
- name: Checkout
36-
uses: actions/checkout@v2
38+
uses: actions/checkout@v3
39+
40+
- name: Install system dependencies (Alpine)
41+
if: contains(matrix.image, 'alpine')
42+
run: |
43+
apk update
44+
. /etc/os-release
45+
case "$VERSION_ID" in
46+
3.11.* | 3.12.* | 3.13.* | 3.14.* | 3.15.* | 3.16.* | 3.17.*)
47+
apk update && apk add $PHPIZE_DEPS lapack lapack-dev openblas-dev
48+
if [ ! -e /usr/lib/liblapacke.so ]; then
49+
# Fix for Alpine 3.15, 3.16 and 3.17
50+
ln -s /usr/lib/liblapacke.so.3 /usr/lib/liblapacke.so
51+
fi
52+
;;
53+
*)
54+
apk add $PHPIZE_DEPS liblapack lapack-dev openblas-dev
55+
;;
56+
esac
57+
58+
- name: Install system dependencies (Debian)
59+
if: ${{ !contains(matrix.image, 'alpine') }}
60+
run: |
61+
apt-get update -q
62+
apt-get install -qy gfortran liblapack-dev libopenblas-dev liblapacke-dev
63+
64+
- name: Create working directory
65+
run: |
66+
rm -rf /tmp/tensor-package
67+
mkdir /tmp/tensor-package
68+
69+
- name: Create PECL package
70+
run: |
71+
cd /tmp/tensor-package
72+
pecl package "$GITHUB_WORKSPACE/package.xml"
73+
74+
- name: Compile PECL package
75+
run: |
76+
cd /tmp/tensor-package
77+
MAKE="make -j$(nproc)" pecl install tensor-*.tgz
78+
79+
- name: Enable PHP extension
80+
run: docker-php-ext-enable tensor
81+
82+
- name: Check for PHP startup warnings
83+
run: |
84+
php -d display_errors=stderr -d display_startup_errors=1 -d error_reporting=-1 -r ';' 2>/tmp/php-startup-warnings
85+
if [ -s /tmp/php-startup-warnings ]; then
86+
echo 'The PHP extension was successfully installed, but PHP raised these warnings:' >&2
87+
cat /tmp/php-startup-warnings >&2
88+
exit 1
89+
fi
90+
echo "PHP didn't raise any warnings at startup."
3791
38-
- name: Compile
39-
run: docker run --rm -v "$GITHUB_WORKSPACE:/app" ${{ matrix.image }} /app/.github/workflows/ci-ext.sh
92+
- name: Inspect PHP extension
93+
run: php --ri tensor

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v3
1717

1818
- name: Setup PHP
1919
uses: shivammathur/setup-php@v2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*.dSYM
1212
*.deps
1313
*.tgz
14+
*.dep
1415

1516
zephir.phar
1617
autom4te.cache/

build-ext

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,45 @@ const CONFIG_M4_PATH = './ext/config.m4';
66
const EXECINFO_MATCH = "PHP_SUBST(TENSOR_SHARED_LIBADD)\n";
77
const EXECINFO_PATCH = <<<'EOT'
88
9-
AC_CHECK_FUNC(backtrace_symbols, have_backtrace_symbols=yes, have_backtrace_symbols=no)
10-
if test $have_backtrace_symbols = no; then
11-
LDFLAGS="${LDFLAGS:-} -lexecinfo"
9+
AC_CANONICAL_BUILD
10+
if test "$build_os" = linux-musl; then
11+
CPPFLAGS="${CPPFLAGS:-} -DALPINE_LINUX"
12+
else
13+
AC_CHECK_FUNC(backtrace_symbols, have_backtrace_symbols=yes, have_backtrace_symbols=no)
14+
if test $have_backtrace_symbols = no; then
15+
LDFLAGS="${LDFLAGS:-} -lexecinfo"
16+
fi
1217
fi
1318

1419
EOT
1520
;
1621

1722
chdir(__DIR__);
1823

19-
echo 'Reading config.m4 file';
20-
24+
echo 'Reading config.m4 file... ';
2125
$configM4Contents = file_get_contents(CONFIG_M4_PATH);
22-
2326
if (!$configM4Contents) {
2427
fwrite(STDERR, "Failed to read the config.m4 file!\n");
2528

2629
exit(1);
2730
}
31+
echo "done.\n";
2832

29-
echo 'Applying libexec patch';
30-
33+
echo 'Applying libexec patch... ';
3134
if (strpos($configM4Contents, EXECINFO_MATCH) === false) {
32-
fwrite(STDERR, "Patch entrypoint not found!\n");
35+
fwrite(STDERR, "patch entrypoint not found!\n");
3336

3437
exit(1);
3538
} elseif (strpos($configM4Contents, trim(EXECINFO_PATCH)) !== false) {
36-
echo "Already applied.\n";
39+
echo "already applied.\n";
3740
} else {
3841
$configM4Contents = str_replace(EXECINFO_MATCH, EXECINFO_MATCH . EXECINFO_PATCH, $configM4Contents);
39-
}
40-
41-
echo 'Saving config.m4 file';
42-
43-
if (!file_put_contents(CONFIG_M4_PATH, $configM4Contents)) {
44-
fwrite(STDERR, "Failed to write the config.m4 file\n");
45-
46-
exit(1);
42+
echo "done.\n";
43+
echo 'Saving config.m4 file... ';
44+
if (!file_put_contents(CONFIG_M4_PATH, $configM4Contents)) {
45+
fwrite(STDERR, "Failed to write the config.m4 file\n");
46+
47+
exit(1);
48+
}
49+
echo "done.\n";
4750
}

ext/config.m4

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,14 @@ if test "$PHP_TENSOR" = "yes"; then
4242
done
4343
PHP_SUBST(TENSOR_SHARED_LIBADD)
4444

45-
AC_CHECK_FUNC(backtrace_symbols, have_backtrace_symbols=yes, have_backtrace_symbols=no)
46-
if test $have_backtrace_symbols = no; then
47-
LDFLAGS="${LDFLAGS:-} -lexecinfo"
45+
AC_CANONICAL_BUILD
46+
if test "$build_os" = linux-musl; then
47+
CPPFLAGS="${CPPFLAGS:-} -DALPINE_LINUX"
48+
else
49+
AC_CHECK_FUNC(backtrace_symbols, have_backtrace_symbols=yes, have_backtrace_symbols=no)
50+
if test $have_backtrace_symbols = no; then
51+
LDFLAGS="${LDFLAGS:-} -lexecinfo"
52+
fi
4853
fi
4954

5055
old_CPPFLAGS=$CPPFLAGS

ext/include/arithmetic.dep

Lines changed: 0 additions & 96 deletions
This file was deleted.

0 commit comments

Comments
 (0)