xref: /php-src/.github/workflows/push.yml (revision 912b13a7)
1name: Push
2on:
3  push:
4    paths-ignore:
5      - docs/**
6      - NEWS
7      - UPGRADING
8      - UPGRADING.INTERNALS
9      - '**/README.*'
10      - CONTRIBUTING.md
11      - CODING_STANDARDS.md
12      - .cirrus.yml
13      - .circleci/**
14    branches:
15      - PHP-8.1
16      - PHP-8.2
17      - PHP-8.3
18      - PHP-8.4
19      - master
20  pull_request:
21    paths-ignore:
22      - docs/**
23      - NEWS
24      - UPGRADING
25      - UPGRADING.INTERNALS
26      - '**/README.*'
27      - CONTRIBUTING.md
28      - CODING_STANDARDS.md
29      - .cirrus.yml
30      - .circleci/**
31    branches:
32      - '**'
33  workflow_dispatch: ~
34permissions:
35  contents: read
36concurrency:
37  group: ${{ github.workflow }}-${{ github.event.pull_request.url || github.run_id }}
38  cancel-in-progress: true
39env:
40  CC: ccache gcc
41  CXX: ccache g++
42jobs:
43  LINUX_X64:
44    if: github.repository == 'php/php-src' || github.event_name == 'pull_request'
45    services:
46      mysql:
47        image: mysql:8.3
48        ports:
49          - 3306:3306
50        env:
51          MYSQL_DATABASE: test
52          MYSQL_ROOT_PASSWORD: root
53      postgres:
54        image: postgres
55        ports:
56          - 5432:5432
57        env:
58          POSTGRES_USER: postgres
59          POSTGRES_PASSWORD: postgres
60          POSTGRES_DB: test
61      firebird:
62        image: jacobalberty/firebird
63        ports:
64          - 3050:3050
65        env:
66          ISC_PASSWORD: test
67          FIREBIRD_DATABASE: test.fdb
68          FIREBIRD_USER: test
69          FIREBIRD_PASSWORD: test
70    strategy:
71      fail-fast: false
72      matrix:
73        include:
74          - debug: false
75            zts: false
76            asan: false
77          - debug: true
78            zts: true
79            asan: true
80    name: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}"
81    runs-on: ubuntu-24.04
82    timeout-minutes: 50
83    steps:
84      - name: git checkout
85        uses: actions/checkout@v4
86      - name: apt
87        uses: ./.github/actions/apt-x64
88      - name: System info
89        run: |
90          echo "::group::Show host CPU info"
91          lscpu
92          echo "::endgroup::"
93          echo "::group::Show installed package versions"
94          dpkg -l
95          echo "::endgroup::"
96      - name: Create MSSQL container
97        if: ${{ !matrix.asan }}
98        uses: ./.github/actions/setup-mssql
99      - name: Setup Caddy server
100        uses: ./.github/actions/setup-caddy
101      - name: ccache
102        uses: hendrikmuhs/ccache-action@v1.2
103        with:
104          # This duplicates the "job.name" expression above because
105          # GitHub has no way to query the job name (github.job is the
106          # job id, not the job name)
107          key: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}-${{hashFiles('main/php_version.h')}}"
108          append-timestamp: false
109          save: ${{ github.event_name != 'pull_request' }}
110      - name: ./configure
111        uses: ./.github/actions/configure-x64
112        with:
113          configurationParameters: >-
114            --${{ matrix.debug && 'enable' || 'disable' }}-debug
115            --${{ matrix.zts && 'enable' || 'disable' }}-zts
116            ${{ matrix.asan && 'CFLAGS="-fsanitize=undefined,address -fno-sanitize=function -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=undefined,address -fno-sanitize=function" CC=clang CXX=clang++' || '' }}
117          skipSlow: ${{ matrix.asan }}
118      - name: make
119        run: make -j$(/usr/bin/nproc) >/dev/null
120      - name: make install
121        uses: ./.github/actions/install-linux
122      - name: Setup
123        if: ${{ !matrix.asan }}
124        uses: ./.github/actions/setup-x64
125      - name: Test
126        if: matrix.asan == false
127        uses: ./.github/actions/test-linux
128      - name: Test Tracing JIT
129        uses: ./.github/actions/test-linux
130        with:
131          jitType: tracing
132          runTestsParameters: >-
133            -d zend_extension=opcache.so
134            -d opcache.enable_cli=1
135            ${{ matrix.asan && '--asan -x' || '' }}
136      - name: Verify generated files are up to date
137        if: ${{ !matrix.asan }}
138        uses: ./.github/actions/verify-generated-files
139  LINUX_X32:
140    if: github.repository == 'php/php-src' || github.event_name == 'pull_request'
141    name: LINUX_X32_DEBUG_ZTS
142    runs-on: ubuntu-latest
143    timeout-minutes: 50
144    container:
145      image: ubuntu:24.04
146    env:
147      MYSQL_TEST_HOST: mysql
148      PDO_MYSQL_TEST_DSN: mysql:host=mysql;dbname=test
149      PDO_MYSQL_TEST_HOST: mysql
150      PDO_FIREBIRD_TEST_DSN: firebird:dbname=firebird:test.fdb
151    services:
152      mysql:
153        image: mysql:8.3
154        ports:
155          - 3306:3306
156        env:
157          MYSQL_DATABASE: test
158          MYSQL_ROOT_PASSWORD: root
159      firebird:
160        image: jacobalberty/firebird
161        ports:
162          - 3050:3050
163        env:
164          ISC_PASSWORD: test
165          FIREBIRD_DATABASE: test.fdb
166          FIREBIRD_USER: test
167          FIREBIRD_PASSWORD: test
168    steps:
169      - name: git checkout
170        uses: actions/checkout@v4
171      - name: apt
172        uses: ./.github/actions/apt-x32
173      - name: ccache
174        uses: hendrikmuhs/ccache-action@v1.2
175        with:
176          key: "${{github.job}}-${{hashFiles('main/php_version.h')}}"
177          append-timestamp: false
178      - name: ./configure
179        uses: ./.github/actions/configure-x32
180        with:
181          configurationParameters: >-
182            --enable-debug
183            --enable-zts
184      - name: make
185        run: make -j$(/usr/bin/nproc) >/dev/null
186      - name: make install
187        uses: ./.github/actions/install-linux-x32
188      - name: Test Tracing JIT
189        uses: ./.github/actions/test-linux
190        with:
191          jitType: tracing
192          runTestsParameters: >-
193            -d zend_extension=opcache.so
194            -d opcache.enable_cli=1
195  MACOS_DEBUG_NTS:
196    if: github.repository == 'php/php-src' || github.event_name == 'pull_request'
197    strategy:
198      fail-fast: false
199      matrix:
200        include:
201          - os: 13
202            arch: X64
203          - os: 14
204            arch: ARM64
205    name: MACOS_${{ matrix.arch }}_DEBUG_NTS
206    runs-on: macos-${{ matrix.os }}
207    timeout-minutes: 50
208    steps:
209      - name: git checkout
210        uses: actions/checkout@v4
211      - name: brew
212        uses: ./.github/actions/brew
213      - name: ccache
214        uses: hendrikmuhs/ccache-action@v1.2
215        with:
216          key: "${{github.job}}-${{matrix.os}}-${{hashFiles('main/php_version.h')}}"
217          append-timestamp: false
218          save: ${{ github.event_name != 'pull_request' }}
219      - name: ./configure
220        uses: ./.github/actions/configure-macos
221        with:
222          configurationParameters: --enable-debug --disable-zts
223      - name: make
224        run: |-
225          export PATH="$(brew --prefix)/opt/bison/bin:$PATH"
226          make -j$(sysctl -n hw.logicalcpu) >/dev/null
227      - name: make install
228        run: sudo make install
229      - name: Test Tracing JIT
230        uses: ./.github/actions/test-macos
231        with:
232          jitType: tracing
233          runTestsParameters: >-
234            -d zend_extension=opcache.so
235            -d opcache.enable_cli=1
236      - name: Verify generated files are up to date
237        uses: ./.github/actions/verify-generated-files
238  WINDOWS:
239    if: github.repository == 'php/php-src' || github.event_name == 'pull_request'
240    name: WINDOWS_X64_ZTS
241    runs-on: windows-2022
242    timeout-minutes: 50
243    env:
244      PHP_BUILD_CACHE_BASE_DIR: C:\build-cache
245      PHP_BUILD_OBJ_DIR: C:\obj
246      PHP_BUILD_CACHE_SDK_DIR: C:\build-cache\sdk
247      PHP_BUILD_SDK_BRANCH: php-sdk-2.3.0
248      PHP_BUILD_CRT: vs17
249      PLATFORM: x64
250      THREAD_SAFE: "1"
251      INTRINSICS: AVX2
252      PARALLEL: -j2
253      OPCACHE: "1"
254    steps:
255      - name: git config
256        run: git config --global core.autocrlf false && git config --global core.eol lf
257      - name: git checkout
258        uses: actions/checkout@v4
259      - name: Setup
260        uses: ./.github/actions/setup-windows
261      - name: Build
262        run: .github/scripts/windows/build.bat
263      - name: Test
264        run: .github/scripts/windows/test.bat
265  BENCHMARKING:
266    name: BENCHMARKING
267    if: github.repository == 'php/php-src' || github.event_name == 'pull_request'
268    runs-on: ubuntu-24.04
269    timeout-minutes: 50
270    steps:
271      - name: git checkout
272        uses: actions/checkout@v4
273        with:
274          fetch-depth: 0
275      # ASLR can cause a lot of noise due to missed sse opportunities for memcpy
276      # and other operations, so we disable it during benchmarking.
277      - name: Disable ASLR
278        run: echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
279      - name: apt
280        run: |
281          set -x
282          sudo apt-get update
283          sudo apt-get install \
284            bison \
285            libgmp-dev \
286            libonig-dev \
287            libsqlite3-dev \
288            openssl \
289            re2c \
290            valgrind
291      - name: ccache
292        uses: hendrikmuhs/ccache-action@v1.2
293        with:
294          key: "${{github.job}}-${{hashFiles('main/php_version.h')}}"
295          append-timestamp: false
296          save: ${{ github.event_name != 'pull_request' }}
297      - name: ./configure
298        run: |
299          set -x
300          ./buildconf --force
301          ./configure \
302            --disable-debug \
303            --enable-mbstring \
304            --enable-opcache \
305            --enable-option-checking=fatal \
306            --enable-sockets \
307            --enable-werror \
308            --prefix=/usr \
309            --with-config-file-scan-dir=/etc/php.d \
310            --with-gmp \
311            --with-mysqli=mysqlnd \
312            --with-openssl \
313            --with-pdo-sqlite \
314            --with-valgrind
315      - name: make
316        run: make -j$(/usr/bin/nproc) >/dev/null
317      - name: make install
318        run: |
319          set -x
320          sudo make install
321          sudo mkdir -p /etc/php.d
322          sudo chmod 777 /etc/php.d
323          echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini
324          echo zend_extension=opcache.so >> /etc/php.d/opcache.ini
325          echo opcache.enable=1 >> /etc/php.d/opcache.ini
326          echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini
327      - name: Setup
328        run: |
329          git config --global user.name "Benchmark"
330          git config --global user.email "benchmark@php.net"
331          sudo service mysql start
332          mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS wordpress"
333          mysql -uroot -proot -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpress'; FLUSH PRIVILEGES;"
334          mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'localhost' WITH GRANT OPTION;"
335      - name: git checkout benchmarking-data
336        uses: actions/checkout@v4
337        with:
338          repository: php/benchmarking-data
339          ssh-key: ${{ secrets.BENCHMARKING_DATA_DEPLOY_KEY }}
340          path: benchmark/repos/data
341      - name: Benchmark
342        run: php benchmark/benchmark.php true
343      - name: Store result
344        if: github.event_name == 'push'
345        run: |
346          set -x
347          cd benchmark/repos/data
348          git pull --autostash
349          if [ -e ".git/MERGE_HEAD" ]; then
350            echo "Merging, can't proceed"
351            exit 1
352          fi
353          git add .
354          if git diff --cached --quiet; then
355            exit 0
356          fi
357          git commit -m "Add result for ${{ github.repository }}@${{ github.sha }}"
358          git push
359      - name: Show diff
360        if: github.event_name == 'pull_request'
361        run: |-
362          set -x
363          php benchmark/generate_diff.php \
364            ${{ github.sha }} \
365            $(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) \
366            > $GITHUB_STEP_SUMMARY
367      - uses: actions/upload-artifact@v4
368        with:
369          name: profiles
370          path: ${{ github.workspace }}/benchmark/profiles
371          retention-days: 30
372  FREEBSD:
373    name: FREEBSD
374    runs-on: ubuntu-latest
375    steps:
376      - name: git checkout
377        uses: actions/checkout@v4
378      - name: FreeBSD
379        uses: ./.github/actions/freebsd
380