-
Notifications
You must be signed in to change notification settings - Fork 18
155 lines (135 loc) · 5.34 KB
/
main-php-matrix.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: CI (reusable workflow)
on:
workflow_call:
inputs:
php:
description: 'PHP version'
required: true
type: string
runs-on:
description: 'GitHub runner'
default: 'ubuntu-20.04'
type: string
jobs:
build-php:
name: Build PHP (Valgrind ${{ matrix.valgrind }})
concurrency: php-debug-${{ inputs.php }}-valgrind-${{ matrix.valgrind }}-${{ inputs.runs-on }}-${{ github.ref }}
strategy:
matrix:
valgrind: [0, 1]
runs-on: ${{ inputs.runs-on }}
steps:
- name: Set PHP build cache key
id: cache-key
run: |
echo "key=php-debug-${{ inputs.php }}-valgrind-${{ matrix.valgrind }}-${{ inputs.runs-on }}" >> $GITHUB_OUTPUT
- name: Check PHP build cache
uses: actions/cache@v4
id: cache
with:
path: ${{ github.workspace }}/php
key: ${{ steps.cache-key.outputs.key }}
lookup-only: true
- name: Install PHP build dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
sudo apt-get update && sudo apt-get install \
re2c
- name: Install Valgrind
if: matrix.valgrind == '1' && steps.cache.outputs.cache-hit != 'true'
run: |
sudo apt-get update && sudo apt-get install valgrind
echo "CFLAGS=-DZEND_TRACK_ARENA_ALLOC=1" >> $GITHUB_ENV
echo "PHP_BUILD_CONFIGURE_OPTS=--with-valgrind" >> $GITHUB_ENV
- name: Get number of CPU cores
if: steps.cache.outputs.cache-hit != 'true'
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores
- name: Download PHP
if: steps.cache.outputs.cache-hit != 'true'
run: curl -L https://github.com/php/php-src/archive/refs/tags/php-${{ inputs.php }}.tar.gz | tar -xz
- name: Compile PHP
if: steps.cache.outputs.cache-hit != 'true'
working-directory: php-src-php-${{ inputs.php }}
run: |
./buildconf --force
./configure \
--disable-all \
--enable-cli \
--enable-zts \
--enable-debug \
--enable-sockets \
--enable-opcache \
--enable-opcache-jit \
"$PHP_BUILD_CONFIGURE_OPTS" \
--prefix="${{ github.workspace }}/php"
make -j ${{ steps.cpu-cores.outputs.count }} install
test-extension:
name: Test (OPcache ${{ matrix.opcache }}, Valgrind tool ${{ matrix.valgrind-tool }})
runs-on: ${{ inputs.runs-on }}
needs: build-php
strategy:
fail-fast: false
matrix:
opcache:
- "off"
- "on"
- "jit"
#- "jit-tracing" #borked until 8.3 due to php-src bugs
valgrind-tool:
- none
- memcheck
- drd
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Fetch PHP build cache
uses: actions/cache/restore@v4 #fails if cache is missing
with:
path: ${{ github.workspace }}/php
key: php-debug-${{ inputs.php }}-valgrind-${{ matrix.valgrind-tool != 'none' && 1 || 0 }}-${{ inputs.runs-on }}
- name: Install Valgrind
if: matrix.valgrind-tool != 'none'
run: |
sudo apt-get update && sudo apt-get install valgrind
echo "TEST_PHP_ARGS=-M ${{ matrix.valgrind-tool }}" >> $GITHUB_ENV
echo "CFLAGS=-DZEND_TRACK_ARENA_ALLOC=1" >> $GITHUB_ENV
- name: Compile extension
run: |
$GITHUB_WORKSPACE/php/bin/phpize
./configure --with-php-config=$GITHUB_WORKSPACE/php/bin/php-config --with-pmmpthread-sockets
make install
- name: Generate php.ini
run: |
echo "extension=pmmpthread.so" > $GITHUB_WORKSPACE/php.ini
if [[ "${{ matrix.opcache }}" != "off" ]]; then
echo "Enabling OPcache"
echo "zend_extension=opcache.so" >> $GITHUB_WORKSPACE/php.ini
echo "opcache.enable=1" >> $GITHUB_WORKSPACE/php.ini
echo "opcache.enable_cli=1" >> $GITHUB_WORKSPACE/php.ini
echo "opcache.protect_memory=1" >> $GITHUB_WORKSPACE/php.ini
if [[ "${{ matrix.opcache }}" == "jit" ]]; then
echo "opcache.jit=1205" >> $GITHUB_WORKSPACE/php.ini
echo "opcache.jit_buffer_size=128M" >> $GITHUB_WORKSPACE/php.ini
elif [[ "${{ matrix.opcache }}" == "jit-tracing" ]]; then
echo "opcache.jit=tracing" >> $GITHUB_WORKSPACE/php.ini
echo "opcache.jit_buffer_size=128M" >> $GITHUB_WORKSPACE/php.ini
else
echo "opcache.jit=0" >> $GITHUB_WORKSPACE/php.ini
fi
else
echo "OPcache is not enabled for this run"
fi
- name: Run PHPT tests
run: |
$GITHUB_WORKSPACE/php/bin/php ./run-tests.php $TEST_PHP_ARGS -P -j$(nproc) -q --show-diff --show-slow 30000 -n -c $GITHUB_WORKSPACE/php.ini
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ inputs.php }}-valgrind-${{ matrix.valgrind-tool }}-opcache-${{ matrix.opcache }}
path: |
${{ github.workspace }}/tests/*.log
${{ github.workspace }}/tests/*.diff
${{ github.workspace }}/tests/*.mem
if-no-files-found: ignore