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
78 changes: 78 additions & 0 deletions .github/workflows/run-tests-with-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Run tests with coverage

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

jobs:
tests-with-coverage:
runs-on: ubuntu-latest
env:
DB_CONNECTION: pgsql
DB_HOST: 127.0.0.1
DB_PORT: 5432
DB_DATABASE: forge
DB_USERNAME: forge
DB_PASSWORD: secret

services:
postgres:
image: postgres
env:
POSTGRES_DB: forge
POSTGRES_USER: forge
POSTGRES_PASSWORD: secret
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring, pdo, pdo_pgsql, gd, dom, fileinfo, pgsql
coverage: xdebug
env:
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432

- name: Set up PostgreSQL
run: |
sudo apt-get update
sudo apt-get install -y postgresql-client
psql --version

- name: Wait for PostgreSQL
run: |
echo "Waiting for PostgreSQL to be ready..."
for i in {1..30}; do
if pg_isready -h 127.0.0.1 -p 5432 -U forge -d forge; then
echo "PostgreSQL is ready"
exit 0
fi
echo "Waiting for PostgreSQL..."
sleep 2
done
echo "PostgreSQL failed to start"
exit 1

- name: Install Composer dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Run PHPUnit tests with coverage
run: php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-clover=build/logs/clover.xml --stop-on-failure ./tests/

- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: php vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,10 @@
"RonasIT\\Chat\\ChatServiceProvider"
]
}
},
"require-dev": {
"phpunit/phpunit": "^11.5",
"phpunit/php-code-coverage": "^11.0",
"php-coveralls/php-coveralls": "^2.7"
}
}
}
Loading