Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Build
run: |
phpize
./configure
./configure --enable-code-coverage
make -j $(nproc)
sudo make install
sudo sh -c "echo 'extension=phpy.so' > /etc/php/${PHP_VERSION}/cli/conf.d/90-phpy.ini"
Expand All @@ -49,3 +49,18 @@ jobs:
sudo service redis-server start
composer install
composer test

- name: run coverage
shell: bash
run: sudo apt-get install lcov &&
sudo lcov --directory . --capture --branch-coverage --rc geninfo_unexecuted_blocks=1 --ignore-errors mismatch --output-file coverage.info &&
sudo lcov --remove coverage.info '/usr/*' --output-file coverage.info &&
sudo lcov --list coverage.info

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.info
fail_ci_if_error: true

16 changes: 15 additions & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,24 @@ jobs:
pwd
- name: Build
run: |
cmake .
cmake . -D CODE_COVERAGE=ON
make -j $(nproc)
- name: Run pytest tests
run: |
sudo service redis-server start
pip install pytest
pytest -v tests/

- name: run coverage
shell: bash
run: sudo apt-get install lcov &&
sudo lcov --directory . --capture --branch-coverage --rc geninfo_unexecuted_blocks=1 --ignore-errors mismatch --output-file coverage.info &&
sudo lcov --remove coverage.info '/usr/*' --output-file coverage.info &&
sudo lcov --list coverage.info

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.info
fail_ci_if_error: true
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ if (NOT DEFINED PYTHON_CONFIG)
set(PYTHON_CONFIG "python3-config")
endif()

# Code Coverage Configuration
add_library(coverage_config INTERFACE)

option(CODE_COVERAGE "Enable coverage reporting" OFF)
if(CODE_COVERAGE)
message(STATUS "Open coverage")
# --coverage => -fprofile-arcs -ftest-coverage
target_compile_options(coverage_config INTERFACE
-O0
-g
-fprofile-update=atomic
--coverage
)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
target_link_options(coverage_config INTERFACE --coverage)
else()
target_link_libraries(coverage_config INTERFACE --coverage)
endif()
endif(CODE_COVERAGE)

file(GLOB_RECURSE SOURCE_FILES FOLLOW_SYMLINKS src/*.cc)

execute_process(COMMAND ${PHP_CONFIG} --includes
Expand Down Expand Up @@ -55,5 +75,9 @@ include_directories(BEFORE ${phpy_includes})
link_directories(${phpy_link_directories})
add_library(phpy SHARED ${SOURCE_FILES})

if (CODE_COVERAGE)
target_link_libraries(phpy coverage_config gcov)
endif(CODE_COVERAGE)

set_target_properties(phpy PROPERTIES OUTPUT_NAME "lib/phpy")
target_link_libraries(phpy ${phpy_libraries})
15 changes: 15 additions & 0 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ PHP_ARG_ENABLE([phpy],
[Enable phpy support])],
[no])

PHP_ARG_ENABLE([code-coverage],
[whether to enable code coverage support],
[AS_HELP_STRING([--enable-code-coverage],
[Enable code coverage support])], [no], [no])

AC_DEFUN([GET_PYTHON_LDFLAGS], [
TMP_RESULT="$($PHP_PYTHON_CONFIG --embed --ldflags)"
if test $? -eq 0; then
Expand Down Expand Up @@ -84,6 +89,16 @@ if test "$PHP_PHPY" != "no"; then
EXTRAS_CXXFLAGS="-Wall -Wno-unused-function -Wno-deprecated -Wno-deprecated-declarations -z now"
EXTRAS_CXXFLAGS="$EXTRAS_CXXFLAGS -std=c++14"

AC_MSG_CHECKING([code coverage])
if test "$PHP_CODE_COVERAGE" != "no"; then
AC_MSG_RESULT([enabled])
EXTRAS_CFLAGS="-fprofile-arcs -ftest-cover -fprofile-update=atomic"
EXTRAS_CXXFLAGS="-fprofile-arcs -ftest-coverage -fprofile-update=atomic"
EXTRA_LDFLAGS="--coverage"
else
AC_MSG_RESULT([disabled])
fi

if test -f "$abs_srcdir/phpy.cc"; then
phpy_source_dir=$abs_srcdir
elif test -f "phpy.cc"; then
Expand Down