Skip to content

Commit

Permalink
gactions: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Oct 17, 2020
1 parent df0ba29 commit b1462f6
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 5 deletions.
94 changes: 93 additions & 1 deletion .github/workflows/build.yml
Expand Up @@ -10,14 +10,18 @@ jobs:

runs-on: ubuntu-latest

strategy:
matrix:
php-versions: [ '7.4' ]

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

- name: Setup PHP with pecl extension
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: ${{ matrix.php-versions }}

- name: Get composer cache directory
id: composercache
Expand All @@ -35,3 +39,91 @@ jobs:

- name: Run PHPStan
run: composer phpstan

tests:
name: Tests

strategy:
matrix:
php-versions: [ '7.1', '7.2', '7.3', '7.4' ]

runs-on: ubuntu-latest

services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: nextras_dbal_test
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -ppass"
--health-interval 10s
--health-start-period 10s
--health-timeout 5s
--health-retries 10
postgres:
image: postgres:10.8
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: nextras_dbal_test
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP with pecl extension
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, mysqli
coverage: pcov

- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist --no-interaction --no-progress --no-suggest

- name: Init config
run: cp ./tests/databases.sample.ini ./tests/databases.ini && cat ./tests/databases.ini

- name: Tests
run: ./tests/run.sh ./tests/cases --coverage ./clover.xml --coverage-src ./src

- name: Send coverage report
env:
COVERALLS_PARALLEL: "true"
COVERALLS_FLAG_NAME: run-${{ matrix.php-versions }}
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer require --dev php-coveralls/php-coveralls --prefer-dist --no-interaction --no-progress --no-suggest && \
vendor/bin/php-coveralls -v --coverage_clover=./clover.xml --json_path=./coveralls-upload.json
coverage-finish:
name: Code coverage finish
needs: tests
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl -k "https://coveralls.io/webhook?repo_name=$GITHUB_REPOSITORY&repo_token=$COVERALLS_REPO_TOKEN" -d "payload[build_num]=$GITHUB_RUN_ID&payload[status]=done"
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -12,7 +12,8 @@
"issues": "https://github.com/nextras/dbal/issues"
},
"require": {
"php": ">=7.1"
"php": ">=7.1",
"ext-json": "*"
},
"require-dev": {
"mockery/mockery": "~1.3.0",
Expand Down
4 changes: 2 additions & 2 deletions tests/databases.sample.ini
Expand Up @@ -3,11 +3,11 @@ driver = mysqli
host = "127.0.0.1"
database = nextras_dbal_test
username = root
password =
password = root

[pgsql]
driver = pgsql
host = "127.0.0.1"
database = nextras_dbal_test
username = postgres
password =
password = postgres
2 changes: 1 addition & 1 deletion tests/run.sh
@@ -1,3 +1,3 @@
#!/bin/sh
dir=$(cd `dirname $0` && pwd)
$dir/../vendor/bin/tester -p php -c $dir/php.ini --setup $dir/inc/setup.php $@
$dir/../vendor/bin/tester -C --setup $dir/inc/setup.php $@

0 comments on commit b1462f6

Please sign in to comment.