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