From 85df4731d16f848d143e9c0bb040e9eb1f07708a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 4 Oct 2024 15:48:12 +0800 Subject: [PATCH] Fix tests CI --- .github/workflows/tests.yml | 16 +++--------- src/globals/test-extensions.php | 43 +++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b8ee2ebc..7b2e65ae 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -193,18 +193,8 @@ jobs: - name: "Run Build Tests (download)" run: | - bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug --retry=5 --shallow-clone $(php src/globals/test-extensions.php prefer_pre_built) + bin/spc $(php src/globals/test-extensions.php download_cmd ${{ matrix.os }} ${{ matrix.php }}) - - name: "Download pre-built libraries for pkg-config" - if: matrix.os != 'windows-latest' + - name: "Run Build Tests (build)" run: | - bin/spc del-download pkg-config - bin/spc download pkg-config --prefer-pre-built --debug - - - name: "Run Build Tests (build, *nix)" - if: matrix.os != 'windows-latest' - run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php zts) $(php src/globals/test-extensions.php no_strip) $UPX_CMD --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --build-fpm --debug - - - name: "Run Build Tests (build, windows)" - if: matrix.os == 'windows-latest' - run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php zts) $(php src/globals/test-extensions.php no_strip) $env:UPX_CMD --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --debug \ No newline at end of file + bin/spc $(php src/globals/test-extensions.php build_cmd ${{ matrix.os }} ${{ matrix.php }}) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index fd23a2d5..a80db4c6 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -11,16 +11,31 @@ declare(strict_types=1); // --------------------------------- edit area --------------------------------- -$test_php_version = ['8.0', '8.1', '8.2', '8.3']; +// test php version +$test_php_version = [ + '8.0', + // '8.1', + // '8.2', + '8.3', +]; -$test_os = ['macos-14', 'ubuntu-latest', 'macos-13', 'windows-latest']; +// test os (macos-13, macos-14, ubuntu-latest, windows-latest are available) +$test_os = [ + 'macos-14', + 'ubuntu-latest', + 'macos-13', + 'windows-latest', +]; +// whether enable thread safe $zts = true; $no_strip = false; +// compress with upx $upx = false; +// prefer downloading pre-built packages to speed up the build process $prefer_pre_built = true; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). @@ -78,6 +93,28 @@ if (PHP_OS_FAMILY === 'Windows') { $final_extensions_cmd = $final_extensions; } +// generate download command +$down_cmd = 'download '; +$down_cmd .= '--for-extensions="' . $final_extensions . '" '; +$down_cmd .= '--for-libs="' . $final_libs . '" '; +$down_cmd .= '--with-php="' . $argv[3] . '" '; +$down_cmd .= '--ignore-cache-sources=php-src '; +$down_cmd .= '--debug '; +$down_cmd .= '--retry=5 '; +$down_cmd .= '--shallow-clone '; +$down_cmd .= $prefer_pre_built ? '--prefer-pre-built ' : ''; + +// generate build command +$build_cmd = 'build '; +$build_cmd .= '"' . $final_extensions . '" '; +$build_cmd .= $zts ? '--enable-zts ' : ''; +$build_cmd .= $no_strip ? '--no-strip ' : ''; +$build_cmd .= $upx ? '--with-upx-pack ' : ''; +$build_cmd .= $final_libs === '' ? '' : ('--with-libs="' . $final_libs . '" '); +$build_cmd .= '--build-cli --build-micro '; +$build_cmd .= str_starts_with($argv[2], 'windows-') ? '' : '--build-fpm '; +$build_cmd .= '--debug '; + echo match ($argv[1]) { 'os' => json_encode($test_os), 'php' => json_encode($test_php_version), @@ -89,5 +126,7 @@ echo match ($argv[1]) { 'no_strip' => $no_strip ? '--no-strip' : '', 'upx' => $upx ? '--with-upx-pack' : '', 'prefer_pre_built' => $prefer_pre_built ? '--prefer-pre-built' : '', + 'download_cmd' => $down_cmd, + 'build_cmd' => $build_cmd, default => '', };