xref: /php-src/.github/workflows/push.yml (revision aca88baf)
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    services:
151      mysql:
152        image: mysql:8.3
153        ports:
154          - 3306:3306
155        env:
156          MYSQL_DATABASE: test
157          MYSQL_ROOT_PASSWORD: root
158    steps:
159      - name: git checkout
160        uses: actions/checkout@v4
161      - name: apt
162        uses: ./.github/actions/apt-x32
163      - name: ccache
164        uses: hendrikmuhs/ccache-action@v1.2
165        with:
166          key: "${{github.job}}-${{hashFiles('main/php_version.h')}}"
167          append-timestamp: false
168      - name: ./configure
169        uses: ./.github/actions/configure-x32
170        with:
171          configurationParameters: >-
172            --enable-debug
173            --enable-zts
174      - name: make
175        run: make -j$(/usr/bin/nproc) >/dev/null
176      - name: make install
177        uses: ./.github/actions/install-linux-x32
178      - name: Test Tracing JIT
179        uses: ./.github/actions/test-linux
180        with:
181          jitType: tracing
182          runTestsParameters: >-
183            -d zend_extension=opcache.so
184            -d opcache.enable_cli=1
185  MACOS_DEBUG_NTS:
186    if: github.repository == 'php/php-src' || github.event_name == 'pull_request'
187    strategy:
188      fail-fast: false
189      matrix:
190        include:
191          - os: 13
192            arch: X64
193          - os: 14
194            arch: ARM64
195    name: MACOS_${{ matrix.arch }}_DEBUG_NTS
196    runs-on: macos-${{ matrix.os }}
197    timeout-minutes: 50
198    steps:
199      - name: git checkout
200        uses: actions/checkout@v4
201      - name: brew
202        uses: ./.github/actions/brew
203      - name: ccache
204        uses: hendrikmuhs/ccache-action@v1.2
205        with:
206          key: "${{github.job}}-${{matrix.os}}-${{hashFiles('main/php_version.h')}}"
207          append-timestamp: false
208          save: ${{ github.event_name != 'pull_request' }}
209      - name: ./configure
210        uses: ./.github/actions/configure-macos
211        with:
212          configurationParameters: --enable-debug --disable-zts
213      - name: make
214        run: |-
215          export PATH="$(brew --prefix)/opt/bison/bin:$PATH"
216          make -j$(sysctl -n hw.logicalcpu) >/dev/null
217      - name: make install
218        run: sudo make install
219      - name: Test Tracing JIT
220        uses: ./.github/actions/test-macos
221        with:
222          jitType: tracing
223          runTestsParameters: >-
224            -d zend_extension=opcache.so
225            -d opcache.enable_cli=1
226      - name: Verify generated files are up to date
227        uses: ./.github/actions/verify-generated-files
228  WINDOWS:
229    if: github.repository == 'php/php-src' || github.event_name == 'pull_request'
230    name: WINDOWS_X64_ZTS
231    runs-on: windows-2022
232    timeout-minutes: 50
233    env:
234      PHP_BUILD_CACHE_BASE_DIR: C:\build-cache
235      PHP_BUILD_OBJ_DIR: C:\obj
236      PHP_BUILD_CACHE_SDK_DIR: C:\build-cache\sdk
237      PHP_BUILD_SDK_BRANCH: php-sdk-2.3.0
238      PHP_BUILD_CRT: vs17
239      PLATFORM: x64
240      THREAD_SAFE: "1"
241      INTRINSICS: AVX2
242      PARALLEL: -j2
243      OPCACHE: "1"
244    steps:
245      - name: git config
246        run: git config --global core.autocrlf false && git config --global core.eol lf
247      - name: git checkout
248        uses: actions/checkout@v4
249      - name: Setup
250        uses: ./.github/actions/setup-windows
251      - name: Build
252        run: .github/scripts/windows/build.bat
253      - name: Test
254        run: .github/scripts/windows/test.bat
255  BENCHMARKING:
256    name: BENCHMARKING
257    if: github.repository == 'php/php-src' || github.event_name == 'pull_request'
258    runs-on: ubuntu-24.04
259    timeout-minutes: 50
260    steps:
261      - name: git checkout
262        uses: actions/checkout@v4
263        with:
264          fetch-depth: 0
265      # ASLR can cause a lot of noise due to missed sse opportunities for memcpy
266      # and other operations, so we disable it during benchmarking.
267      - name: Disable ASLR
268        run: echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
269      - name: apt
270        run: |
271          set -x
272          sudo apt-get update
273          sudo apt-get install \
274            bison \
275            libgmp-dev \
276            libonig-dev \
277            libsqlite3-dev \
278            openssl \
279            re2c \
280            valgrind
281      - name: ccache
282        uses: hendrikmuhs/ccache-action@v1.2
283        with:
284          key: "${{github.job}}-${{hashFiles('main/php_version.h')}}"
285          append-timestamp: false
286          save: ${{ github.event_name != 'pull_request' }}
287      - name: ./configure
288        run: |
289          set -x
290          ./buildconf --force
291          ./configure \
292            --disable-debug \
293            --enable-mbstring \
294            --enable-opcache \
295            --enable-option-checking=fatal \
296            --enable-sockets \
297            --enable-werror \
298            --prefix=/usr \
299            --with-config-file-scan-dir=/etc/php.d \
300            --with-gmp \
301            --with-mysqli=mysqlnd \
302            --with-openssl \
303            --with-pdo-sqlite \
304            --with-valgrind
305      - name: make
306        run: make -j$(/usr/bin/nproc) >/dev/null
307      - name: make install
308        run: |
309          set -x
310          sudo make install
311          sudo mkdir -p /etc/php.d
312          sudo chmod 777 /etc/php.d
313          echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini
314          echo zend_extension=opcache.so >> /etc/php.d/opcache.ini
315          echo opcache.enable=1 >> /etc/php.d/opcache.ini
316          echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini
317      - name: Setup
318        run: |
319          git config --global user.name "Benchmark"
320          git config --global user.email "benchmark@php.net"
321          sudo service mysql start
322          mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS wordpress"
323          mysql -uroot -proot -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpress'; FLUSH PRIVILEGES;"
324          mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'localhost' WITH GRANT OPTION;"
325      - name: git checkout benchmarking-data
326        uses: actions/checkout@v4
327        with:
328          repository: php/benchmarking-data
329          ssh-key: ${{ secrets.BENCHMARKING_DATA_DEPLOY_KEY }}
330          path: benchmark/repos/data
331      - name: Benchmark
332        run: php benchmark/benchmark.php true
333      - name: Store result
334        if: github.event_name == 'push'
335        run: |
336          set -x
337          cd benchmark/repos/data
338          git pull --autostash
339          if [ -e ".git/MERGE_HEAD" ]; then
340            echo "Merging, can't proceed"
341            exit 1
342          fi
343          git add .
344          if git diff --cached --quiet; then
345            exit 0
346          fi
347          git commit -m "Add result for ${{ github.repository }}@${{ github.sha }}"
348          git push
349      - name: Show diff
350        if: github.event_name == 'pull_request'
351        run: |-
352          set -x
353          php benchmark/generate_diff.php \
354            ${{ github.sha }} \
355            $(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) \
356            > $GITHUB_STEP_SUMMARY
357      - uses: actions/upload-artifact@v4
358        with:
359          name: profiles
360          path: ${{ github.workspace }}/benchmark/profiles
361          retention-days: 30
362  FREEBSD:
363    name: FREEBSD
364    runs-on: ubuntu-latest
365    steps:
366      - name: git checkout
367        uses: actions/checkout@v4
368      - name: FreeBSD
369        uses: ./.github/actions/freebsd
370