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