Skip to content

Commit

Permalink
Merge pull request #828 from cakephp/gha-3x
Browse files Browse the repository at this point in the history
Port CI configuration to github actions
  • Loading branch information
othercorey authored May 16, 2021
2 parents 5bec3c4 + 69f7fa4 commit ed9bbe4
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 57 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: CI


on:
push:
branches:
- 3.x
pull_request:
branches:
- '*'

jobs:
testsuite-linux:
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
php-version: ['5.6', '7.4']
db-type: [mysql, pgsql, sqlite]
prefer-lowest: ['']
include:
- php-version: '5.6'
db-type: 'sqlite'
prefer-lowest: 'prefer-lowest'

services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres

steps:
- uses: actions/checkout@v2

- name: Setup Service
if: matrix.db-type == 'mysql'
run: |
sudo service mysql start
mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp;'
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl, pdo_${{ matrix.db-type }}
coverage: pcov

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

- name: Get date part for cache key
id: key-date
run: echo "::set-output name=date::$(date +'%Y-%m')"

- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}

- name: Composer install
run: |
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
composer update --prefer-lowest --prefer-stable
else
composer update
fi
- name: Run PHPUnit
run: |
if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then
export DB_URL='sqlite://./tests.sqlite'
fi
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then
export DB_URL='mysql://root:[email protected]/cakephp'
fi
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then
export DB_URL='postgres://postgres:[email protected]/postgres'
fi
if [[ ${{ matrix.php-version }} == '7.4' && ${{ matrix.db-type }} == 'mysql' ]]; then
vendor/bin/phpunit --coverage-clover=coverage.xml
else
vendor/bin/phpunit
fi
- name: Code Coverage Report
if: matrix.php-version == '7.4' && matrix.db-type == 'mysql'
uses: codecov/codecov-action@v1
51 changes: 0 additions & 51 deletions .travis.yml

This file was deleted.

3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"php": ">=5.6.0",
"cakephp/cakephp": "^3.7.0",
"cakephp/chronos": "^1.0.0",
"cakephp/plugin-installer": "^1.0.0",
"composer/composer": "^1.3.0",
"composer/composer": "^1.3 | ^2.0",
"jdorn/sql-formatter": "^1.2.0"
},
"require-dev": {
Expand Down
10 changes: 6 additions & 4 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Cake\Core\Plugin;
use Cake\Datasource\ConnectionManager;
use Cake\Log\Log;
use Cake\Routing\DispatcherFactory;
use Cake\Utility\Security;

require_once 'vendor/autoload.php';

Expand Down Expand Up @@ -87,12 +87,12 @@
]);

// Ensure default test connection is defined
if (!getenv('db_dsn')) {
putenv('db_dsn=sqlite://127.0.0.1/' . TMP . 'debug_kit_test.sqlite');
if (!getenv('DB_URL')) {
putenv('DB_URL=sqlite://127.0.0.1/' . TMP . 'debug_kit_test.sqlite');
}

$config = [
'url' => getenv('db_dsn'),
'url' => getenv('DB_URL'),
'timezone' => 'UTC',
];

Expand All @@ -113,4 +113,6 @@
],
]);

Security::setSalt('a long random string that no one will ever guess');

Plugin::getCollection()->add(new \DebugKit\Plugin());

0 comments on commit ed9bbe4

Please sign in to comment.