From 3d96ddd8c5a9ea68e3bd2b949aa5a3f5b002c0ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sat, 8 Nov 2025 23:24:32 +0100 Subject: [PATCH 01/12] add workflow & skeleton generator --- .../actions/verify-generated-files/action.yml | 1 + .../download-bundled/make-workflow-file.php | 199 ++++++++++++++++++ .github/workflows/verify-bundled-files.yml | 6 +- 3 files changed, 203 insertions(+), 3 deletions(-) create mode 100755 .github/scripts/download-bundled/make-workflow-file.php diff --git a/.github/actions/verify-generated-files/action.yml b/.github/actions/verify-generated-files/action.yml index 79c49dbfcfffb..3f3dea73c4dcd 100644 --- a/.github/actions/verify-generated-files/action.yml +++ b/.github/actions/verify-generated-files/action.yml @@ -13,4 +13,5 @@ runs: ext/tokenizer/tokenizer_data_gen.php build/gen_stub.php -f --generate-optimizer-info --verify ext/phar/makestub.php + .github/scripts/download-bundled/make-workflow-file.php .github/scripts/test-directory-unchanged.sh . diff --git a/.github/scripts/download-bundled/make-workflow-file.php b/.github/scripts/download-bundled/make-workflow-file.php new file mode 100755 index 0000000000000..98279daecc173 --- /dev/null +++ b/.github/scripts/download-bundled/make-workflow-file.php @@ -0,0 +1,199 @@ +#!/usr/bin/env php + $directories + */ + public function __construct( + public string $name, + public array $directories + ) {} + + public function getNameForPath(): string + { + return preg_replace('~\W+~', '-', strtolower($this->name)); + } +} + +class Generator +{ + /** + * @param list $bundles + */ + public function __construct( + public array $bundles + ) {} + + protected function getRepoDirectory(): string + { + return dirname(__DIR__, 3); + } + + protected function indentString(string $value, int $levels, bool $inclFirstLine): string + { + return preg_replace( + '~' . ($inclFirstLine ? '^|' : '') . '(?<=\n)~', + str_repeat(' ', $levels), + $value + ); + } + + /** + * @param mixed $data + */ + protected function encodeYml($data): string + { + if (is_array($data)) { + $isList = array_is_list($data); + $resParts = []; + foreach ($data as $k => $v) { + $kEncoded = $isList + ? '-' + : $this->encodeYml($k) . ':'; + $vEncoded = $this->encodeYml($v); + + $resParts[] = $kEncoded + . (!$isList && is_array($v) && $v !== [] ? "\n " : ' ') + . (is_array($v) ? $this->indentString($vEncoded, 1, false) : $vEncoded); + } + + return implode("\n", $resParts); + } + + if (preg_match('~^(\w+|\$\{\{[^\}]+\}\})$~', $data)) { + return $data; + } + + return strpos($data, "\n") !== false + ? '|' . "\n" . $this->indentString($data, 1, true) + : '\'' . str_replace('\'', '\'\'', $data) . '\''; + } + + public function makeWorkflowFile(): void + { + $content = <<<'EOD' + name: Verify Bundled Files + + on: + push: + paths: &paths + %paths% + pull_request: + paths: *paths + schedule: + - cron: "0 1 * * *" + workflow_dispatch: ~ + + permissions: + contents: read + + jobs: + VERIFY_BUNDLED_FILES: + name: Verify Bundled Files + runs-on: ubuntu-24.04 + steps: + - name: git checkout + uses: actions/checkout@v5 + + - name: Detect changed files + uses: dorny/paths-filter@v3 + id: changes + with: + base: master + filters: %filters% + + %steps% + + EOD; + + $paths = [ + '.github/scripts/download-bundled/**', + ]; + foreach ($this->bundles as $bundle) { + foreach ($this->makeDornyPathsFilterFilters($bundle) as $p) { + if (str_starts_with($p, '.github/scripts/download-bundled/')) { + continue; + } + + $paths[] = $p; + } + } + $content = str_replace('%paths%', $this->indentString($this->encodeYml($paths), 3, false), $content); + + $filters = []; + foreach ($this->bundles as $bundle) { + $filters[$bundle->getNameForPath()] = $this->makeDornyPathsFilterFilters($bundle); + } + $content = str_replace('%filters%', $this->indentString($this->encodeYml($this->encodeYml($filters)), 5, false), $content); + + $steps = []; + foreach ($this->bundles as $bundle) { + $steps[] = [ + 'name' => $bundle->name, + 'if' => '${{ !cancelled() && (steps.changes.outputs.' . $bundle->getNameForPath() . ' == \'true\' || github.event_name == \'schedule\' || github.event_name == \'workflow_dispatch\') }}', + 'run' => implode("\n", [ + 'echo "::group::Download"', + '.github/scripts/download-bundled/' . $bundle->getNameForPath() . '.sh', + 'echo "::endgroup::"', + 'echo "::group::Verify files"', + ...array_map(static fn ($v) => '.github/scripts/test-directory-unchanged.sh ' . escapeshellarg($v), $bundle->directories), + 'echo "::endgroup::"', + ]), + ]; + } + $content = str_replace('%steps%', $this->indentString($this->encodeYml($steps), 3, false), $content); + + file_put_contents($this->getRepoDirectory() . '/.github/workflows/verify-bundled-files.yml', $content); + } + + protected function makeDornyPathsFilterFilters(Bundle $bundle): array + { + return [ + '.github/scripts/download-bundled/' . $bundle->getNameForPath() . '.*', + ...array_map(static fn ($v) => $v . '/**', $bundle->directories), + ]; + } + + public function makeDownloadScriptHeaders(): void + { + foreach ($this->bundles as $bundle) { + $this->makeDownloadScriptHeader($bundle); + } + } + + protected function makeDownloadScriptHeader(Bundle $bundle): void + { + $scriptPath = $this->getRepoDirectory() . '/.github/scripts/download-bundled/' . $bundle->getNameForPath() . '.sh'; + + $content = !file_exists($scriptPath) + ? "# TODO\n" + : file_get_contents($scriptPath); + + $header = <<<'EOD' + #!/bin/sh + set -ex + cd "$(dirname "$0")/../../.." + + + EOD; + if (!str_starts_with($content, $header)) { + $content = $header . $content; + } + + file_put_contents($scriptPath, $content); + } +} + +$generator = new Generator($bundles); +$generator->makeWorkflowFile(); +$generator->makeDownloadScriptHeaders(); diff --git a/.github/workflows/verify-bundled-files.yml b/.github/workflows/verify-bundled-files.yml index e15fcb36a0e7a..a3a375d9ca97a 100644 --- a/.github/workflows/verify-bundled-files.yml +++ b/.github/workflows/verify-bundled-files.yml @@ -3,7 +3,7 @@ name: Verify Bundled Files on: push: paths: &paths - - '.github/scripts/download-bundled/pcre2.sh' + - '.github/scripts/download-bundled/**' - 'ext/pcre/pcre2lib/**' pull_request: paths: *paths @@ -29,7 +29,7 @@ jobs: base: master filters: | pcre2: - - '.github/scripts/download-bundled/pcre2.sh' + - '.github/scripts/download-bundled/pcre2.*' - 'ext/pcre/pcre2lib/**' - name: PCRE2 @@ -39,5 +39,5 @@ jobs: .github/scripts/download-bundled/pcre2.sh echo "::endgroup::" echo "::group::Verify files" - .github/scripts/test-directory-unchanged.sh ext/pcre/pcre2lib + .github/scripts/test-directory-unchanged.sh "ext/pcre/pcre2lib" echo "::endgroup::" From a3d9f6278eb86a979ed16a6fb479c770a2d51947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sat, 8 Nov 2025 23:37:18 +0100 Subject: [PATCH 02/12] add download for boost.context --- .../scripts/download-bundled/boost-context.sh | 38 +++++++++++++++++++ .../download-bundled/make-workflow-file.php | 1 + .github/workflows/verify-bundled-files.yml | 13 +++++++ 3 files changed, 52 insertions(+) create mode 100755 .github/scripts/download-bundled/boost-context.sh diff --git a/.github/scripts/download-bundled/boost-context.sh b/.github/scripts/download-bundled/boost-context.sh new file mode 100755 index 0000000000000..d92425df4cec3 --- /dev/null +++ b/.github/scripts/download-bundled/boost-context.sh @@ -0,0 +1,38 @@ +#!/bin/sh +set -ex +cd "$(dirname "$0")/../../.." + +revision=refs/tags/boost-1.86.0 + +git clone --depth 1 --revision="$revision" https://github.com/boostorg/context.git /tmp/php-src-bundled/boost-context + +rm -rf Zend/asm +cp -R /tmp/php-src-bundled/boost-context/src/asm Zend/asm + +cd Zend/asm + +# remove unneeded files +rm jump_arm_aapcs_pe_armasm.asm +rm jump_i386_ms_pe_clang_gas.S +rm jump_i386_ms_pe_gas.asm +rm jump_i386_x86_64_sysv_macho_gas.S +rm jump_ppc32_ppc64_sysv_macho_gas.S +rm jump_x86_64_ms_pe_clang_gas.S +rm make_arm_aapcs_pe_armasm.asm +rm make_i386_ms_pe_clang_gas.S +rm make_i386_ms_pe_gas.asm +rm make_i386_x86_64_sysv_macho_gas.S +rm make_ppc32_ppc64_sysv_macho_gas.S +rm make_x86_64_ms_pe_clang_gas.S +rm ontop_*.S +rm ontop_*.asm +rm tail_ontop_ppc32_sysv.cpp + +# move renamed files +# GH-13896 introduced these 2 files named as .S but since https://github.com/boostorg/context/pull/265 they are named as .asm +mv jump_x86_64_ms_pe_gas.asm jump_x86_64_ms_pe_gas.S +mv make_x86_64_ms_pe_gas.asm make_x86_64_ms_pe_gas.S + +# add extra files +git restore LICENSE +git restore save_xmm_x86_64_ms_masm.asm # added in GH-18352, not an upstream boost.context file diff --git a/.github/scripts/download-bundled/make-workflow-file.php b/.github/scripts/download-bundled/make-workflow-file.php index 98279daecc173..d6d05f12d9e01 100755 --- a/.github/scripts/download-bundled/make-workflow-file.php +++ b/.github/scripts/download-bundled/make-workflow-file.php @@ -6,6 +6,7 @@ namespace Phpsrc\Ci\DownloadBundled; $bundles = [ + new Bundle('boost.context', ['Zend/asm']), new Bundle('PCRE2', ['ext/pcre/pcre2lib']), ]; diff --git a/.github/workflows/verify-bundled-files.yml b/.github/workflows/verify-bundled-files.yml index a3a375d9ca97a..5d2cfbf9d4b19 100644 --- a/.github/workflows/verify-bundled-files.yml +++ b/.github/workflows/verify-bundled-files.yml @@ -4,6 +4,7 @@ on: push: paths: &paths - '.github/scripts/download-bundled/**' + - 'Zend/asm/**' - 'ext/pcre/pcre2lib/**' pull_request: paths: *paths @@ -28,10 +29,22 @@ jobs: with: base: master filters: | + 'boost-context': + - '.github/scripts/download-bundled/boost-context.*' + - 'Zend/asm/**' pcre2: - '.github/scripts/download-bundled/pcre2.*' - 'ext/pcre/pcre2lib/**' + - name: 'boost.context' + if: ${{ !cancelled() && (steps.changes.outputs.boost-context == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }} + run: | + echo "::group::Download" + .github/scripts/download-bundled/boost-context.sh + echo "::endgroup::" + echo "::group::Verify files" + .github/scripts/test-directory-unchanged.sh "Zend/asm" + echo "::endgroup::" - name: PCRE2 if: ${{ !cancelled() && (steps.changes.outputs.pcre2 == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }} run: | From 7f12ef5fdc18273283e96217f04e93acf6e56c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 10 Nov 2025 00:27:41 +0100 Subject: [PATCH 03/12] unify/generate tmp_dir --- .github/scripts/download-bundled/boost-context.sh | 7 +++++-- .github/scripts/download-bundled/make-workflow-file.php | 6 ++++++ .github/scripts/download-bundled/pcre2.sh | 7 +++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/scripts/download-bundled/boost-context.sh b/.github/scripts/download-bundled/boost-context.sh index d92425df4cec3..b1fd8708b85b6 100755 --- a/.github/scripts/download-bundled/boost-context.sh +++ b/.github/scripts/download-bundled/boost-context.sh @@ -2,12 +2,15 @@ set -ex cd "$(dirname "$0")/../../.." +tmp_dir=/tmp/php-src-download-bundled/boost-context +rm -rf "$tmp_dir" + revision=refs/tags/boost-1.86.0 -git clone --depth 1 --revision="$revision" https://github.com/boostorg/context.git /tmp/php-src-bundled/boost-context +git clone --depth 1 --revision="$revision" https://github.com/boostorg/context.git "$tmp_dir" rm -rf Zend/asm -cp -R /tmp/php-src-bundled/boost-context/src/asm Zend/asm +cp -R "$tmp_dir"/src/asm Zend/asm cd Zend/asm diff --git a/.github/scripts/download-bundled/make-workflow-file.php b/.github/scripts/download-bundled/make-workflow-file.php index d6d05f12d9e01..7c89011dc5fb6 100755 --- a/.github/scripts/download-bundled/make-workflow-file.php +++ b/.github/scripts/download-bundled/make-workflow-file.php @@ -185,8 +185,14 @@ protected function makeDownloadScriptHeader(Bundle $bundle): void set -ex cd "$(dirname "$0")/../../.." + tmp_dir=%tmp_dir% + rm -rf "$tmp_dir" + EOD; + + $header = str_replace('%tmp_dir%', '/tmp/php-src-download-bundled/' . $bundle->getNameForPath(), $header); + if (!str_starts_with($content, $header)) { $content = $header . $content; } diff --git a/.github/scripts/download-bundled/pcre2.sh b/.github/scripts/download-bundled/pcre2.sh index b43554206c929..360cbb91db824 100755 --- a/.github/scripts/download-bundled/pcre2.sh +++ b/.github/scripts/download-bundled/pcre2.sh @@ -2,12 +2,15 @@ set -ex cd "$(dirname "$0")/../../.." +tmp_dir=/tmp/php-src-download-bundled/pcre2 +rm -rf "$tmp_dir" + revision=refs/tags/pcre2-10.44 -git clone --depth 1 --recurse-submodules --revision="$revision" https://github.com/PCRE2Project/pcre2.git /tmp/php-src-bundled/pcre2 +git clone --depth 1 --recurse-submodules --revision="$revision" https://github.com/PCRE2Project/pcre2.git "$tmp_dir" rm -rf ext/pcre/pcre2lib -cp -R /tmp/php-src-bundled/pcre2/src ext/pcre/pcre2lib +cp -R "$tmp_dir"/src ext/pcre/pcre2lib cd ext/pcre/pcre2lib From dfd87a649e9b02687f6d62878fc90216fcf2c1d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 10 Nov 2025 00:41:30 +0100 Subject: [PATCH 04/12] add uriparser ci --- .../download-bundled/make-workflow-file.php | 1 + .github/scripts/download-bundled/uriparser.sh | 21 +++++++++++++++++++ .github/workflows/verify-bundled-files.yml | 13 ++++++++++++ 3 files changed, 35 insertions(+) create mode 100755 .github/scripts/download-bundled/uriparser.sh diff --git a/.github/scripts/download-bundled/make-workflow-file.php b/.github/scripts/download-bundled/make-workflow-file.php index 7c89011dc5fb6..1ab25567294b5 100755 --- a/.github/scripts/download-bundled/make-workflow-file.php +++ b/.github/scripts/download-bundled/make-workflow-file.php @@ -8,6 +8,7 @@ $bundles = [ new Bundle('boost.context', ['Zend/asm']), new Bundle('PCRE2', ['ext/pcre/pcre2lib']), + new Bundle('uriparser', ['ext/uri/uriparser']), ]; class Bundle diff --git a/.github/scripts/download-bundled/uriparser.sh b/.github/scripts/download-bundled/uriparser.sh new file mode 100755 index 0000000000000..eea204aacd2fb --- /dev/null +++ b/.github/scripts/download-bundled/uriparser.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -ex +cd "$(dirname "$0")/../../.." + +tmp_dir=/tmp/php-src-download-bundled/uriparser +rm -rf "$tmp_dir" + +revision=c3b49569f1f25550a16d9a18207e498d77458b27 # refs/tags/uriparser-0.9.9 with https://github.com/uriparser/uriparser/pull/276 + +git clone --depth 1 --revision="$revision" https://github.com/uriparser/uriparser.git "$tmp_dir" + +rm -rf ext/uri/uriparser +mkdir ext/uri/uriparser +cp -R "$tmp_dir"/src ext/uri/uriparser +cp -R "$tmp_dir"/include ext/uri/uriparser +cp "$tmp_dir"/COPYING.BSD-3-Clause ext/uri/uriparser + +cd ext/uri/uriparser + +# move renamed files +mv src/UriConfig.h.in src/UriConfig.h diff --git a/.github/workflows/verify-bundled-files.yml b/.github/workflows/verify-bundled-files.yml index 5d2cfbf9d4b19..22232216e12bf 100644 --- a/.github/workflows/verify-bundled-files.yml +++ b/.github/workflows/verify-bundled-files.yml @@ -6,6 +6,7 @@ on: - '.github/scripts/download-bundled/**' - 'Zend/asm/**' - 'ext/pcre/pcre2lib/**' + - 'ext/uri/uriparser/**' pull_request: paths: *paths schedule: @@ -35,6 +36,9 @@ jobs: pcre2: - '.github/scripts/download-bundled/pcre2.*' - 'ext/pcre/pcre2lib/**' + uriparser: + - '.github/scripts/download-bundled/uriparser.*' + - 'ext/uri/uriparser/**' - name: 'boost.context' if: ${{ !cancelled() && (steps.changes.outputs.boost-context == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }} @@ -54,3 +58,12 @@ jobs: echo "::group::Verify files" .github/scripts/test-directory-unchanged.sh "ext/pcre/pcre2lib" echo "::endgroup::" + - name: uriparser + if: ${{ !cancelled() && (steps.changes.outputs.uriparser == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }} + run: | + echo "::group::Download" + .github/scripts/download-bundled/uriparser.sh + echo "::endgroup::" + echo "::group::Verify files" + .github/scripts/test-directory-unchanged.sh "ext/uri/uriparser" + echo "::endgroup::" From 0bd987be7f34e03d2c6815433bcf6bad2e4521d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 10 Nov 2025 00:48:44 +0100 Subject: [PATCH 05/12] rm original/duplicate src/UriConfig.h.in --- ext/uri/uriparser/src/UriConfig.h.in | 47 ---------------------------- 1 file changed, 47 deletions(-) delete mode 100644 ext/uri/uriparser/src/UriConfig.h.in diff --git a/ext/uri/uriparser/src/UriConfig.h.in b/ext/uri/uriparser/src/UriConfig.h.in deleted file mode 100644 index b9a85a8fe02af..0000000000000 --- a/ext/uri/uriparser/src/UriConfig.h.in +++ /dev/null @@ -1,47 +0,0 @@ -/* - * uriparser - RFC 3986 URI parsing library - * - * Copyright (C) 2018, Sebastian Pipping - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#if !defined(URI_CONFIG_H) -# define URI_CONFIG_H 1 - -# define PACKAGE_VERSION "@PROJECT_VERSION@" - -#cmakedefine HAVE_WPRINTF -#cmakedefine HAVE_REALLOCARRAY - -#endif /* !defined(URI_CONFIG_H) */ From ea90d45e8cce6a10f7cd7b526104787e1418b953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 10 Nov 2025 01:05:47 +0100 Subject: [PATCH 06/12] fix outdated config/comment --- ext/uri/uriparser/src/UriConfig.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/uri/uriparser/src/UriConfig.h b/ext/uri/uriparser/src/UriConfig.h index e265c0a9a1154..ab78b96cd808a 100644 --- a/ext/uri/uriparser/src/UriConfig.h +++ b/ext/uri/uriparser/src/UriConfig.h @@ -42,8 +42,8 @@ # define PACKAGE_VERSION "@PROJECT_VERSION@" /* -#define HAVE_WPRINTF -#define HAVE_REALLOCARRAY +#cmakedefine HAVE_WPRINTF +#cmakedefine HAVE_REALLOCARRAY */ #endif /* !defined(URI_CONFIG_H) */ From 98a5e562a0fb87b55cdc200147f7792f2bc5d2da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 10 Nov 2025 01:01:58 +0100 Subject: [PATCH 07/12] patch config to minimize changes between the official config --- .github/scripts/download-bundled/.gitignore | 1 + .../download-bundled/uriparser.config.patch | 14 ++++++++++++++ .github/scripts/download-bundled/uriparser.sh | 3 +++ 3 files changed, 18 insertions(+) create mode 100644 .github/scripts/download-bundled/.gitignore create mode 100644 .github/scripts/download-bundled/uriparser.config.patch diff --git a/.github/scripts/download-bundled/.gitignore b/.github/scripts/download-bundled/.gitignore new file mode 100644 index 0000000000000..69f1bf4530957 --- /dev/null +++ b/.github/scripts/download-bundled/.gitignore @@ -0,0 +1 @@ +!*.patch diff --git a/.github/scripts/download-bundled/uriparser.config.patch b/.github/scripts/download-bundled/uriparser.config.patch new file mode 100644 index 0000000000000..9742154e5d7c5 --- /dev/null +++ b/.github/scripts/download-bundled/uriparser.config.patch @@ -0,0 +1,14 @@ +diff --git a/ext/uri/uriparser/src/UriConfig.h b/ext/uri/uriparser/src/UriConfig.h +index b9a85a8..ab78b96 100644 +--- a/ext/uri/uriparser/src/UriConfig.h ++++ b/ext/uri/uriparser/src/UriConfig.h +@@ -41,7 +41,9 @@ + + # define PACKAGE_VERSION "@PROJECT_VERSION@" + ++/* + #cmakedefine HAVE_WPRINTF + #cmakedefine HAVE_REALLOCARRAY ++*/ + + #endif /* !defined(URI_CONFIG_H) */ diff --git a/.github/scripts/download-bundled/uriparser.sh b/.github/scripts/download-bundled/uriparser.sh index eea204aacd2fb..7eb10965e9d76 100755 --- a/.github/scripts/download-bundled/uriparser.sh +++ b/.github/scripts/download-bundled/uriparser.sh @@ -19,3 +19,6 @@ cd ext/uri/uriparser # move renamed files mv src/UriConfig.h.in src/UriConfig.h + +# patch customized files +git apply -v ../../../.github/scripts/download-bundled/uriparser.config.patch From 901c3ebe7cde96b1c9bb19d0757a46dc89393a4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Wed, 12 Nov 2025 19:20:08 +0100 Subject: [PATCH 08/12] "base" param for dorny/paths-filter is not used for PR --- .github/scripts/download-bundled/make-workflow-file.php | 1 - .github/workflows/verify-bundled-files.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/scripts/download-bundled/make-workflow-file.php b/.github/scripts/download-bundled/make-workflow-file.php index 1ab25567294b5..2c56abe1230da 100755 --- a/.github/scripts/download-bundled/make-workflow-file.php +++ b/.github/scripts/download-bundled/make-workflow-file.php @@ -111,7 +111,6 @@ public function makeWorkflowFile(): void uses: dorny/paths-filter@v3 id: changes with: - base: master filters: %filters% %steps% diff --git a/.github/workflows/verify-bundled-files.yml b/.github/workflows/verify-bundled-files.yml index 22232216e12bf..09ae02f38b029 100644 --- a/.github/workflows/verify-bundled-files.yml +++ b/.github/workflows/verify-bundled-files.yml @@ -28,7 +28,6 @@ jobs: uses: dorny/paths-filter@v3 id: changes with: - base: master filters: | 'boost-context': - '.github/scripts/download-bundled/boost-context.*' From 606ea2a03988ca98317ac9887b8b921cb14fe4ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Thu, 13 Nov 2025 07:57:34 +0100 Subject: [PATCH 09/12] do not use "escapeshellarg" function as it generates different results on Windows vs. linux --- .github/scripts/download-bundled/make-workflow-file.php | 2 +- .github/workflows/verify-bundled-files.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/scripts/download-bundled/make-workflow-file.php b/.github/scripts/download-bundled/make-workflow-file.php index 2c56abe1230da..2352f974caf06 100755 --- a/.github/scripts/download-bundled/make-workflow-file.php +++ b/.github/scripts/download-bundled/make-workflow-file.php @@ -147,7 +147,7 @@ public function makeWorkflowFile(): void '.github/scripts/download-bundled/' . $bundle->getNameForPath() . '.sh', 'echo "::endgroup::"', 'echo "::group::Verify files"', - ...array_map(static fn ($v) => '.github/scripts/test-directory-unchanged.sh ' . escapeshellarg($v), $bundle->directories), + ...array_map(static fn ($v) => '.github/scripts/test-directory-unchanged.sh \'' . $v . '\'', $bundle->directories), 'echo "::endgroup::"', ]), ]; diff --git a/.github/workflows/verify-bundled-files.yml b/.github/workflows/verify-bundled-files.yml index 09ae02f38b029..6b92c53f54d70 100644 --- a/.github/workflows/verify-bundled-files.yml +++ b/.github/workflows/verify-bundled-files.yml @@ -46,7 +46,7 @@ jobs: .github/scripts/download-bundled/boost-context.sh echo "::endgroup::" echo "::group::Verify files" - .github/scripts/test-directory-unchanged.sh "Zend/asm" + .github/scripts/test-directory-unchanged.sh 'Zend/asm' echo "::endgroup::" - name: PCRE2 if: ${{ !cancelled() && (steps.changes.outputs.pcre2 == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }} @@ -55,7 +55,7 @@ jobs: .github/scripts/download-bundled/pcre2.sh echo "::endgroup::" echo "::group::Verify files" - .github/scripts/test-directory-unchanged.sh "ext/pcre/pcre2lib" + .github/scripts/test-directory-unchanged.sh 'ext/pcre/pcre2lib' echo "::endgroup::" - name: uriparser if: ${{ !cancelled() && (steps.changes.outputs.uriparser == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }} @@ -64,5 +64,5 @@ jobs: .github/scripts/download-bundled/uriparser.sh echo "::endgroup::" echo "::group::Verify files" - .github/scripts/test-directory-unchanged.sh "ext/uri/uriparser" + .github/scripts/test-directory-unchanged.sh 'ext/uri/uriparser' echo "::endgroup::" From 81a8cf07b25a6be69d32fd456c6b737a4dc9779b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 14 Nov 2025 12:47:09 +0100 Subject: [PATCH 10/12] always use topmost/repo's .git as "--git-dir" --- .github/scripts/test-directory-unchanged.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/scripts/test-directory-unchanged.sh b/.github/scripts/test-directory-unchanged.sh index 0ce7fd4cc4afd..20ca410e4ec9c 100755 --- a/.github/scripts/test-directory-unchanged.sh +++ b/.github/scripts/test-directory-unchanged.sh @@ -1,13 +1,16 @@ #!/bin/sh set -ex -cd "$(dirname "$0")/../../$1" +# use the repo root directory as "--git-dir" +cd "$(dirname "$0")/../.." + +dir="$1" # notify git about untracked (except ignored) files -git add -N . +git add -N "$dir" # display overview of changed files -git status . +git status "$dir" # display diff of working directory vs HEAD commit and set exit code -git diff -a --exit-code HEAD . +git diff -a --exit-code HEAD "$dir" From 993480bfdb9dca51f400852bde1daeb73ff98f94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 14 Nov 2025 15:12:44 +0100 Subject: [PATCH 11/12] run "Detect changed files" step only for push/PR events --- .github/scripts/download-bundled/make-workflow-file.php | 1 + .github/workflows/verify-bundled-files.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/scripts/download-bundled/make-workflow-file.php b/.github/scripts/download-bundled/make-workflow-file.php index 2352f974caf06..e35ffa43c945f 100755 --- a/.github/scripts/download-bundled/make-workflow-file.php +++ b/.github/scripts/download-bundled/make-workflow-file.php @@ -108,6 +108,7 @@ public function makeWorkflowFile(): void uses: actions/checkout@v5 - name: Detect changed files + if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }} uses: dorny/paths-filter@v3 id: changes with: diff --git a/.github/workflows/verify-bundled-files.yml b/.github/workflows/verify-bundled-files.yml index 6b92c53f54d70..2753f0b8dc722 100644 --- a/.github/workflows/verify-bundled-files.yml +++ b/.github/workflows/verify-bundled-files.yml @@ -25,6 +25,7 @@ jobs: uses: actions/checkout@v5 - name: Detect changed files + if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }} uses: dorny/paths-filter@v3 id: changes with: From ae478167e98f7d38daeea01f44380c85ec5e0a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sun, 7 Dec 2025 11:31:28 +0100 Subject: [PATCH 12/12] rm generator script --- .../actions/verify-generated-files/action.yml | 1 - .../download-bundled/make-workflow-file.php | 207 ------------------ .github/workflows/verify-bundled-files.yml | 6 +- 3 files changed, 3 insertions(+), 211 deletions(-) delete mode 100755 .github/scripts/download-bundled/make-workflow-file.php diff --git a/.github/actions/verify-generated-files/action.yml b/.github/actions/verify-generated-files/action.yml index 3f3dea73c4dcd..79c49dbfcfffb 100644 --- a/.github/actions/verify-generated-files/action.yml +++ b/.github/actions/verify-generated-files/action.yml @@ -13,5 +13,4 @@ runs: ext/tokenizer/tokenizer_data_gen.php build/gen_stub.php -f --generate-optimizer-info --verify ext/phar/makestub.php - .github/scripts/download-bundled/make-workflow-file.php .github/scripts/test-directory-unchanged.sh . diff --git a/.github/scripts/download-bundled/make-workflow-file.php b/.github/scripts/download-bundled/make-workflow-file.php deleted file mode 100755 index e35ffa43c945f..0000000000000 --- a/.github/scripts/download-bundled/make-workflow-file.php +++ /dev/null @@ -1,207 +0,0 @@ -#!/usr/bin/env php - $directories - */ - public function __construct( - public string $name, - public array $directories - ) {} - - public function getNameForPath(): string - { - return preg_replace('~\W+~', '-', strtolower($this->name)); - } -} - -class Generator -{ - /** - * @param list $bundles - */ - public function __construct( - public array $bundles - ) {} - - protected function getRepoDirectory(): string - { - return dirname(__DIR__, 3); - } - - protected function indentString(string $value, int $levels, bool $inclFirstLine): string - { - return preg_replace( - '~' . ($inclFirstLine ? '^|' : '') . '(?<=\n)~', - str_repeat(' ', $levels), - $value - ); - } - - /** - * @param mixed $data - */ - protected function encodeYml($data): string - { - if (is_array($data)) { - $isList = array_is_list($data); - $resParts = []; - foreach ($data as $k => $v) { - $kEncoded = $isList - ? '-' - : $this->encodeYml($k) . ':'; - $vEncoded = $this->encodeYml($v); - - $resParts[] = $kEncoded - . (!$isList && is_array($v) && $v !== [] ? "\n " : ' ') - . (is_array($v) ? $this->indentString($vEncoded, 1, false) : $vEncoded); - } - - return implode("\n", $resParts); - } - - if (preg_match('~^(\w+|\$\{\{[^\}]+\}\})$~', $data)) { - return $data; - } - - return strpos($data, "\n") !== false - ? '|' . "\n" . $this->indentString($data, 1, true) - : '\'' . str_replace('\'', '\'\'', $data) . '\''; - } - - public function makeWorkflowFile(): void - { - $content = <<<'EOD' - name: Verify Bundled Files - - on: - push: - paths: &paths - %paths% - pull_request: - paths: *paths - schedule: - - cron: "0 1 * * *" - workflow_dispatch: ~ - - permissions: - contents: read - - jobs: - VERIFY_BUNDLED_FILES: - name: Verify Bundled Files - runs-on: ubuntu-24.04 - steps: - - name: git checkout - uses: actions/checkout@v5 - - - name: Detect changed files - if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }} - uses: dorny/paths-filter@v3 - id: changes - with: - filters: %filters% - - %steps% - - EOD; - - $paths = [ - '.github/scripts/download-bundled/**', - ]; - foreach ($this->bundles as $bundle) { - foreach ($this->makeDornyPathsFilterFilters($bundle) as $p) { - if (str_starts_with($p, '.github/scripts/download-bundled/')) { - continue; - } - - $paths[] = $p; - } - } - $content = str_replace('%paths%', $this->indentString($this->encodeYml($paths), 3, false), $content); - - $filters = []; - foreach ($this->bundles as $bundle) { - $filters[$bundle->getNameForPath()] = $this->makeDornyPathsFilterFilters($bundle); - } - $content = str_replace('%filters%', $this->indentString($this->encodeYml($this->encodeYml($filters)), 5, false), $content); - - $steps = []; - foreach ($this->bundles as $bundle) { - $steps[] = [ - 'name' => $bundle->name, - 'if' => '${{ !cancelled() && (steps.changes.outputs.' . $bundle->getNameForPath() . ' == \'true\' || github.event_name == \'schedule\' || github.event_name == \'workflow_dispatch\') }}', - 'run' => implode("\n", [ - 'echo "::group::Download"', - '.github/scripts/download-bundled/' . $bundle->getNameForPath() . '.sh', - 'echo "::endgroup::"', - 'echo "::group::Verify files"', - ...array_map(static fn ($v) => '.github/scripts/test-directory-unchanged.sh \'' . $v . '\'', $bundle->directories), - 'echo "::endgroup::"', - ]), - ]; - } - $content = str_replace('%steps%', $this->indentString($this->encodeYml($steps), 3, false), $content); - - file_put_contents($this->getRepoDirectory() . '/.github/workflows/verify-bundled-files.yml', $content); - } - - protected function makeDornyPathsFilterFilters(Bundle $bundle): array - { - return [ - '.github/scripts/download-bundled/' . $bundle->getNameForPath() . '.*', - ...array_map(static fn ($v) => $v . '/**', $bundle->directories), - ]; - } - - public function makeDownloadScriptHeaders(): void - { - foreach ($this->bundles as $bundle) { - $this->makeDownloadScriptHeader($bundle); - } - } - - protected function makeDownloadScriptHeader(Bundle $bundle): void - { - $scriptPath = $this->getRepoDirectory() . '/.github/scripts/download-bundled/' . $bundle->getNameForPath() . '.sh'; - - $content = !file_exists($scriptPath) - ? "# TODO\n" - : file_get_contents($scriptPath); - - $header = <<<'EOD' - #!/bin/sh - set -ex - cd "$(dirname "$0")/../../.." - - tmp_dir=%tmp_dir% - rm -rf "$tmp_dir" - - - EOD; - - $header = str_replace('%tmp_dir%', '/tmp/php-src-download-bundled/' . $bundle->getNameForPath(), $header); - - if (!str_starts_with($content, $header)) { - $content = $header . $content; - } - - file_put_contents($scriptPath, $content); - } -} - -$generator = new Generator($bundles); -$generator->makeWorkflowFile(); -$generator->makeDownloadScriptHeaders(); diff --git a/.github/workflows/verify-bundled-files.yml b/.github/workflows/verify-bundled-files.yml index 2753f0b8dc722..f28da34378e76 100644 --- a/.github/workflows/verify-bundled-files.yml +++ b/.github/workflows/verify-bundled-files.yml @@ -47,7 +47,7 @@ jobs: .github/scripts/download-bundled/boost-context.sh echo "::endgroup::" echo "::group::Verify files" - .github/scripts/test-directory-unchanged.sh 'Zend/asm' + .github/scripts/test-directory-unchanged.sh Zend/asm echo "::endgroup::" - name: PCRE2 if: ${{ !cancelled() && (steps.changes.outputs.pcre2 == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }} @@ -56,7 +56,7 @@ jobs: .github/scripts/download-bundled/pcre2.sh echo "::endgroup::" echo "::group::Verify files" - .github/scripts/test-directory-unchanged.sh 'ext/pcre/pcre2lib' + .github/scripts/test-directory-unchanged.sh ext/pcre/pcre2lib echo "::endgroup::" - name: uriparser if: ${{ !cancelled() && (steps.changes.outputs.uriparser == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }} @@ -65,5 +65,5 @@ jobs: .github/scripts/download-bundled/uriparser.sh echo "::endgroup::" echo "::group::Verify files" - .github/scripts/test-directory-unchanged.sh 'ext/uri/uriparser' + .github/scripts/test-directory-unchanged.sh ext/uri/uriparser echo "::endgroup::"