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