Update main-php-matrix-windows.yml #2
Workflow file for this run
This file contains hidden or 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: Windows CI (reusable workflow) | |
on: | |
workflow_call: | |
inputs: | |
php: | |
description: 'PHP version' | |
type: string | |
required: true | |
vs-arch: | |
description: 'CPU arch to build for (x86 or x64)' | |
type: string | |
default: 'x64' | |
vs-crt: | |
description: 'Visual Studio CRT for build (vc15=2017, vs16=2019, vs17=2022)' | |
type: string | |
required: true | |
build-type: | |
description: 'Build type to select deps for (stable or staging)' | |
type: string | |
default: stable | |
env: | |
PHP_SDK_BINARY_TOOLS_VER: 2.2.0 | |
PTHREAD_W32_VER: 3.0.0 | |
jobs: | |
build-php: | |
name: Build PHP & extension | |
runs-on: windows-2019 | |
steps: | |
- name: Checkout PHP build SDK | |
uses: actions/checkout@v4 | |
with: | |
repository: php/php-sdk-binary-tools | |
ref: php-sdk-${{ env.PHP_SDK_BINARY_TOOLS_VER }} #TODO: probably should update this, but haven't tested newer versions | |
path: php-sdk | |
- name: Checkout PHP | |
uses: actions/checkout@v4 | |
with: | |
repository: php/php-src | |
ref: "PHP-${{ inputs.php }}" | |
path: php-src | |
- name: Checkout ext-pmmpthread | |
uses: actions/checkout@v4 | |
with: | |
path: php-src/ext/ext-pmmpthread | |
- name: Set PHP build dependencies directory | |
id: deps | |
shell: cmd | |
run: (echo deps_dir=${{ github.workspace }}\deps)>>%GITHUB_OUTPUT% | |
- name: Cache PHP build dependencies | |
id: deps-cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.deps.outputs.deps_dir }} | |
key: php-deps-${{ inputs.php }}-${{ inputs.vs-arch }}-${{ inputs.vs-crt }}-${{ inputs.build-type }}-windows | |
- name: Download PHP build dependencies | |
shell: cmd | |
working-directory: php-sdk | |
run: | | |
(echo phpsdk_deps -u -t ${{ inputs.vs-crt }} -b ${{ inputs.php }} -a ${{ inputs.vs-arch }} -s ${{ inputs.build-type }} -d "${{ steps.deps.outputs.deps_dir }}")>task.bat | |
call .\phpsdk-${{ inputs.vs-crt }}-${{ inputs.vs-arch }}.bat -t task.bat | |
- name: Download pthreads4w dependency | |
#TODO: cache this too | |
shell: cmd | |
run: | | |
C:\msys64\usr\bin\wget.exe -nv https://github.com/pmmp/DependencyMirror/releases/download/mirror/pthreads4w-code-v${{ env.PTHREAD_W32_VER }}.zip -O temp.zip || exit 1 | |
"C:\Program Files\7-Zip\7z.exe" x -y temp.zip || exit 1 | |
del /s /q temp.zip || exit 1 | |
move pthreads4w-code-* pthreads4w-code || exit 1 | |
- name: Compile pthreads4w | |
#TODO: don't need to rebuild this if cache was hit | |
shell: cmd | |
working-directory: pthreads4w-code | |
run: | | |
(echo nmake VC)>task.bat | |
call "${{ github.workspace }}\php-sdk\phpsdk-${{ inputs.vs-crt }}-${{ inputs.vs-arch }}.bat" -t task.bat | |
- name: Copy pthreads4w files to deps dir | |
shell: cmd | |
working-directory: pthreads4w-code | |
run: | | |
set DEPS_DIR=${{ steps.deps.outputs.deps_dir }} | |
copy pthread.h "%DEPS_DIR%\include\pthread.h" || exit 1 | |
copy sched.h "%DEPS_DIR%\include\sched.h" || exit 1 | |
copy semaphore.h "%DEPS_DIR%\include\semaphore.h" || exit 1 | |
copy _ptw32.h "%DEPS_DIR%\include\_ptw32.h" || exit 1 | |
copy pthreadVC3.lib "%DEPS_DIR%\lib\pthreadVC3.lib" || exit 1 | |
copy pthreadVC3.dll "%DEPS_DIR%\bin\pthreadVC3.dll" || exit 1 | |
copy pthreadVC3.pdb "%DEPS_DIR%\bin\pthreadVC3.pdb" || exit 1 | |
- name: Compile PHP | |
id: compile | |
shell: cmd | |
working-directory: php-src | |
run: | | |
set INSTALL_DIR=${{ github.workspace }}\bin | |
(echo install_dir=%INSTALL_DIR%)>>%GITHUB_OUTPUT% | |
(echo call buildconf.bat)>task.bat | |
(echo call configure.bat^ | |
--disable-all^ | |
--enable-cli^ | |
--enable-zts^ | |
--with-pmmpthread=shared^ | |
--with-pmmpthread-sockets^ | |
--enable-sockets^ | |
--enable-ipv6^ | |
--enable-debug^ | |
--with-prefix=%INSTALL_DIR%^ | |
--with-php-build=${{ github.workspace }}\deps)>>task.bat | |
(echo nmake)>>task.bat | |
(echo nmake install)>>task.bat | |
REM php sdk jank! woohoo | |
call "${{ github.workspace }}\php-sdk\phpsdk-${{ inputs.vs-crt }}-${{ inputs.vs-arch }}.bat" -t task.bat | |
- name: Add | |
- name: Upload build result | |
uses: actions/upload-artifact@v4 | |
with: | |
name: php-build-${{ inputs.php }}-${{ inputs.vs-arch }}-${{ inputs.vs-crt }}-${{ inputs.build-type }}-windows | |
path: ${{ steps.compile.outputs.install_dir }} | |
if-no-files-found: error | |
test-extension: | |
name: Test extension | |
runs-on: windows-2019 | |
needs: [build-php] | |
steps: | |
- name: Download PHP binary | |
id: download | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ inputs.php }}-${{ inputs.vs-arch }}-${{ inputs.vs-crt }}-${{ inputs.build-type }}-windows | |
path: ${{ github.workspace }}/bin | |
- name: Generate php.ini | |
shell: cmd | |
working-directory: ${{ steps.download.outputs.download-path }} | |
run: | | |
(echo [PHP])>php.ini | |
(echo extension_dir=${{ steps.download.outputs.download-path }}\ext)>>php.ini | |
(echo extension=php_pmmpthread.dll)>>php.ini | |
- name: Run test suite | |
shell: cmd | |
working-directory: ${{ steps.download.outputs.download-path }} | |
run: | | |
set TEST_PHP_EXECUTABLE=%~dp0php.exe | |
set REPORT_EXIT_STATUS=1 | |
.\php.exe .\SDK\script\run-tests.php ext\pmmpthread -q --show-diff --offline || exit 1 | |