xref: /PHP-8.0/.github/workflows/nightly.yml (revision cdc0a8b0)
1name: Nightly
2on:
3  schedule:
4   - cron: "0 1 * * *"
5  workflow_dispatch: ~
6jobs:
7  GENERATE_MATRIX:
8    name: Generate Matrix
9    if: github.repository_owner == 'php' || github.event_name == 'workflow_dispatch'
10    runs-on: ubuntu-latest
11    outputs:
12      branches: ${{ steps.set-matrix.outputs.branches }}
13      matrix-include: ${{ steps.set-matrix.outputs.matrix-include }}
14    steps:
15      - uses: actions/checkout@v3
16        with:
17          # Set fetch-depth to 0 to clone the full repository
18          # including all branches. This is required to find
19          # the correct commit hashes.
20          fetch-depth: 0
21      - name: Grab the commit mapping
22        uses: actions/cache@v3
23        with:
24          path: branch-commit-cache.json
25          # The cache key needs to change every time for the
26          # cache to be updated after this job finishes.
27          key: nightly-${{ github.run_id }}-${{ github.run_attempt }}
28          restore-keys: |
29            nightly-
30      - name: Generate Matrix
31        id: set-matrix
32        run: php .github/nightly_matrix.php "${{ github.event_name }}" "${{ github.run_attempt }}"
33  LINUX_X64:
34    needs: GENERATE_MATRIX
35    if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
36    strategy:
37      fail-fast: false
38      matrix:
39        branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
40        configuration_parameters: ['']
41        debug: [true, false]
42        name: ['']
43        run_tests_parameters: ['']
44        test_function_jit: [true]
45        zts: [true, false]
46        include: ${{ fromJson(needs.GENERATE_MATRIX.outputs.matrix-include) }}
47    name: "${{ matrix.branch.name }}_LINUX_X64${{ matrix.name }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
48    runs-on: ubuntu-20.04
49    steps:
50      - name: git checkout
51        uses: actions/checkout@v3
52        with:
53          ref: ${{ matrix.branch.ref }}
54      - name: Create MSSQL container
55        uses: ./.github/actions/setup-mssql
56      - name: Create Oracle container
57        uses: ./.github/actions/setup-oracle
58      - name: apt
59        uses: ./.github/actions/apt-x64
60      - name: ./configure
61        uses: ./.github/actions/configure-x64
62        with:
63          configurationParameters: >-
64            ${{ matrix.configuration_parameters }}
65            --${{ matrix.debug && 'enable' || 'disable' }}-debug
66            --${{ matrix.zts && 'enable' || 'disable' }}-zts
67      - name: make
68        run: make -j$(/usr/bin/nproc) >/dev/null
69      - name: make install
70        uses: ./.github/actions/install-linux
71      - name: Setup
72        uses: ./.github/actions/setup-x64
73      - name: Test
74        uses: ./.github/actions/test-linux
75        with:
76          runTestsParameters: >-
77            ${{ matrix.run_tests_parameters }}
78      - name: Test Tracing JIT
79        uses: ./.github/actions/test-linux
80        with:
81          runTestsParameters: >-
82            ${{ matrix.run_tests_parameters }}
83            -d zend_extension=opcache.so
84            -d opcache.enable_cli=1
85            -d opcache.jit_buffer_size=16M
86      - name: Test OpCache
87        uses: ./.github/actions/test-linux
88        with:
89          runTestsParameters: >-
90            ${{ matrix.run_tests_parameters }}
91            -d zend_extension=opcache.so
92            -d opcache.enable_cli=1
93      - name: Test Function JIT
94        # ASAN frequently timeouts. Each test run takes ~90 minutes, we can
95        # avoid running into the 6 hour timeout by skipping the function JIT.
96        if: matrix.test_function_jit
97        uses: ./.github/actions/test-linux
98        with:
99          runTestsParameters: >-
100            ${{ matrix.run_tests_parameters }}
101            -d zend_extension=opcache.so
102            -d opcache.enable_cli=1
103            -d opcache.jit_buffer_size=16M
104            -d opcache.jit=1205
105      - name: Verify generated files are up to date
106        uses: ./.github/actions/verify-generated-files
107  LINUX_X32:
108    needs: GENERATE_MATRIX
109    if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
110    strategy:
111      fail-fast: false
112      matrix:
113        branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
114        debug: [true, false]
115        zts: [true, false]
116    name: "${{ matrix.branch.name }}_LINUX_X32_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
117    runs-on: ubuntu-latest
118    container:
119      image: ubuntu:20.04
120    env:
121      MYSQL_TEST_HOST: mysql
122      PDO_MYSQL_TEST_DSN: mysql:host=mysql;dbname=test
123      PDO_MYSQL_TEST_HOST: mysql
124    services:
125      mysql:
126        image: mysql:8
127        ports:
128          - 3306:3306
129        env:
130          MYSQL_DATABASE: test
131          MYSQL_ROOT_PASSWORD: root
132    steps:
133      - name: git checkout
134        uses: actions/checkout@v3
135        with:
136          ref: ${{ matrix.branch.ref }}
137      - name: apt
138        uses: ./.github/actions/apt-x32
139      - name: ./configure
140        uses: ./.github/actions/configure-x32
141        with:
142          configurationParameters: >-
143            --${{ matrix.debug && 'enable' || 'disable' }}-debug
144            --${{ matrix.zts && 'enable' || 'disable' }}-zts
145      - name: make
146        run: make -j$(/usr/bin/nproc) >/dev/null
147      - name: make install
148        uses: ./.github/actions/install-linux-x32
149      - name: Test
150        uses: ./.github/actions/test-linux
151        with:
152          runTestsParameters: >-
153            ${{ matrix.run_tests_parameters }}
154      - name: Test Tracing JIT
155        uses: ./.github/actions/test-linux
156        with:
157          runTestsParameters: >-
158            ${{ matrix.run_tests_parameters }}
159            -d zend_extension=opcache.so
160            -d opcache.enable_cli=1
161            -d opcache.jit_buffer_size=16M
162      - name: Test OpCache
163        uses: ./.github/actions/test-linux
164        with:
165          runTestsParameters: >-
166            ${{ matrix.run_tests_parameters }}
167            -d zend_extension=opcache.so
168            -d opcache.enable_cli=1
169      - name: Test Function JIT
170        uses: ./.github/actions/test-linux
171        with:
172          runTestsParameters: >-
173            ${{ matrix.run_tests_parameters }}
174            -d zend_extension=opcache.so
175            -d opcache.enable_cli=1
176            -d opcache.jit_buffer_size=16M
177            -d opcache.jit=1205
178  MACOS:
179    needs: GENERATE_MATRIX
180    if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
181    strategy:
182      fail-fast: false
183      matrix:
184        branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
185        debug: [true, false]
186        zts: [true, false]
187    name: "${{ matrix.branch.name }}_MACOS_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}"
188    runs-on: macos-11
189    steps:
190      - name: git checkout
191        uses: actions/checkout@v3
192        with:
193          ref: ${{ matrix.branch.ref }}
194      - name: brew
195        uses: ./.github/actions/brew
196      - name: ./configure
197        uses: ./.github/actions/configure-macos
198        with:
199          configurationParameters: >-
200            --${{ matrix.debug && 'enable' || 'disable' }}-debug
201            --${{ matrix.zts && 'enable' || 'disable' }}-zts
202      - name: make
203        run: |-
204          export PATH="/usr/local/opt/bison/bin:$PATH"
205          make -j$(sysctl -n hw.logicalcpu) >/dev/null
206      - name: make install
207        run: sudo make install
208      - name: Test
209        uses: ./.github/actions/test-macos
210      - name: Test Tracing JIT
211        uses: ./.github/actions/test-macos
212        with:
213          runTestsParameters: >-
214            -d zend_extension=opcache.so
215            -d opcache.enable_cli=1
216            -d opcache.protect_memory=1
217            -d opcache.jit_buffer_size=16M
218      - name: Test OpCache
219        uses: ./.github/actions/test-macos
220        with:
221          runTestsParameters: >-
222            -d zend_extension=opcache.so
223            -d opcache.enable_cli=1
224            -d opcache.protect_memory=1
225      - name: Test Function JIT
226        uses: ./.github/actions/test-macos
227        with:
228          runTestsParameters: >-
229            -d zend_extension=opcache.so
230            -d opcache.enable_cli=1
231            -d opcache.protect_memory=1
232            -d opcache.jit_buffer_size=16M
233            -d opcache.jit=1205
234      - name: Verify generated files are up to date
235        uses: ./.github/actions/verify-generated-files
236  COVERAGE_DEBUG_NTS:
237    if: github.repository_owner == 'php' || github.event_name == 'workflow_dispatch'
238    runs-on: ubuntu-20.04
239    steps:
240      - name: git checkout
241        uses: actions/checkout@v3
242      - name: Create MSSQL container
243        uses: ./.github/actions/setup-mssql
244      - name: Create Oracle container
245        uses: ./.github/actions/setup-oracle
246      - name: apt
247        uses: ./.github/actions/apt-x64
248      - name: Install gcovr
249        run: sudo -H pip install gcovr
250      - name: ./configure
251        uses: ./.github/actions/configure-x64
252        with:
253          configurationParameters: --enable-debug --disable-zts --enable-gcov
254      - name: make
255        run: make -j$(/usr/bin/nproc) >/dev/null
256      - name: make install
257        uses: ./.github/actions/install-linux
258      - name: Setup
259        uses: ./.github/actions/setup-x64
260      # We only test with OpCache, the difference in coverage is negligible
261      - name: Test OpCache
262        uses: ./.github/actions/test-linux
263        with:
264          runTestsParameters: >-
265            -d zend_extension=opcache.so
266            -d opcache.enable_cli=1
267      - name: Upload Test Coverage to Codecov.io
268        if: always()
269        run: bash <(curl -s https://codecov.io/bash)
270  COMMUNITY:
271    needs: GENERATE_MATRIX
272    if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
273    strategy:
274      fail-fast: false
275      matrix:
276        branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
277    name: "${{ matrix.branch.name }}_COMMUNITY"
278    runs-on: ubuntu-20.04
279    env:
280      UBSAN_OPTIONS: print_stacktrace=1
281      USE_ZEND_ALLOC: 0
282      USE_TRACKED_ALLOC: 1
283    steps:
284      - name: git checkout
285        uses: actions/checkout@v3
286        with:
287          ref: ${{ matrix.branch.ref }}
288      - name: apt
289        uses: ./.github/actions/apt-x64
290      - name: ./configure
291        uses: ./.github/actions/configure-x64
292        with:
293          configurationParameters: >-
294            --enable-debug
295            --enable-zts
296            CFLAGS='-fsanitize=undefined,address -fno-sanitize-recover -DZEND_TRACK_ARENA_ALLOC'
297            LDFLAGS='-fsanitize=undefined,address'
298      - name: make
299        run: make -j$(/usr/bin/nproc) >/dev/null
300      - name: make install
301        uses: ./.github/actions/install-linux
302      - name: Setup
303        run: |
304          sudo service mysql start
305          mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS test"
306          mysql -uroot -proot -e "SET GLOBAL local_infile = true"
307      - name: Enable Opcache and JIT
308        run: |
309          echo zend_extension=opcache.so > /etc/php.d/opcache.ini
310          echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini
311          echo opcache.protect_memory=1 >> /etc/php.d/opcache.ini
312          echo opcache.jit_buffer_size=1G >> /etc/php.d/opcache.ini
313      - name: Test Laravel
314        if: matrix.branch.ref != 'PHP-8.0'
315        run: |
316          git clone https://github.com/laravel/framework.git --branch=master --depth=1
317          cd framework
318          git rev-parse HEAD
319          php /usr/bin/composer install --no-progress --ignore-platform-reqs
320          # Hack to disable a test that hangs
321          php -r '$c = file_get_contents("tests/Filesystem/FilesystemTest.php"); $c = str_replace("*/\n    public function testSharedGet()", "* @group skip\n     */\n    public function testSharedGet()", $c); file_put_contents("tests/Filesystem/FilesystemTest.php", $c);'
322          export ASAN_OPTIONS=exitcode=139
323          php vendor/bin/phpunit --exclude-group skip || EXIT_CODE=$?
324          if [ $EXIT_CODE -gt 128 ]; then
325            exit 1
326          fi
327      - name: Test Symfony
328        if: matrix.branch.ref != 'PHP-8.0'
329        run: |
330          git clone https://github.com/symfony/symfony.git --depth=1
331          cd symfony
332          git rev-parse HEAD
333          php /usr/bin/composer install --no-progress --ignore-platform-reqs
334          php ./phpunit install
335          # Test causes a heap-buffer-overflow but I cannot reproduce it locally...
336          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);'
337          # Buggy FFI test in Symfony, see https://github.com/symfony/symfony/issues/47668
338          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);'
339          export ASAN_OPTIONS=exitcode=139
340          export SYMFONY_DEPRECATIONS_HELPER=max[total]=999
341          X=0
342          for component in $(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h\n'); do
343            php ./phpunit $component --exclude-group tty,benchmark,intl-data,transient --exclude-group skip || EXIT_CODE=$?
344            if [ $EXIT_CODE -gt 128 ]; then
345              X=1;
346            fi
347          done
348          exit $X
349      - name: Test PHPUnit
350        if: always()
351        run: |
352          git clone https://github.com/sebastianbergmann/phpunit.git --branch=main --depth=1
353          cd phpunit
354          git rev-parse HEAD
355          export ASAN_OPTIONS=exitcode=139
356          php /usr/bin/composer install --no-progress --ignore-platform-reqs
357          php ./phpunit || EXIT_CODE=$?
358          if [ $EXIT_CODE -gt 128 ]; then
359            exit 1
360          fi
361      - name: 'Symfony Preloading'
362        if: matrix.branch.ref != 'PHP-8.0'
363        run: |
364          php /usr/bin/composer create-project symfony/symfony-demo symfony_demo --no-progress --ignore-platform-reqs
365          cd symfony_demo
366          git rev-parse HEAD
367          sed -i 's/PHP_SAPI/"cli-server"/g' var/cache/dev/App_KernelDevDebugContainer.preload.php
368          php -d opcache.preload=var/cache/dev/App_KernelDevDebugContainer.preload.php public/index.php
369      - name: Test Wordpress
370        if: always()
371        run: |
372          git clone https://github.com/WordPress/wordpress-develop.git wordpress --depth=1
373          cd wordpress
374          git rev-parse HEAD
375          export ASAN_OPTIONS=exitcode=139
376          php /usr/bin/composer install --no-progress --ignore-platform-reqs
377          cp wp-tests-config-sample.php wp-tests-config.php
378          sed -i 's/youremptytestdbnamehere/test/g' wp-tests-config.php
379          sed -i 's/yourusernamehere/root/g' wp-tests-config.php
380          sed -i 's/yourpasswordhere/root/g' wp-tests-config.php
381          php vendor/bin/phpunit || EXIT_CODE=$?
382          if [ $EXIT_CODE -gt 128 ]; then
383            exit 1
384          fi
385  OPCACHE_VARIATION:
386    needs: GENERATE_MATRIX
387    if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
388    strategy:
389      fail-fast: false
390      matrix:
391        branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
392    name: "${{ matrix.branch.name }}_OPCACHE_VARIATION"
393    runs-on: ubuntu-20.04
394    steps:
395      - name: git checkout
396        uses: actions/checkout@v3
397        with:
398          ref: ${{ matrix.branch.ref }}
399      - name: Create MSSQL container
400        uses: ./.github/actions/setup-mssql
401      - name: Create Oracle container
402        uses: ./.github/actions/setup-oracle
403      - name: apt
404        uses: ./.github/actions/apt-x64
405      - name: ./configure
406        uses: ./.github/actions/configure-x64
407        with:
408          configurationParameters: >-
409            --enable-debug --disable-zts
410      - name: make
411        run: make -j$(/usr/bin/nproc) >/dev/null
412      - name: make install
413        uses: ./.github/actions/install-linux
414      - name: Setup
415        uses: ./.github/actions/setup-x64
416      - name: Test File Cache (prime shm)
417        uses: ./.github/actions/test-linux
418        with:
419          runTestsParameters: >-
420            -d zend_extension=opcache.so
421            -d opcache.enable_cli=1
422            --file-cache-prime
423      - name: Test File Cache (prime shm, use shm)
424        uses: ./.github/actions/test-linux
425        with:
426          runTestsParameters: >-
427            -d zend_extension=opcache.so
428            -d opcache.enable_cli=1
429            --file-cache-use
430      - name: Test File Cache (prime shm, use file)
431        uses: ./.github/actions/test-linux
432        with:
433          runTestsParameters: >-
434            -d zend_extension=opcache.so
435            -d opcache.enable_cli=1
436            --file-cache-use
437            -d opcache.file_cache_only=1
438      - name: Test File Cache Only (prime)
439        uses: ./.github/actions/test-linux
440        with:
441          runTestsParameters: >-
442            -d zend_extension=opcache.so
443            -d opcache.enable_cli=1
444            --file-cache-prime
445            -d opcache.file_cache_only=1
446      - name: Test File Cache Only (use)
447        uses: ./.github/actions/test-linux
448        with:
449          runTestsParameters: >-
450            -d zend_extension=opcache.so
451            -d opcache.enable_cli=1
452            --file-cache-use
453            -d opcache.file_cache_only=1
454      - name: Verify generated files are up to date
455        uses: ./.github/actions/verify-generated-files
456  MSAN:
457    needs: GENERATE_MATRIX
458    if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }}
459    strategy:
460      fail-fast: false
461      matrix:
462        branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }}
463    name: "${{ matrix.branch.name }}_MSAN"
464    runs-on: ubuntu-22.04
465    steps:
466      - name: git checkout
467        uses: actions/checkout@v3
468        with:
469          ref: ${{ matrix.branch.ref }}
470      - name: apt
471        uses: ./.github/actions/apt-x64
472      - name: ./configure
473        run: |
474          export CC=clang
475          export CXX=clang++
476          export CFLAGS="-DZEND_TRACK_ARENA_ALLOC"
477          ./buildconf --force
478          # msan requires all used libraries to be instrumented,
479          # so we should avoiding linking against anything but libc here
480          ./configure \
481            --enable-debug \
482            --enable-zts \
483            --enable-option-checking=fatal \
484            --prefix=/usr \
485            --without-sqlite3 \
486            --without-pdo-sqlite \
487            --without-libxml \
488            --disable-dom \
489            --disable-simplexml \
490            --disable-xml \
491            --disable-xmlreader \
492            --disable-xmlwriter \
493            --without-pcre-jit \
494            --disable-opcache-jit \
495            --enable-phpdbg \
496            --enable-fpm \
497            --with-pdo-mysql=mysqlnd \
498            --with-mysqli=mysqlnd \
499            --disable-mysqlnd-compression-support \
500            --without-pear \
501            --enable-exif \
502            --enable-sysvsem \
503            --enable-sysvshm \
504            --enable-shmop \
505            --enable-pcntl \
506            --enable-mbstring \
507            --disable-mbregex \
508            --enable-sockets \
509            --enable-bcmath \
510            --enable-calendar \
511            --enable-ftp \
512            --enable-zend-test \
513            --enable-werror \
514            --enable-memory-sanitizer \
515            --with-config-file-path=/etc \
516            --with-config-file-scan-dir=/etc/php.d
517      - name: make
518        run: make -j$(/usr/bin/nproc) >/dev/null
519      - name: make install
520        run: |
521          sudo make install
522          sudo mkdir     /etc/php.d
523          sudo chmod 777 /etc/php.d
524          echo mysqli.default_socket=/var/run/mysqld/mysqld.sock    > /etc/php.d/mysqli.ini
525          echo pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/pdo_mysql.ini
526      - name: Setup
527        run: |
528          set -x
529          sudo service mysql start
530          mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS test"
531          # Ensure local_infile tests can run.
532          mysql -uroot -proot -e "SET GLOBAL local_infile = true"
533          sudo locale-gen de_DE
534      - name: Test
535        uses: ./.github/actions/test-linux
536        with:
537          runTestsParameters: >-
538            --msan
539      - name: Test Opcache
540        uses: ./.github/actions/test-linux
541        with:
542          runTestsParameters: >-
543            --msan
544            -d zend_extension=opcache.so
545            -d opcache.enable_cli=1
546      - name: Verify generated files are up to date
547        uses: ./.github/actions/verify-generated-files
548