xref: /PHP-8.2/.github/workflows/push.yml (revision a4d64b26)
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_owner == 'php' || github.event_name == 'pull_request'
47    services:
48      mysql:
49        image: mysql:8
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-22.04
84    steps:
85      - name: git checkout
86        uses: actions/checkout@v4
87      - name: apt
88        uses: ./.github/actions/apt-x64
89      - name: LLVM 16 (ASAN-only)
90        if: ${{ matrix.asan }}
91        run: |
92          wget https://apt.llvm.org/llvm.sh
93          chmod u+x llvm.sh
94          sudo ./llvm.sh 16
95      - name: System info
96        run: |
97          echo "::group::Show host CPU info"
98          lscpu
99          echo "::endgroup::"
100          echo "::group::Show installed package versions"
101          dpkg -l
102          echo "::endgroup::"
103      - name: Create MSSQL container
104        if: ${{ !matrix.asan }}
105        uses: ./.github/actions/setup-mssql
106      - name: Setup Caddy server
107        uses: ./.github/actions/setup-caddy
108      - name: ccache
109        uses: hendrikmuhs/ccache-action@v1.2
110        with:
111          # This duplicates the "job.name" expression above because
112          # GitHub has no way to query the job name (github.job is the
113          # job id, not the job name)
114          key: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}-${{hashFiles('main/php_version.h')}}"
115          append-timestamp: false
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 -fno-sanitize=pointer-overflow -DZEND_TRACK_ARENA_ALLOC" LDFLAGS="-fsanitize=undefined,address -fno-sanitize=pointer-overflow" 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        with:
135          testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}
136      - name: Test Tracing JIT
137        uses: ./.github/actions/test-linux
138        with:
139          testArtifacts: ${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}_Tracing JIT
140          jitType: tracing
141          runTestsParameters: >-
142            -d zend_extension=opcache.so
143            -d opcache.enable_cli=1
144            ${{ matrix.asan && '--asan -x' || '' }}
145      - name: Verify generated files are up to date
146        if: ${{ !matrix.asan }}
147        uses: ./.github/actions/verify-generated-files
148  MACOS_DEBUG_NTS:
149    if: github.repository_owner == 'php' || github.event_name == 'pull_request'
150    strategy:
151      fail-fast: false
152      matrix:
153        include:
154          - os: 13
155            arch: X64
156          - os: 14
157            arch: ARM64
158    name: MACOS_${{ matrix.arch }}_DEBUG_NTS
159    runs-on: macos-${{ matrix.os }}
160    steps:
161      - name: git checkout
162        uses: actions/checkout@v4
163      - name: brew
164        uses: ./.github/actions/brew
165      - name: ccache
166        uses: hendrikmuhs/ccache-action@v1.2
167        with:
168          key: "${{github.job}}-${{matrix.os}}-${{hashFiles('main/php_version.h')}}"
169          append-timestamp: false
170      - name: ./configure
171        uses: ./.github/actions/configure-macos
172        with:
173          configurationParameters: --enable-debug --disable-zts
174      - name: make
175        run: |-
176          export PATH="$(brew --prefix)/opt/bison/bin:$PATH"
177          make -j$(sysctl -n hw.logicalcpu) >/dev/null
178      - name: make install
179        run: sudo make install
180      - name: Test Tracing JIT
181        uses: ./.github/actions/test-macos
182        with:
183          testArtifacts: ${{ matrix.arch }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }} Tracing JIT
184          jitType: tracing
185          runTestsParameters: >-
186            -d zend_extension=opcache.so
187            -d opcache.enable_cli=1
188      - name: Verify generated files are up to date
189        uses: ./.github/actions/verify-generated-files
190  WINDOWS:
191    if: github.repository_owner == 'php' || github.event_name == 'pull_request'
192    name: WINDOWS_X64_ZTS
193    runs-on: windows-2019
194    env:
195      PHP_BUILD_CACHE_BASE_DIR: C:\build-cache
196      PHP_BUILD_OBJ_DIR: C:\obj
197      PHP_BUILD_CACHE_SDK_DIR: C:\build-cache\sdk
198      PHP_BUILD_SDK_BRANCH: php_downloads_server_migration_v1
199      PHP_BUILD_CRT: vs16
200      PLATFORM: x64
201      THREAD_SAFE: "1"
202      INTRINSICS: AVX2
203      PARALLEL: -j2
204      OPCACHE: "1"
205    steps:
206      - name: git config
207        run: git config --global core.autocrlf false && git config --global core.eol lf
208      - name: git checkout
209        uses: actions/checkout@v4
210      - name: Setup
211        uses: ./.github/actions/setup-windows
212      - name: Build
213        run: .github/scripts/windows/build.bat
214      - name: Test
215        run: .github/scripts/windows/test.bat
216  BENCHMARKING:
217    name: BENCHMARKING
218    if: github.repository_owner == 'php' || github.event_name == 'pull_request'
219    runs-on: ubuntu-22.04
220    steps:
221      - name: git checkout
222        uses: actions/checkout@v4
223        with:
224          fetch-depth: 0
225      - name: apt
226        run: |
227          set -x
228          sudo apt-get update
229          sudo apt-get install \
230            bison \
231            libgmp-dev \
232            libonig-dev \
233            libsqlite3-dev \
234            openssl \
235            re2c \
236            valgrind
237      - name: ccache
238        uses: hendrikmuhs/ccache-action@v1.2
239        with:
240          key: "${{github.job}}-${{hashFiles('main/php_version.h')}}"
241          append-timestamp: false
242      - name: ./configure
243        run: |
244          set -x
245          ./buildconf --force
246          ./configure \
247            --disable-debug \
248            --enable-mbstring \
249            --enable-opcache \
250            --enable-option-checking=fatal \
251            --enable-sockets \
252            --enable-werror \
253            --prefix=/usr \
254            --with-config-file-scan-dir=/etc/php.d \
255            --with-gmp \
256            --with-mysqli=mysqlnd \
257            --with-openssl \
258            --with-pdo-sqlite \
259            --with-valgrind
260      - name: make
261        run: make -j$(/usr/bin/nproc) >/dev/null
262      - name: make install
263        run: |
264          set -x
265          sudo make install
266          sudo mkdir -p /etc/php.d
267          sudo chmod 777 /etc/php.d
268          echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini
269          echo zend_extension=opcache.so >> /etc/php.d/opcache.ini
270          echo opcache.enable=1 >> /etc/php.d/opcache.ini
271          echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini
272      - name: Setup
273        run: |
274          git config --global user.name "Benchmark"
275          git config --global user.email "benchmark@php.net"
276          sudo service mysql start
277          mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS wordpress"
278          mysql -uroot -proot -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpress'; FLUSH PRIVILEGES;"
279          mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'localhost' WITH GRANT OPTION;"
280      - name: git checkout benchmarking-data
281        uses: actions/checkout@v4
282        with:
283          repository: php/benchmarking-data
284          ssh-key: ${{ secrets.BENCHMARKING_DATA_DEPLOY_KEY }}
285          path: benchmark/repos/data
286      - name: Benchmark
287        run: php benchmark/benchmark.php true
288      - name: Store result
289        if: github.event_name == 'push'
290        run: |
291          set -x
292          cd benchmark/repos/data
293          git pull --autostash
294          if [ -e ".git/MERGE_HEAD" ]; then
295            echo "Merging, can't proceed"
296            exit 1
297          fi
298          git add .
299          if git diff --cached --quiet; then
300            exit 0
301          fi
302          git commit -m "Add result for ${{ github.repository }}@${{ github.sha }}"
303          git push
304      - name: Show diff
305        if: github.event_name == 'pull_request'
306        run: |-
307          set -x
308          php benchmark/generate_diff.php \
309            ${{ github.sha }} \
310            $(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) \
311            > $GITHUB_STEP_SUMMARY
312      - uses: actions/upload-artifact@v4
313        with:
314          name: profiles
315          path: ${{ github.workspace }}/benchmark/profiles
316          retention-days: 30
317