Add unit test coverage statistics (#89) #260
This file contains hidden or 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: phpunit | |
| on: [ push, pull_request ] | |
| jobs: | |
| php: | |
| runs-on: ubuntu-latest | |
| env: | |
| PHP_VERSION: ${{ matrix.php }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: [ '8.1', '8.2', '8.3' ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install deps | |
| run: sudo apt update -y && sudo apt install -y libcurl4-openssl-dev php-curl libc-ares-dev python3 python3-dev | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: "${{ matrix.php }}" | |
| coverage: none | |
| - name: Show machine information | |
| run: | | |
| date | |
| env | |
| uname -a | |
| ulimit -a | |
| php -v | |
| php --ini | |
| ls -al | |
| ldconfig -p | |
| pwd | |
| echo "`git log -20 --pretty --oneline`" | |
| echo "`git log -10 --stat --pretty --oneline`" | |
| - name: Build | |
| run: | | |
| phpize | |
| ./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" | |
| php --ri phpy | |
| - name: Run phpunit tests | |
| env: | |
| LC_ALL: POSIX # Do not remove this line, PR: https://github.com/swoole/phpy/pull/45 | |
| run: | | |
| sudo apt install -y redis-server | |
| 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 | |