From 9777c9aa93a6b4626eca88d5a18917fac0d05f43 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 14 Feb 2024 00:49:58 +0800 Subject: [PATCH] Fix openpty bug for linux (#337) * fix openpty bug for linux * add event test * add download retry for download command * use test token * use test token * use test token * use test token * re-fix this bug --- .github/workflows/tests.yml | 14 +++++++++++++- src/SPC/builder/extension/event.php | 13 +++++++++++++ src/SPC/store/SourcePatcher.php | 1 - src/globals/test-extensions.php | 4 ++-- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b04a1324..21dcb0e8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -129,6 +129,13 @@ jobs: extensions: curl, openssl, mbstring ini-values: memory_limit=-1 + - name: "Use test token if exists" + if: matrix.os != 'windows-latest' + run: | + if [ "${{ secrets.TEST_GH_TOKEN }}" != "" ]; then + echo "GITHUB_TOKEN=${{ secrets.TEST_GH_TOKEN }}" >> $GITHUB_ENV + fi + - name: "Cache Composer packages" id: composer-cache uses: actions/cache@v3 @@ -152,7 +159,12 @@ jobs: run: bin/spc doctor --auto-fix - name: "Run Build Tests (download)" - run: bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --with-php=${{ matrix.php }} --debug + uses: nick-fields/retry@v3 + with: + timeout_minutes: 10 + max_attempts: 3 + retry_on: error + command: bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --with-php=${{ matrix.php }} --debug - name: "Run Build Tests (build)" run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php libs_cmd) --build-cli --build-micro --build-fpm --debug diff --git a/src/SPC/builder/extension/event.php b/src/SPC/builder/extension/event.php index 7339ad17..a1cc7bcc 100644 --- a/src/SPC/builder/extension/event.php +++ b/src/SPC/builder/extension/event.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\builder\macos\MacOSBuilder; use SPC\exception\FileSystemException; use SPC\store\FileSystem; use SPC\util\CustomExt; @@ -34,4 +35,16 @@ class event extends Extension FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-levent_openssl/', $this->getLibFilesString()); return true; } + + /** + * @throws FileSystemException + */ + public function patchBeforeMake(): bool + { + // Prevent event extension compile error on macOS + if ($this->builder instanceof MacOSBuilder) { + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', ''); + } + return true; + } } diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index c1fe1be7..53f74ddc 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -197,7 +197,6 @@ class SourcePatcher FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_STRLCAT 1$/m', ''); } if ($builder instanceof UnixBuilderBase) { - FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', ''); FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'install-micro', ''); } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 12843feb..9bc07eba 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,7 +13,7 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'calendar,ctype,curl,dom,fileinfo,filter,gd,iconv,imagick,mbregex,mbstring,mysqli,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,rar,redis,session,simplexml,soap,sockets,sqlite3,swoole,swoole-hook-mysql,tokenizer,xlswriter,xml,xmlreader,xmlwriter,zip,zlib', + 'Linux', 'Darwin' => 'event', 'Windows' => 'mbstring,openssl', }; @@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) { // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'none', + 'Linux', 'Darwin' => 'common', 'Windows' => 'none', };