#14: Configured automatic running tests on commit #2
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 tests with coverage | |
on: | |
push: | |
branches: ["master"] | |
pull_request: | |
branches: ["master"] | |
jobs: | |
tests-with-coverage: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:12.5 | |
env: | |
POSTGRES_DB: mydb | |
POSTGRES_USER: myuser | |
POSTGRES_PASSWORD: mypassword | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.1' | |
extensions: pgsql | |
- name: Install Dependencies | |
run: | | |
composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist | |
composer update --with-dependencies | |
- name: Execute unit tests via PHPUnit with coverage | |
run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml | |
- name: Upload coverage results to Coveralls | |
env: | |
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
composer global require php-coveralls/php-coveralls | |
php-coveralls --coverage_clover=build/logs/clover.xml -v |