Send coverage to Scrutinizer #37
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: Run phpunit tests | |
permissions: | |
contents: read | |
on: [push] | |
jobs: | |
test-php: | |
name: Test on php ${{ matrix.php-version }} and ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
continue-on-error: ${{ matrix.experimental }} | |
services: | |
mysql: | |
image: mysql:5.7 | |
env: | |
MYSQL_DATABASE: testdb | |
MYSQL_USER: testuser | |
MYSQL_PASSWORD: testpass | |
MYSQL_RANDOM_ROOT_PASSWORD: yes | |
ports: | |
- "3306:3306" | |
options: --name mysql-server --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
strategy: | |
fail-fast: false | |
matrix: | |
php-version: ["8.2", "8.3"] | |
os: [ubuntu-latest] | |
experimental: [false] | |
include: | |
- { php-version: 'nightly', os: ubuntu-latest, experimental: true } | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Fetch 10 commits or Scrutinizer will throw ("Failed to retrieve commit parents. If you use a shallow git checkout, please checkout at least a depth of one."), see: RepositoryIntrospector at scrutinizer-ci/ocular GitHub repository | |
# 10 commits is an arbitrary value that is more than 1 commit | |
fetch-depth: 10 | |
- name: Use php ${{ matrix.php-version }} | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
coverage: pcov | |
extensions: mbstring | |
- name: Cache module | |
uses: actions/cache@v4 | |
with: | |
path: ~/.composer/cache/ | |
key: composer-cache | |
- name: Install dependencies | |
run: composer install --no-interaction | |
- name: Copy config | |
run: cp tests/config.dist.php tests/config.php | |
- name: Run php tests | |
run: composer run phpunit -- --coverage-clover build/logs/clover.xml | |
env: | |
TEST_MYSQL_HOST: "127.0.0.1" | |
TEST_MYSQL_DB: testdb | |
TEST_MYSQL_USER: testuser | |
TEST_MYSQL_PASS: testpass | |
TEST_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }} | |
- name: Send coverage | |
uses: codecov/codecov-action@v4 | |
with: | |
file: "./build/logs/clover.xml" | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Upload Scrutinizer coverage | |
uses: sudo-bot/action-scrutinizer@latest | |
# Do not run this step on forked versions of the main repository (example: contributor forks) | |
if: github.repository == 'wdes/simple-php-model-system' | |
with: | |
cli-args: "--format=php-clover build/logs/clover.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}" |