Add Valgrind installation verification step #178
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test with Ray.Aop PECL 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'] | |
fail-fast: false | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up PHP ${{ matrix.php-version }} | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
extensions: mbstring, intl, dom, json, libxml, xml, xmlwriter, tokenizer | |
ini-values: memory_limit=256M | |
tools: phpize, composer:v2 | |
coverage: pcov | |
- name: Install build tools and Valgrind | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y autoconf automake libtool bison re2c valgrind | |
- name: Verify Valgrind installation | |
run: valgrind --version | |
- name: Install Composer dependencies | |
run: composer install --prefer-dist --no-progress | |
- name: Build extension | |
id: build_extension | |
run: | | |
git clone https://github.com/ray-di/ext-rayaop.git | |
cd ext-rayaop | |
phpize | |
./configure | |
make | |
continue-on-error: true | |
# Run the demo script | |
- name: Run demo script | |
run: | | |
# Running demo script under Valgrind | |
valgrind \ | |
--leak-check=full \ | |
--show-leak-kinds=all \ | |
--track-origins=yes \ | |
php \ | |
-d extension=./ext-rayaop/modules/rayaop.so \ | |
demo/05-pecl.php | |
# Combined step for PHPUnit and Valgrind analysis | |
- name: Run Tests with Valgrind | |
if: success() || failure() | |
id: test_with_valgrind | |
run: | | |
# Create Valgrind suppression file | |
cat << EOF > rayaop.supp | |
{ | |
php_startup_leak | |
Memcheck:Leak | |
match-leak-kinds: reachable | |
... | |
fun:php_module_startup | |
... | |
} | |
{ | |
zend_mm_startup_leak | |
Memcheck:Leak | |
match-leak-kinds: reachable | |
... | |
fun:zend_mm_startup | |
... | |
} | |
EOF | |
# Run PHPUnit under Valgrind | |
valgrind \ | |
--suppressions=rayaop.supp \ | |
--leak-check=full \ | |
--show-leak-kinds=all \ | |
--track-origins=yes \ | |
--verbose \ | |
--error-exitcode=0 \ | |
--log-file=valgrind.log \ | |
php \ | |
-d extension=./ext-rayaop/modules/rayaop.so \ | |
-d memory_limit=256M \ | |
vendor/bin/phpunit \ | |
--coverage-clover=coverage.xml || true | |
# Display Valgrind log | |
echo "=== Valgrind Log ===" | |
cat valgrind.log | |
# Upload debug information with unique names per PHP version | |
- name: Upload debug logs | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: debug-logs-php${{ matrix.php-version }} | |
path: | | |
valgrind.log | |
coverage.xml | |
core* | |
if-no-files-found: warn | |
# Upload coverage report | |
- name: Upload coverage report | |
if: always() | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
continue-on-error: true | |
- name: Final status check | |
if: always() | |
run: | | |
echo "PHP Version: ${{ matrix.php-version }}" | |
echo "Extension build status: ${{ steps.build_extension.outcome }}" | |
echo "Test with Valgrind status: ${{ steps.test_with_valgrind.outcome }}" | |
# Check for critical issues in Valgrind log | |
if [ -f valgrind.log ]; then | |
echo "=== Valgrind Error Summary ===" | |
grep "ERROR SUMMARY:" valgrind.log || true | |
grep "definitely lost:" valgrind.log || true | |
grep "indirectly lost:" valgrind.log || true | |
fi |