xref: /php-src/.github/workflows/nightly.yml (revision c3b07a6e)
1name: Nightly
2on:
3  schedule:
4   - cron: "0 1 * * *"
5  workflow_dispatch: ~
6permissions:
7  contents: read
8jobs:
9  GENERATE_MATRIX:
10    name: Generate Matrix
11    if: github.repository == 'php/php-src' || github.event_name == 'workflow_dispatch'
12    runs-on: ubuntu-latest
13    outputs:
14      branches: ${{ steps.set-matrix.outputs.branches }}
15      matrix-include: ${{ steps.set-matrix.outputs.matrix-include }}
16      windows-matrix-include: ${{ steps.set-matrix.outputs.windows-matrix-include }}
17      macos-matrix-include: ${{ steps.set-matrix.outputs.macos-matrix-include }}
18    steps:
19      - uses: actions/checkout@v4
20        with:
21          # Set fetch-depth to 0 to clone the full repository
22          # including all branches. This is required to find
23          # the correct commit hashes.
24          fetch-depth: 0
25      - name: Grab the commit mapping
26        uses: actions/cache@v3
27        with:
28          path: branch-commit-cache.json
29          # The cache key needs to change every time for the
30          # cache to be updated after this job finishes.
31          key: nightly-${{ github.run_id }}-${{ github.run_attempt }}
32          restore-keys: |
33            nightly-
34      - name: Generate Matrix
35        id: set-matrix
36        run: php .github/nightly_matrix.php "${{ github.event_name }}" "${{ github.run_attempt }}" "${{ github.head_ref || github.ref_name }}"
37      - name: Notify Slack
38        if: failure()
39        uses: ./.github/actions/notify-slack
40        with:
41          token: ${{ secrets.ACTION_MONITORING_SLACK }}
42  LINUX_X64:
43    needs: GENERATE_MATRIX
44    if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
45    services:
46      postgres:
47        image: postgres
48        env:
49          POSTGRES_USER: postgres
50          POSTGRES_PASSWORD: postgres
51          POSTGRES_DB: test
52      firebird:
53        image: jacobalberty/firebird
54        ports:
55          - 3050:3050
56        env:
57          ISC_PASSWORD: test
58          FIREBIRD_DATABASE: test.fdb
59          FIREBIRD_USER: test
60          FIREBIRD_PASSWORD: test
61    strategy:
62      fail-fast: false
63      matrix:
64        branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
65        configuration_parameters: ['']
66        debug: [true, false]
67        name: ['']
68        run_tests_parameters: ['']
69        test_function_jit: [true]
70        zts: [true, false]
71        include: ${{ fromJson(needs.GENERATE_MATRIX.outputs.matrix-include) }}
72    name: "${{ matrix.branch.name }}_LINUX_X64${{ matrix.name }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
73    runs-on: ubuntu-${{ (matrix.branch.version.minor >= 3 && !matrix.asan) && '22.04' || '20.04' }}
74    steps:
75      - name: git checkout
76        uses: actions/checkout@v4
77        with:
78          ref: ${{ matrix.branch.ref }}
79      - name: Create MSSQL container
80        uses: ./.github/actions/setup-mssql
81      - name: apt
82        uses: ./.github/actions/apt-x64
83      - name: System info
84        run: |
85          echo "::group::Show host CPU info"
86          lscpu
87          echo "::endgroup::"
88          echo "::group::Show installed package versions"
89          dpkg -l
90          echo "::endgroup::"
91      - name: ./configure
92        uses: ./.github/actions/configure-x64
93        with:
94          configurationParameters: >-
95            ${{ matrix.configuration_parameters }}
96            --${{ matrix.debug && 'enable' || 'disable' }}-debug
97            --${{ matrix.zts && 'enable' || 'disable' }}-zts
98      - name: make
99        run: make -j$(/usr/bin/nproc) >/dev/null
100      - name: make install
101        uses: ./.github/actions/install-linux
102      - name: Setup
103        uses: ./.github/actions/setup-x64
104      - name: Test
105        uses: ./.github/actions/test-linux
106        with:
107          testArtifacts: ${{ matrix.branch.name }}_${{ matrix.name }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}
108          runTestsParameters: >-
109            ${{ matrix.run_tests_parameters }}
110          idleCpu: ${{ matrix.asan && 'true' || 'false' }}
111      - name: Test Tracing JIT
112        uses: ./.github/actions/test-linux
113        with:
114          testArtifacts: ${{ matrix.branch.name }}_${{ matrix.name }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} Tracing JIT
115          jitType: tracing
116          runTestsParameters: >-
117            ${{ matrix.run_tests_parameters }}
118            -d zend_extension=opcache.so
119            -d opcache.enable_cli=1
120      - name: Test OpCache
121        uses: ./.github/actions/test-linux
122        with:
123          testArtifacts: ${{ matrix.branch.name }}_${{ matrix.name }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} OpCache
124          runTestsParameters: >-
125            ${{ matrix.run_tests_parameters }}
126            -d zend_extension=opcache.so
127            -d opcache.enable_cli=1
128      - name: Test Function JIT
129        # ASAN frequently timeouts. Each test run takes ~90 minutes, we can
130        # avoid running into the 6 hour timeout by skipping the function JIT.
131        if: matrix.test_function_jit
132        uses: ./.github/actions/test-linux
133        with:
134          testArtifacts: ${{ matrix.branch.name }}_${{ matrix.name }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} Function JIT
135          jitType: function
136          runTestsParameters: >-
137            ${{ matrix.run_tests_parameters }}
138            -d zend_extension=opcache.so
139            -d opcache.enable_cli=1
140      - name: Verify generated files are up to date
141        uses: ./.github/actions/verify-generated-files
142      - name: Notify Slack
143        if: failure()
144        uses: ./.github/actions/notify-slack
145        with:
146          token: ${{ secrets.ACTION_MONITORING_SLACK }}
147  LINUX_X32:
148    needs: GENERATE_MATRIX
149    if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
150    strategy:
151      fail-fast: false
152      matrix:
153        branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
154        debug: [true, false]
155        zts: [true, false]
156    name: "${{ matrix.branch.name }}_LINUX_X32_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
157    runs-on: ubuntu-latest
158    container:
159      image: ubuntu:${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }}
160    services:
161      mysql:
162        image: mysql:8
163        ports:
164          - 3306:3306
165        env:
166          MYSQL_DATABASE: test
167          MYSQL_ROOT_PASSWORD: root
168    steps:
169      - name: git checkout
170        uses: actions/checkout@v4
171        with:
172          ref: ${{ matrix.branch.ref }}
173      - name: apt
174        uses: ./.github/actions/apt-x32
175      - name: System info
176        run: |
177          echo "::group::Show host CPU info"
178          lscpu
179          echo "::endgroup::"
180          echo "::group::Show installed package versions"
181          dpkg -l
182          echo "::endgroup::"
183      - name: ./configure
184        uses: ./.github/actions/configure-x32
185        with:
186          configurationParameters: >-
187            --${{ matrix.debug && 'enable' || 'disable' }}-debug
188            --${{ matrix.zts && 'enable' || 'disable' }}-zts
189      - name: make
190        run: make -j$(/usr/bin/nproc) >/dev/null
191      - name: make install
192        uses: ./.github/actions/install-linux-x32
193      - name: Test
194        uses: ./.github/actions/test-linux
195        with:
196          runTestsParameters: >-
197            ${{ matrix.run_tests_parameters }}
198      - name: Test Tracing JIT
199        uses: ./.github/actions/test-linux
200        with:
201          jitType: tracing
202          runTestsParameters: >-
203            ${{ matrix.run_tests_parameters }}
204            -d zend_extension=opcache.so
205            -d opcache.enable_cli=1
206      - name: Test OpCache
207        uses: ./.github/actions/test-linux
208        with:
209          runTestsParameters: >-
210            ${{ matrix.run_tests_parameters }}
211            -d zend_extension=opcache.so
212            -d opcache.enable_cli=1
213      - name: Test Function JIT
214        uses: ./.github/actions/test-linux
215        with:
216          jitType: function
217          runTestsParameters: >-
218            ${{ matrix.run_tests_parameters }}
219            -d zend_extension=opcache.so
220            -d opcache.enable_cli=1
221      - name: Notify Slack
222        if: failure()
223        uses: ./.github/actions/notify-slack
224        with:
225          token: ${{ secrets.ACTION_MONITORING_SLACK }}
226  MACOS:
227    needs: GENERATE_MATRIX
228    if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
229    strategy:
230      fail-fast: false
231      matrix:
232        include: ${{ fromJson(needs.GENERATE_MATRIX.outputs.macos-matrix-include) }}
233    name: "${{ matrix.branch.name }}_MACOS_${{ matrix.arch }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
234    runs-on: macos-${{ matrix.os }}
235    steps:
236      - name: git checkout
237        uses: actions/checkout@v4
238        with:
239          ref: ${{ matrix.branch.ref }}
240      - name: brew
241        uses: ./.github/actions/brew
242      - name: ./configure
243        uses: ./.github/actions/configure-macos
244        with:
245          configurationParameters: >-
246            --${{ matrix.debug && 'enable' || 'disable' }}-debug
247            --${{ matrix.zts && 'enable' || 'disable' }}-zts
248      - name: make
249        run: |-
250          export PATH="$(brew --prefix)/opt/bison/bin:$PATH"
251          make -j$(sysctl -n hw.logicalcpu) >/dev/null
252      - name: make install
253        run: sudo make install
254      - name: Test
255        uses: ./.github/actions/test-macos
256        with:
257          testArtifacts: ${{ matrix.branch.name }}_${{ matrix.arch }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}
258      - name: Test Tracing JIT
259        if: matrix.test_jit
260        uses: ./.github/actions/test-macos
261        with:
262          testArtifacts: ${{ matrix.branch.name }}_${{ matrix.arch }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} Tracing JIT
263          jitType: tracing
264          runTestsParameters: >-
265            -d zend_extension=opcache.so
266            -d opcache.enable_cli=1
267      - name: Test OpCache
268        uses: ./.github/actions/test-macos
269        with:
270          testArtifacts: ${{ matrix.branch.name }}_${{ matrix.arch }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} OpCache
271          runTestsParameters: >-
272            -d zend_extension=opcache.so
273            -d opcache.enable_cli=1
274      - name: Test Function JIT
275        if: matrix.test_jit
276        uses: ./.github/actions/test-macos
277        with:
278          testArtifacts: ${{ matrix.branch.name }}_${{ matrix.arch }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} Function JIT
279          jitType: function
280          runTestsParameters: >-
281            -d zend_extension=opcache.so
282            -d opcache.enable_cli=1
283      - name: Verify generated files are up to date
284        uses: ./.github/actions/verify-generated-files
285      - name: Notify Slack
286        if: failure()
287        uses: ./.github/actions/notify-slack
288        with:
289          token: ${{ secrets.ACTION_MONITORING_SLACK }}
290  COVERAGE_DEBUG_NTS:
291    if: github.repository == 'php/php-src' || github.event_name == 'workflow_dispatch'
292    services:
293      postgres:
294        image: postgres
295        env:
296          POSTGRES_USER: postgres
297          POSTGRES_PASSWORD: postgres
298          POSTGRES_DB: test
299      firebird:
300        image: jacobalberty/firebird
301        ports:
302          - 3050:3050
303        env:
304          ISC_PASSWORD: test
305          FIREBIRD_DATABASE: test.fdb
306          FIREBIRD_USER: test
307          FIREBIRD_PASSWORD: test
308    runs-on: ubuntu-22.04
309    steps:
310      - name: git checkout
311        uses: actions/checkout@v4
312      - name: Create MSSQL container
313        uses: ./.github/actions/setup-mssql
314      - name: apt
315        uses: ./.github/actions/apt-x64
316      - name: Install gcovr
317        run: sudo -H pip install gcovr
318      - name: ./configure
319        uses: ./.github/actions/configure-x64
320        with:
321          configurationParameters: --enable-debug --disable-zts --enable-gcov
322      - name: make
323        run: make -j$(/usr/bin/nproc) >/dev/null
324      - name: make install
325        uses: ./.github/actions/install-linux
326      - name: Setup
327        uses: ./.github/actions/setup-x64
328      # We only test with OpCache, the difference in coverage is negligible
329      - name: Test OpCache
330        uses: ./.github/actions/test-linux
331        with:
332          jitType: tracing
333          runTestsParameters: >-
334            -d zend_extension=opcache.so
335            -d opcache.enable_cli=1
336      - name: Upload Test Coverage to Codecov.io
337        if: always()
338        run: bash <(curl -s https://codecov.io/bash)
339      - name: Notify Slack
340        if: failure()
341        uses: ./.github/actions/notify-slack
342        with:
343          token: ${{ secrets.ACTION_MONITORING_SLACK }}
344  COMMUNITY:
345    needs: GENERATE_MATRIX
346    if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
347    strategy:
348      fail-fast: false
349      matrix:
350        branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
351        type: ['asan', 'verify_type_inference']
352        # These branches don't include type verification
353        exclude:
354          - { branch: { name: 'PHP-8.1', ref: 'PHP-8.1', major: 8, minor: 1 }, type: 'verify_type_inference' }
355          - { branch: { name: 'PHP-8.2', ref: 'PHP-8.2', major: 8, minor: 2 }, type: 'verify_type_inference' }
356          - { branch: { name: 'PHP-8.3', ref: 'PHP-8.3', major: 8, minor: 3 }, type: 'verify_type_inference' }
357    name: "${{ matrix.branch.name }}_COMMUNITY_${{ matrix.type }}"
358    runs-on: ubuntu-${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }}
359    env:
360      ASAN_OPTIONS: exitcode=139
361      UBSAN_OPTIONS: print_stacktrace=1
362      USE_ZEND_ALLOC: 0
363      USE_TRACKED_ALLOC: 1
364    steps:
365      - name: git checkout
366        uses: actions/checkout@v4
367        with:
368          ref: ${{ matrix.branch.ref }}
369      - name: apt
370        uses: ./.github/actions/apt-x64
371      - name: ./configure
372        uses: ./.github/actions/configure-x64
373        with:
374          # CFLAGS removes O2, so we have to add it again...
375          configurationParameters: >-
376            --enable-zts
377            ${{ matrix.type == 'asan' && '--enable-debug CFLAGS="-fsanitize=undefined,address -fno-sanitize-recover -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=undefined,address"' || '' }}
378            ${{ matrix.type == 'verify_type_inference' && 'CFLAGS="-DZEND_VERIFY_TYPE_INFERENCE -O2"' || '' }}
379      - name: make
380        run: make -j$(/usr/bin/nproc) >/dev/null
381      - name: make install
382        uses: ./.github/actions/install-linux
383      - name: Setup
384        run: |
385          sudo service mysql start
386          mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS test"
387          mysql -uroot -proot -e "SET GLOBAL local_infile = true"
388      - name: Enable Opcache
389        run: |
390          echo memory_limit=-1 >> /etc/php.d/opcache.ini
391          echo zend_extension=opcache.so > /etc/php.d/opcache.ini
392          echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini
393          echo opcache.enable=1 >> /etc/php.d/opcache.ini
394          echo opcache.protect_memory=1 >> /etc/php.d/opcache.ini
395          echo opcache.memory_consumption=256M >> /etc/php.d/opcache.ini
396          echo opcache.file_update_protection=0 >> /etc/php.d/opcache.ini
397          echo opcache.interned_strings_buffer=64 >> /etc/php.d/opcache.ini
398          echo opcache.max_accelerated_files=100000 >> /etc/php.d/opcache.ini
399      - name: Enable JIT
400        if: matrix.type != 'verify_type_inference'
401        run: |
402          echo opcache.jit=tracing >> /etc/php.d/opcache.ini
403          echo opcache.jit_buffer_size=1G >> /etc/php.d/opcache.ini
404          echo opcache.jit_max_root_traces=100000 >> /etc/php.d/opcache.ini
405          echo opcache.jit_max_side_traces=100000 >> /etc/php.d/opcache.ini
406          echo opcache.jit_max_exit_counters=100000 >> /etc/php.d/opcache.ini
407          echo opcache.jit_hot_loop=1 >> /etc/php.d/opcache.ini
408          echo opcache.jit_hot_func=1 >> /etc/php.d/opcache.ini
409          echo opcache.jit_hot_return=1 >> /etc/php.d/opcache.ini
410          echo opcache.jit_hot_side_exit=1 >> /etc/php.d/opcache.ini
411          php -v
412      - name: Test AMPHP
413        if: always()
414        run: |
415          repositories="amp cache dns file http parallel parser pipeline process serialization socket sync websocket-client websocket-server"
416          X=0
417          for repository in $repositories; do
418            printf "Testing amp/%s\n" "$repository"
419            git clone "https://github.com/amphp/$repository.git" "amphp-$repository" --depth 1
420            cd "amphp-$repository"
421            git rev-parse HEAD
422            php /usr/bin/composer install --no-progress --ignore-platform-reqs
423            vendor/bin/phpunit || EXIT_CODE=$?
424            if [ ${EXIT_CODE:-0} -gt 128 ]; then
425              X=1;
426            fi
427            cd ..
428          done
429          exit $X
430      - name: Test Laravel
431        if: always()
432        run: |
433          git clone https://github.com/laravel/framework.git --branch=master --depth=1
434          cd framework
435          git rev-parse HEAD
436          php /usr/bin/composer install --no-progress --ignore-platform-reqs
437          # Hack to disable a test that hangs
438          php -r '$c = file_get_contents("tests/Filesystem/FilesystemTest.php"); $c = str_replace("public function testSharedGet()", "#[\\PHPUnit\\Framework\\Attributes\\Group('"'"'skip'"'"')]\n    public function testSharedGet()", $c); file_put_contents("tests/Filesystem/FilesystemTest.php", $c);'
439          php vendor/bin/phpunit --exclude-group skip || EXIT_CODE=$?
440          if [ ${EXIT_CODE:-0} -gt 128 ]; then
441            exit 1
442          fi
443      - name: Test ReactPHP
444        if: always()
445        run: |
446          repositories="async cache child-process datagram dns event-loop promise promise-stream promise-timer stream"
447          X=0
448          for repository in $repositories; do
449            printf "Testing reactphp/%s\n" "$repository"
450            git clone "https://github.com/reactphp/$repository.git" "reactphp-$repository" --depth 1
451            cd "reactphp-$repository"
452            git rev-parse HEAD
453            php /usr/bin/composer install --no-progress --ignore-platform-reqs
454            vendor/bin/phpunit || EXIT_CODE=$?
455            if [ $[EXIT_CODE:-0} -gt 128 ]; then
456              X=1;
457            fi
458            cd ..
459          done
460          exit $X
461      - name: Test Revolt PHP
462        if: always()
463        run: |
464          git clone https://github.com/revoltphp/event-loop.git --depth=1
465          cd event-loop
466          git rev-parse HEAD
467          php /usr/bin/composer install --no-progress --ignore-platform-reqs
468          vendor/bin/phpunit || EXIT_CODE=$?
469          if [ ${EXIT_CODE:-0} -gt 128 ]; then
470            exit 1
471          fi
472      - name: Test Symfony
473        if: always()
474        run: |
475          git clone https://github.com/symfony/symfony.git --depth=1
476          cd symfony
477          git rev-parse HEAD
478          php /usr/bin/composer install --no-progress --ignore-platform-reqs
479          php ./phpunit install
480          # Test causes a heap-buffer-overflow but I cannot reproduce it locally...
481          php -r '$c = file_get_contents("src/Symfony/Component/HtmlSanitizer/Tests/HtmlSanitizerCustomTest.php"); $c = str_replace("public function testSanitizeDeepNestedString()", "/** @group skip */\n    public function testSanitizeDeepNestedString()", $c); file_put_contents("src/Symfony/Component/HtmlSanitizer/Tests/HtmlSanitizerCustomTest.php", $c);'
482          # Buggy FFI test in Symfony, see https://github.com/symfony/symfony/issues/47668
483          php -r '$c = file_get_contents("src/Symfony/Component/VarDumper/Tests/Caster/FFICasterTest.php"); $c = str_replace("*/\n    public function testCastNonTrailingCharPointer()", "* @group skip\n     */\n    public function testCastNonTrailingCharPointer()", $c); file_put_contents("src/Symfony/Component/VarDumper/Tests/Caster/FFICasterTest.php", $c);'
484          export SYMFONY_DEPRECATIONS_HELPER=max[total]=999
485          X=0
486          for component in $(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n'); do
487            php ./phpunit $component --exclude-group tty,benchmark,intl-data,transient --exclude-group skip || EXIT_CODE=$?
488            if [ ${EXIT_CODE:-0} -gt 128 ]; then
489              X=1;
490            fi
491          done
492          exit $X
493      - name: Test PHPUnit
494        if: always()
495        run: |
496          git clone https://github.com/sebastianbergmann/phpunit.git --branch=main --depth=1
497          cd phpunit
498          git rev-parse HEAD
499          php /usr/bin/composer install --no-progress --ignore-platform-reqs
500          php ./phpunit || EXIT_CODE=$?
501          if [ ${EXIT_CODE:-0} -gt 128 ]; then
502            exit 1
503          fi
504      - name: 'Symfony Preloading'
505        if: always()
506        run: |
507          php /usr/bin/composer create-project symfony/symfony-demo symfony_demo --no-progress --ignore-platform-reqs
508          cd symfony_demo
509          git rev-parse HEAD
510          sed -i 's/PHP_SAPI/"cli-server"/g' var/cache/dev/App_KernelDevDebugContainer.preload.php
511          php -d opcache.preload=var/cache/dev/App_KernelDevDebugContainer.preload.php public/index.php
512      - name: Test Wordpress
513        if: always()
514        run: |
515          git clone https://github.com/WordPress/wordpress-develop.git wordpress --depth=1
516          cd wordpress
517          git rev-parse HEAD
518          php /usr/bin/composer install --no-progress --ignore-platform-reqs
519          cp wp-tests-config-sample.php wp-tests-config.php
520          sed -i 's/youremptytestdbnamehere/test/g' wp-tests-config.php
521          sed -i 's/yourusernamehere/root/g' wp-tests-config.php
522          sed -i 's/yourpasswordhere/root/g' wp-tests-config.php
523          php vendor/bin/phpunit || EXIT_CODE=$?
524          if [ $EXIT_CODE -gt 128 ]; then
525            exit 1
526          fi
527      - name: Notify Slack
528        if: failure()
529        uses: ./.github/actions/notify-slack
530        with:
531          token: ${{ secrets.ACTION_MONITORING_SLACK }}
532  OPCACHE_VARIATION:
533    needs: GENERATE_MATRIX
534    if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
535    services:
536      postgres:
537        image: postgres
538        env:
539          POSTGRES_USER: postgres
540          POSTGRES_PASSWORD: postgres
541          POSTGRES_DB: test
542      firebird:
543        image: jacobalberty/firebird
544        ports:
545          - 3050:3050
546        env:
547          ISC_PASSWORD: test
548          FIREBIRD_DATABASE: test.fdb
549          FIREBIRD_USER: test
550          FIREBIRD_PASSWORD: test
551    strategy:
552      fail-fast: false
553      matrix:
554        branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
555    name: "${{ matrix.branch.name }}_OPCACHE_VARIATION"
556    runs-on: ubuntu-${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }}
557    steps:
558      - name: git checkout
559        uses: actions/checkout@v4
560        with:
561          ref: ${{ matrix.branch.ref }}
562      - name: Create MSSQL container
563        uses: ./.github/actions/setup-mssql
564      - name: apt
565        uses: ./.github/actions/apt-x64
566      - name: ./configure
567        uses: ./.github/actions/configure-x64
568        with:
569          configurationParameters: >-
570            --enable-debug --disable-zts
571      - name: make
572        run: make -j$(/usr/bin/nproc) >/dev/null
573      - name: make install
574        uses: ./.github/actions/install-linux
575      - name: Setup
576        uses: ./.github/actions/setup-x64
577      - name: Test File Cache (prime shm)
578        uses: ./.github/actions/test-linux
579        with:
580          runTestsParameters: >-
581            -d zend_extension=opcache.so
582            -d opcache.enable_cli=1
583            --file-cache-prime
584      - name: Test File Cache (prime shm, use shm)
585        uses: ./.github/actions/test-linux
586        with:
587          runTestsParameters: >-
588            -d zend_extension=opcache.so
589            -d opcache.enable_cli=1
590            --file-cache-use
591      - name: Test File Cache (prime shm, use file)
592        uses: ./.github/actions/test-linux
593        with:
594          runTestsParameters: >-
595            -d zend_extension=opcache.so
596            -d opcache.enable_cli=1
597            --file-cache-use
598            -d opcache.file_cache_only=1
599      - name: Test File Cache Only (prime)
600        uses: ./.github/actions/test-linux
601        with:
602          runTestsParameters: >-
603            -d zend_extension=opcache.so
604            -d opcache.enable_cli=1
605            --file-cache-prime
606            -d opcache.file_cache_only=1
607      - name: Test File Cache Only (use)
608        uses: ./.github/actions/test-linux
609        with:
610          runTestsParameters: >-
611            -d zend_extension=opcache.so
612            -d opcache.enable_cli=1
613            --file-cache-use
614            -d opcache.file_cache_only=1
615      - name: Verify generated files are up to date
616        uses: ./.github/actions/verify-generated-files
617      - name: Notify Slack
618        if: failure()
619        uses: ./.github/actions/notify-slack
620        with:
621          token: ${{ secrets.ACTION_MONITORING_SLACK }}
622  MSAN:
623    needs: GENERATE_MATRIX
624    if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
625    strategy:
626      fail-fast: false
627      matrix:
628        branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
629    name: "${{ matrix.branch.name }}_MSAN"
630    runs-on: ubuntu-${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }}
631    steps:
632      - name: git checkout
633        uses: actions/checkout@v4
634        with:
635          ref: ${{ matrix.branch.ref }}
636      - name: apt
637        uses: ./.github/actions/apt-x64
638      - name: ./configure
639        run: |
640          export CC=clang
641          export CXX=clang++
642          export CFLAGS="-DZEND_TRACK_ARENA_ALLOC"
643          ./buildconf --force
644          # msan requires all used libraries to be instrumented,
645          # so we should avoiding linking against anything but libc here
646          ./configure \
647            --enable-debug \
648            --enable-zts \
649            --enable-option-checking=fatal \
650            --prefix=/usr \
651            --without-sqlite3 \
652            --without-pdo-sqlite \
653            --without-libxml \
654            --disable-dom \
655            --disable-simplexml \
656            --disable-xml \
657            --disable-xmlreader \
658            --disable-xmlwriter \
659            --without-pcre-jit \
660            --disable-opcache-jit \
661            --enable-phpdbg \
662            --enable-fpm \
663            --with-pdo-mysql=mysqlnd \
664            --with-mysqli=mysqlnd \
665            --disable-mysqlnd-compression-support \
666            --without-pear \
667            --enable-exif \
668            --enable-sysvsem \
669            --enable-sysvshm \
670            --enable-shmop \
671            --enable-pcntl \
672            --enable-mbstring \
673            --disable-mbregex \
674            --enable-sockets \
675            --enable-bcmath \
676            --enable-calendar \
677            --enable-ftp \
678            --enable-zend-test \
679            --enable-werror \
680            --enable-memory-sanitizer \
681            --with-config-file-path=/etc \
682            --with-config-file-scan-dir=/etc/php.d \
683            --enable-dl-test=shared
684      - name: make
685        run: make -j$(/usr/bin/nproc) >/dev/null
686      - name: make install
687        run: |
688          sudo make install
689          sudo mkdir -p /etc/php.d
690          sudo chmod 777 /etc/php.d
691          echo mysqli.default_socket=/var/run/mysqld/mysqld.sock    > /etc/php.d/mysqli.ini
692          echo pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/pdo_mysql.ini
693      - name: Setup
694        run: |
695          set -x
696          sudo service mysql start
697          mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS test"
698          # Ensure local_infile tests can run.
699          mysql -uroot -proot -e "SET GLOBAL local_infile = true"
700          sudo locale-gen de_DE
701      - name: Test
702        uses: ./.github/actions/test-linux
703        with:
704          runTestsParameters: >-
705            --msan
706      - name: Test Opcache
707        uses: ./.github/actions/test-linux
708        with:
709          runTestsParameters: >-
710            --msan
711            -d zend_extension=opcache.so
712            -d opcache.enable_cli=1
713      - name: Verify generated files are up to date
714        uses: ./.github/actions/verify-generated-files
715      - name: Notify Slack
716        if: failure()
717        uses: ./.github/actions/notify-slack
718        with:
719          token: ${{ secrets.ACTION_MONITORING_SLACK }}
720  LIBMYSQLCLIENT:
721    needs: GENERATE_MATRIX
722    if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
723    strategy:
724      fail-fast: false
725      matrix:
726        branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
727    name: "${{ matrix.branch.name }}_LIBMYSQLCLIENT"
728    runs-on: ubuntu-${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }}
729    steps:
730      - name: git checkout
731        uses: actions/checkout@v4
732        with:
733          ref: ${{ matrix.branch.ref }}
734      - name: apt
735        run: |
736          sudo apt-get update -y | true
737          sudo apt install bison re2c
738      - name: Setup
739        run: |
740          sudo service mysql start
741          mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS test"
742          # Ensure local_infile tests can run.
743          mysql -uroot -proot -e "SET GLOBAL local_infile = true"
744      - name: Build mysql-8.0
745        uses: ./.github/actions/build-libmysqlclient
746        with:
747          configurationParameters: --enable-werror
748          libmysql: mysql-8.0.35-linux-glibc2.28-x86_64.tar.xz
749          withMysqli: ${{ matrix.branch.ref == 'PHP-8.1' }}
750      - name: Test mysql-8.0
751        uses: ./.github/actions/test-libmysqlclient
752        with:
753          withMysqli: ${{ matrix.branch.ref == 'PHP-8.1' }}
754      - name: Build mysql-8.2
755        uses: ./.github/actions/build-libmysqlclient
756        with:
757          configurationParameters: --enable-werror
758          libmysql: mysql-8.2.0-linux-glibc2.28-x86_64.tar.xz
759          withMysqli: ${{ matrix.branch.ref == 'PHP-8.1' }}
760      - name: Test mysql-8.2
761        uses: ./.github/actions/test-libmysqlclient
762        with:
763          withMysqli: ${{ matrix.branch.ref == 'PHP-8.1' }}
764      - name: Verify generated files are up to date
765        uses: ./.github/actions/verify-generated-files
766      - name: Notify Slack
767        if: failure()
768        uses: ./.github/actions/notify-slack
769        with:
770          token: ${{ secrets.ACTION_MONITORING_SLACK }}
771  PECL:
772    if: github.repository == 'php/php-src' || github.event_name == 'workflow_dispatch'
773    runs-on: ubuntu-22.04
774    env:
775      CC: ccache gcc
776      CXX: ccache g++
777    steps:
778      - name: git checkout PHP
779        uses: actions/checkout@v4
780        with:
781          path: php
782      - name: git checkout apcu
783        uses: actions/checkout@v4
784        with:
785          repository: krakjoe/apcu
786          path: apcu
787      - name: git checkout imagick
788        uses: actions/checkout@v4
789        with:
790          repository: Imagick/imagick
791          path: imagick
792      - name: git checkout memcached
793        uses: actions/checkout@v4
794        with:
795          repository: php-memcached-dev/php-memcached
796          path: memcached
797      - name: git checkout redis
798        # Currently fails to build
799        if: false
800        uses: actions/checkout@v4
801        with:
802          repository: phpredis/phpredis
803          path: redis
804      - name: git checkout xdebug
805        uses: actions/checkout@v4
806        with:
807          repository: xdebug/xdebug
808          path: xdebug
809      - name: git checkout yaml
810        uses: actions/checkout@v4
811        with:
812          repository: php/pecl-file_formats-yaml
813          path: yaml
814      - name: apt
815        run: |
816          sudo apt-get update
817          sudo apt-get install -y --no-install-recommends \
818            ccache \
819            libmemcached-dev \
820            bison \
821            re2c
822      - name: ccache
823        uses: hendrikmuhs/ccache-action@v1.2
824        with:
825          key: "${{github.job}}-${{hashFiles('php/main/php_version.h')}}"
826          append-timestamp: false
827      - name: build PHP
828        run: |
829          cd php
830          ./buildconf --force
831          ./configure \
832            --enable-option-checking=fatal \
833            --prefix=/opt/php \
834            --enable-cli \
835            --disable-all \
836            --enable-session \
837            --enable-werror
838          make -j$(/usr/bin/nproc)
839          sudo make install
840      - name: build apcu
841        run: |
842          cd apcu
843          /opt/php/bin/phpize
844          ./configure --prefix=/opt/php --with-php-config=/opt/php/bin/php-config
845          make -j$(/usr/bin/nproc)
846      - name: build imagick
847        run: |
848          cd imagick
849          /opt/php/bin/phpize
850          ./configure --prefix=/opt/php --with-php-config=/opt/php/bin/php-config
851          make -j$(/usr/bin/nproc)
852      - name: build memcached
853        run: |
854          cd memcached
855          /opt/php/bin/phpize
856          ./configure --prefix=/opt/php --with-php-config=/opt/php/bin/php-config
857          make -j$(/usr/bin/nproc)
858      - name: build redis
859        # Currently fails to build
860        if: false
861        run: |
862          cd redis
863          /opt/php/bin/phpize
864          ./configure --prefix=/opt/php --with-php-config=/opt/php/bin/php-config
865          make -j$(/usr/bin/nproc)
866      - name: build xdebug
867        run: |
868          cd xdebug
869          /opt/php/bin/phpize
870          ./configure --prefix=/opt/php --with-php-config=/opt/php/bin/php-config
871          make -j$(/usr/bin/nproc)
872      - name: build yaml
873        run: |
874          cd yaml
875          /opt/php/bin/phpize
876          ./configure --prefix=/opt/php --with-php-config=/opt/php/bin/php-config
877          make -j$(/usr/bin/nproc)
878      - name: Notify Slack
879        if: failure()
880        uses: ./.github/actions/notify-slack
881        with:
882          token: ${{ secrets.ACTION_MONITORING_SLACK }}
883  WINDOWS:
884    needs: GENERATE_MATRIX
885    if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
886    strategy:
887      fail-fast: false
888      matrix:
889        include: ${{ fromJson(needs.GENERATE_MATRIX.outputs.windows-matrix-include) }}
890    name: "${{ matrix.branch.name }}_WINDOWS_${{ matrix.x64 && 'X64' || 'X86' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
891    runs-on: windows-2019
892    env:
893      PHP_BUILD_CACHE_BASE_DIR: C:\build-cache
894      PHP_BUILD_OBJ_DIR: C:\obj
895      PHP_BUILD_CACHE_SDK_DIR: C:\build-cache\sdk
896      PHP_BUILD_SDK_BRANCH: php_downloads_server_migration_v1
897      PHP_BUILD_CRT: vs16
898      PLATFORM: ${{ matrix.x64 && 'x64' || 'x86' }}
899      THREAD_SAFE: "${{ matrix.zts && '1' || '0' }}"
900      INTRINSICS: "${{ matrix.zts && 'AVX2' || '' }}"
901      PARALLEL: -j2
902      OPCACHE: "${{ matrix.opcache && '1' || '0' }}"
903    steps:
904      - name: git config
905        run: git config --global core.autocrlf false && git config --global core.eol lf
906      - name: git checkout
907        uses: actions/checkout@v4
908        with:
909          ref: ${{ matrix.branch.ref }}
910      - name: Setup
911        uses: ./.github/actions/setup-windows
912      - name: Build
913        run: .github/scripts/windows/build.bat
914      - name: Test
915        run: .github/scripts/windows/test.bat
916