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