Skip to content

Commit

Permalink
Merge f3872bd into 492385e
Browse files Browse the repository at this point in the history
  • Loading branch information
danon committed May 15, 2021
2 parents 492385e + f3872bd commit 91c23fd
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/build.yaml
@@ -0,0 +1,88 @@
name: build

on:
push:
pull_request:

jobs:
tests:
name: Unit tests on PHP ${{ matrix.php }} and ${{ matrix.db }}
runs-on: ubuntu-latest
strategy:
matrix:
php: [ '8.0.0', '8.0.1' ]
db: [ 'MySQL', 'PostgreSQL', 'SQLite' ]
include:
- db: MySQL
phpunitArgs: "--exclude-group postgres,sqlite3"
phpunitEnv: db=mysql # from config/test/config.php
- db: PostgreSQL
phpunitArgs: "--exclude-group mysql,sqlite3"
phpunitEnv: db=postgres # from config/test/config.php
- db: SQLite
phpunitArgs: "--exclude-group mysql,postgres,non-sqlite3"
phpunitEnv: db=sqlite3 # from config/test/config.php
services:
mysql:
image: mysql:8
env:
MYSQL_DATABASE: ouzo_test
MYSQL_ROOT_PASSWORD: password
# Set health checks to wait until mysql has started
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 3306:3306
postgres:
image: postgres:10.0
env:
POSTGRES_DB: ouzo_test
POSTGRES_USER: ouzo_user
POSTGRES_PASSWORD: password
# Set health checks to wait until postgres has started
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 5432:5432

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

- name: Use PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2
coverage: "${{ matrix.coverage }}"

- name: Seed database (PostgreSQL)
if: "${{ matrix.db == 'PostgreSQL' }}"
run: PGPASSWORD=password psql -h 127.0.0.1 -U ouzo_user -v ON_ERROR_STOP=1 -e -f test/test-db/recreate_schema.sql ouzo_test

- name: Seed database (MySQL)
if: "${{ matrix.db == 'MySQL' }}"
run: |
mysql -h 127.0.0.1 -u root -ppassword -e "CREATE USER travis; GRANT ALL ON *.* TO travis;"
cat test/test-db/recreate_schema_mysql.sql | mysql -h 127.0.0.1 -u root -ppassword ouzo_test
- name: Seed database (SQLite)
if: "${{ matrix.db == 'SQLite' }}"
run: echo | sqlite3 ouzo_test -init test/test-db/recreate_schema_sqlite3.sql
# I don't know how to run sqlite without it going into interactive mode, so I piped empty stream to it

- name: Cache dependencies installed with Composer
uses: actions/cache@v1
with:
path: ~/.cache/composer
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: php${{ matrix.php }}-composer-

- name: Install dependencies
run: composer install --no-progress;

- name: Run tests
run: ${{ matrix.phpunitEnv }} ./vendor/bin/phpunit ${{ matrix.phpunitArgs }} --whitelist src test

- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -7,3 +7,6 @@ vendor/
.phpunit.result.cache
build/logs/clover.xml
build/cov/coverage.cov

# SQLite
ouzo_test
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -3,6 +3,7 @@
Ouzo is a PHP MVC framework with built-in ORM and util libraries. PHP 8.0 or later is required.

[![Build Status](https://travis-ci.org/letsdrink/ouzo.png?branch=master)](https://travis-ci.org/letsdrink/ouzo)
[![Build Status](https://github.com/letsdrink/ouzo/workflows/build/badge.svg?branch=master)](https://github.com/letsdrink/ouzo/actions)
[![Documentation Status](https://readthedocs.org/projects/ouzo/badge/?version=latest)](https://readthedocs.org/projects/ouzo/?badge=latest)
[![Coverage Status](https://coveralls.io/repos/letsdrink/ouzo/badge.svg?branch=master)](https://coveralls.io/r/letsdrink/ouzo?branch=master)
[![Latest Stable Version](https://poser.pugx.org/letsdrink/ouzo/v/stable.svg)](https://packagist.org/packages/letsdrink/ouzo)
Expand Down
1 change: 1 addition & 0 deletions test/test-db/recreate_schema_mysql.sql
Expand Up @@ -38,6 +38,7 @@ DROP FUNCTION IF EXISTS get_name;
DELIMITER $$
CREATE FUNCTION get_name(p_name TEXT)
RETURNS TEXT LANGUAGE SQL
DETERMINISTIC
BEGIN
RETURN (SELECT
name
Expand Down

0 comments on commit 91c23fd

Please sign in to comment.