xref: /php-src/.github/workflows/push.yml (revision febbbfac)
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      - name: ./configure
120        uses: ./.github/actions/configure-x64
121        with:
122          configurationParameters: >-
123            --${{ matrix.debug && 'enable' || 'disable' }}-debug
124            --${{ matrix.zts && 'enable' || 'disable' }}-zts
125            ${{ matrix.asan && 'CFLAGS="-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=undefined,address" CC=clang-16 CXX=clang++-16' || '' }}
126          skipSlow: ${{ matrix.asan }}
127      - name: make
128        run: make -j$(/usr/bin/nproc) >/dev/null
129      - name: make install
130        uses: ./.github/actions/install-linux
131      - name: Setup
132        if: ${{ !matrix.asan }}
133        uses: ./.github/actions/setup-x64
134      - name: Test
135        if: matrix.asan == false
136        uses: ./.github/actions/test-linux
137        with:
138          testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}
139      - name: Test Tracing JIT
140        uses: ./.github/actions/test-linux
141        with:
142          testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}_Tracing JIT
143          jitType: tracing
144          runTestsParameters: >-
145            -d zend_extension=opcache.so
146            -d opcache.enable_cli=1
147            ${{ matrix.asan && '--asan -x' || '' }}
148      - name: Verify generated files are up to date
149        if: ${{ !matrix.asan }}
150        uses: ./.github/actions/verify-generated-files
151  MACOS_DEBUG_NTS:
152    if: github.repository == 'php/php-src' || github.event_name == 'pull_request'
153    strategy:
154      fail-fast: false
155      matrix:
156        include:
157          - os: 13
158            arch: X64
159          - os: 14
160            arch: ARM64
161    name: MACOS_${{ matrix.arch }}_DEBUG_NTS
162    runs-on: macos-${{ matrix.os }}
163    steps:
164      - name: git checkout
165        uses: actions/checkout@v4
166      - name: brew
167        uses: ./.github/actions/brew
168      - name: ccache
169        uses: hendrikmuhs/ccache-action@v1.2
170        with:
171          key: "${{github.job}}-${{matrix.os}}-${{hashFiles('main/php_version.h')}}"
172          append-timestamp: false
173      - name: ./configure
174        uses: ./.github/actions/configure-macos
175        with:
176          configurationParameters: --enable-debug --disable-zts
177      - name: make
178        run: |-
179          export PATH="$(brew --prefix)/opt/bison/bin:$PATH"
180          make -j$(sysctl -n hw.logicalcpu) >/dev/null
181      - name: make install
182        run: sudo make install
183      - name: Test Tracing JIT
184        uses: ./.github/actions/test-macos
185        with:
186          testArtifacts: ${{ matrix.arch }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} Tracing JIT
187          jitType: tracing
188          runTestsParameters: >-
189            -d zend_extension=opcache.so
190            -d opcache.enable_cli=1
191      - name: Verify generated files are up to date
192        uses: ./.github/actions/verify-generated-files
193  WINDOWS:
194    if: github.repository == 'php/php-src' || github.event_name == 'pull_request'
195    name: WINDOWS_X64_ZTS
196    runs-on: windows-2019
197    env:
198      PHP_BUILD_CACHE_BASE_DIR: C:\build-cache
199      PHP_BUILD_OBJ_DIR: C:\obj
200      PHP_BUILD_CACHE_SDK_DIR: C:\build-cache\sdk
201      PHP_BUILD_SDK_BRANCH: php_downloads_server_migration_v1
202      PHP_BUILD_CRT: vs16
203      PLATFORM: x64
204      THREAD_SAFE: "1"
205      INTRINSICS: AVX2
206      PARALLEL: -j2
207      OPCACHE: "1"
208    steps:
209      - name: git config
210        run: git config --global core.autocrlf false && git config --global core.eol lf
211      - name: git checkout
212        uses: actions/checkout@v4
213      - name: Setup
214        uses: ./.github/actions/setup-windows
215      - name: Build
216        run: .github/scripts/windows/build.bat
217      - name: Test
218        run: .github/scripts/windows/test.bat
219  BENCHMARKING:
220    name: BENCHMARKING
221    if: github.repository == 'php/php-src' || github.event_name == 'pull_request'
222    runs-on: ubuntu-22.04
223    steps:
224      - name: git checkout
225        uses: actions/checkout@v4
226        with:
227          fetch-depth: 0
228      # ASLR can cause a lot of noise due to missed sse opportunities for memcpy
229      # and other operations, so we disable it during benchmarking.
230      - name: Disable ASLR
231        run: echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
232      - name: apt
233        run: |
234          set -x
235          sudo apt-get update
236          sudo apt-get install \
237            bison \
238            libgmp-dev \
239            libonig-dev \
240            libsqlite3-dev \
241            openssl \
242            re2c \
243            valgrind
244      - name: ccache
245        uses: hendrikmuhs/ccache-action@v1.2
246        with:
247          key: "${{github.job}}-${{hashFiles('main/php_version.h')}}"
248          append-timestamp: false
249      - name: ./configure
250        run: |
251          set -x
252          ./buildconf --force
253          ./configure \
254            --disable-debug \
255            --enable-mbstring \
256            --enable-opcache \
257            --enable-option-checking=fatal \
258            --enable-sockets \
259            --enable-werror \
260            --prefix=/usr \
261            --with-config-file-scan-dir=/etc/php.d \
262            --with-gmp \
263            --with-mysqli=mysqlnd \
264            --with-openssl \
265            --with-pdo-sqlite \
266            --with-valgrind
267      - name: make
268        run: make -j$(/usr/bin/nproc) >/dev/null
269      - name: make install
270        run: |
271          set -x
272          sudo make install
273          sudo mkdir -p /etc/php.d
274          sudo chmod 777 /etc/php.d
275          echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini
276          echo zend_extension=opcache.so >> /etc/php.d/opcache.ini
277          echo opcache.enable=1 >> /etc/php.d/opcache.ini
278          echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini
279      - name: Setup
280        run: |
281          git config --global user.name "Benchmark"
282          git config --global user.email "benchmark@php.net"
283          sudo service mysql start
284          mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS wordpress"
285          mysql -uroot -proot -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpress'; FLUSH PRIVILEGES;"
286          mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'localhost' WITH GRANT OPTION;"
287      - name: git checkout benchmarking-data
288        uses: actions/checkout@v4
289        with:
290          repository: php/benchmarking-data
291          ssh-key: ${{ secrets.BENCHMARKING_DATA_DEPLOY_KEY }}
292          path: benchmark/repos/data
293      - name: Benchmark
294        run: php benchmark/benchmark.php true
295      - name: Store result
296        if: github.event_name == 'push'
297        run: |
298          set -x
299          cd benchmark/repos/data
300          git pull --autostash
301          if [ -e ".git/MERGE_HEAD" ]; then
302            echo "Merging, can't proceed"
303            exit 1
304          fi
305          git add .
306          if git diff --cached --quiet; then
307            exit 0
308          fi
309          git commit -m "Add result for ${{ github.repository }}@${{ github.sha }}"
310          git push
311      - name: Show diff
312        if: github.event_name == 'pull_request'
313        run: |-
314          set -x
315          php benchmark/generate_diff.php \
316            ${{ github.sha }} \
317            $(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) \
318            > $GITHUB_STEP_SUMMARY
319      - uses: actions/upload-artifact@v4
320        with:
321          name: profiles
322          path: ${{ github.workspace }}/benchmark/profiles
323          retention-days: 30
324