generated from koriym/ext-helloworld
-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (105 loc) · 3.97 KB
/
build.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
name: Build and Test PHP Extension
on:
push:
pull_request:
workflow_dispatch:
jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.1', '8.2', '8.3', '8.4']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
- name: Install build tools and Valgrind
run: |
sudo apt-get update
sudo apt-get install -y autoconf automake libtool bison re2c valgrind
- name: Prepare build
run: |
phpize
./configure
make
- name: Create php.ini
run: |
echo "extension=$(pwd)/modules/rayaop.so" > php.ini
- name: Run tests
id: run_tests
run: PHP_INI_SCAN_DIR=$(pwd) make test
continue-on-error: true
- name: Run demo with debug logging
id: run_demo
run: |
php -dextension=./modules/rayaop.so -i | grep rayaop
timeout 60s php -n -dextension=./modules/rayaop.so -dmemory_limit=128M -dreport_memleaks=1 -dzend.assertions=1 -dassert.exception=1 smoke.php
continue-on-error: true
# Add demo directory test
- name: Test demo directory
id: test_demo_dir
run: |
cd demo
composer install
php -dextension=../modules/rayaop.so aop.php
continue-on-error: true
- name: Run Valgrind memory check
if: steps.run_tests.outcome == 'failure' || steps.run_demo.outcome == 'failure' || steps.test_demo_dir.outcome == 'failure'
run: |
cat << EOF > valgrind.supp
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: reachable
...
fun:php_module_startup
...
}
EOF
valgrind --suppressions=valgrind.supp --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-out.txt php -n -dextension=./modules/rayaop.so smoke.php
# Also run Valgrind on demo directory
cd demo
valgrind --suppressions=../valgrind.supp --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-demo-out.txt php -n -dextension=../modules/rayaop.so aop.php
- name: Check Valgrind results
if: steps.run_tests.outcome == 'failure' || steps.run_demo.outcome == 'failure' || steps.test_demo_dir.outcome == 'failure'
run: |
for log in valgrind-out.txt demo/valgrind-demo-out.txt; do
if [ -f "$log" ]; then
echo "Checking Valgrind log: $log"
cat "$log"
if ! grep -q "ERROR SUMMARY: 0 errors from 0 contexts" "$log"; then
echo "Valgrind found errors in $log"
exit 1
fi
fi
done
- name: Upload Valgrind logs
if: (steps.run_tests.outcome == 'failure' || steps.run_demo.outcome == 'failure' || steps.test_demo_dir.outcome == 'failure') && always()
uses: actions/upload-artifact@v4
with:
name: valgrind-logs
path: |
valgrind-out.txt
demo/valgrind-demo-out.txt
if-no-files-found: warn
- name: Upload test logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-logs
path: |
tests/*.log
tests/*.sh
demo/*.log
if-no-files-found: warn
- name: Final status check
if: always()
run: |
if [ "${{ steps.run_tests.outcome }}" == "failure" ] || [ "${{ steps.run_demo.outcome }}" == "failure" ] || [ "${{ steps.test_demo_dir.outcome }}" == "failure" ]; then
echo "Tests, demo run, or demo directory test failed. Please check the logs for more information."
exit 1
fi