-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3689 from michalsn/feature/action-test
Test framework with github actions
- Loading branch information
Showing
8 changed files
with
204 additions
and
139 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
name: PHPUnit | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- develop | ||
- '4.*' | ||
|
||
jobs: | ||
|
||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
if: "!contains(github.event.head_commit.message, '[ci skip]')" | ||
|
||
name: PHP ${{ matrix.php-versions }} - ${{ matrix.db-platforms }} | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php-versions: ['7.2', '7.3', '7.4'] | ||
db-platforms: ['MySQLi', 'Postgre', 'SQLite3'] | ||
|
||
services: | ||
mysql: | ||
image: mysql:5.7 | ||
env: | ||
MYSQL_ALLOW_EMPTY_PASSWORD: yes | ||
MYSQL_DATABASE: test | ||
ports: | ||
- 3306:3306 | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
postgres: | ||
image: postgres | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: test | ||
ports: | ||
- 5432:5432 | ||
options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3 | ||
redis: | ||
image: redis | ||
ports: | ||
- 6379:6379 | ||
options: --health-cmd "redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP, with composer and extensions | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
tools: composer:v2 | ||
extensions: imagick | ||
coverage: xdebug | ||
env: | ||
update: true | ||
|
||
- name: Install Memcached | ||
uses: niden/actions-memcached@v7 | ||
|
||
- 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 --no-progress --no-suggest --no-interaction --prefer-dist --optimize-autoloader | ||
env: | ||
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} | ||
|
||
- name: Test with PHPUnit | ||
run: script -e -c "vendor/bin/phpunit -v" | ||
env: | ||
DB: ${{ matrix.db-platforms }} | ||
TERM: xterm-256color | ||
|
||
- name: Run Coveralls | ||
run: | | ||
composer global require twinh/php-coveralls | ||
php-coveralls --coverage_clover=build/logs/clover.xml -v | ||
env: | ||
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
COVERALLS_PARALLEL: true | ||
COVERALLS_FLAG_NAME: PHP ${{ matrix.php-versions }} | ||
|
||
coveralls-finish: | ||
needs: [tests] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Coveralls Finished | ||
uses: coverallsapp/github-action@master | ||
with: | ||
github-token: ${{ secrets.github_token }} | ||
parallel-finished: true |
This file was deleted.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php namespace Tests\Support\Config; | ||
|
||
/** | ||
* Class Registrar | ||
* | ||
* Provides a basic registrar class for testing BaseConfig registration functions. | ||
*/ | ||
|
||
class Registrar | ||
{ | ||
/** | ||
* DB config array for testing purposes. | ||
* | ||
* @var array | ||
*/ | ||
protected static $dbConfig = [ | ||
'MySQLi' => [ | ||
'DSN' => '', | ||
'hostname' => '127.0.0.1', | ||
'username' => 'root', | ||
'password' => '', | ||
'database' => 'test', | ||
'DBDriver' => 'MySQLi', | ||
'DBPrefix' => 'db_', | ||
'pConnect' => false, | ||
'DBDebug' => (ENVIRONMENT !== 'production'), | ||
'charset' => 'utf8', | ||
'DBCollat' => 'utf8_general_ci', | ||
'swapPre' => '', | ||
'encrypt' => false, | ||
'compress' => false, | ||
'strictOn' => false, | ||
'failover' => [], | ||
'port' => 3306, | ||
], | ||
'Postgre' => [ | ||
'DSN' => '', | ||
'hostname' => 'localhost', | ||
'username' => 'postgres', | ||
'password' => 'postgres', | ||
'database' => 'test', | ||
'DBDriver' => 'Postgre', | ||
'DBPrefix' => 'db_', | ||
'pConnect' => false, | ||
'DBDebug' => (ENVIRONMENT !== 'production'), | ||
'charset' => 'utf8', | ||
'DBCollat' => 'utf8_general_ci', | ||
'swapPre' => '', | ||
'encrypt' => false, | ||
'compress' => false, | ||
'strictOn' => false, | ||
'failover' => [], | ||
'port' => 5432, | ||
], | ||
'SQLite3' => [ | ||
'DSN' => '', | ||
'hostname' => 'localhost', | ||
'username' => '', | ||
'password' => '', | ||
'database' => 'database.db', | ||
'DBDriver' => 'SQLite3', | ||
'DBPrefix' => 'db_', | ||
'pConnect' => false, | ||
'DBDebug' => (ENVIRONMENT !== 'production'), | ||
'charset' => 'utf8', | ||
'DBCollat' => 'utf8_general_ci', | ||
'swapPre' => '', | ||
'encrypt' => false, | ||
'compress' => false, | ||
'strictOn' => false, | ||
'failover' => [], | ||
'port' => 3306, | ||
], | ||
]; | ||
|
||
/** | ||
* Override database config | ||
* | ||
* @return array | ||
*/ | ||
public static function Database() | ||
{ | ||
$config = []; | ||
|
||
// Under Github Actions, we can set an ENV var named 'DB' | ||
// so that we can test against multiple databases. | ||
if ($group = getenv('DB')) | ||
{ | ||
if (! empty(self::$dbConfig[$group])) | ||
{ | ||
$config['tests'] = self::$dbConfig[$group]; | ||
} | ||
} | ||
|
||
return $config; | ||
} | ||
|
||
} |
Binary file not shown.
This file was deleted.
Oops, something went wrong.