Skip to content

Commit

Permalink
Ported cakephp github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
othercorey committed Jun 27, 2020
1 parent c63dcec commit 3387700
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 60 deletions.
159 changes: 159 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,159 @@
name: Phinx CI

on:
push:
branches:
- master
pull_request:
branches:
- '*'

jobs:
testsuite:
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
php-version: ['7.2', '7.4']
db-type: [sqlite, mysql, pgsql]
name: PHP ${{ matrix.php-version }} & ${{ matrix.db-type }}

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

steps:
- name: Setup MySQL
if: matrix.db-type == 'mysql'
run: |
if [[ ${{ matrix.php-version }} == '7.2' ]]; then
sudo service mysql stop
# MySQL 8
docker run --rm --name=mysqld -e MYSQL_ROOT_PASSWORD=root --tmpfs /var/lib/mysql:rw --network=host -d mysql --default-authentication-plugin=mysql_native_password --disable-log-bin --innodb-flush-method=O_DIRECT_NO_FSYNC
else
# MySQL 5.7
sudo service mysql start
fi
- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
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') }}

- name: composer install
run: composer install

- name: Configure PHPUnit matcher
if: matrix.php-version == '7.4' && matrix.db-type == 'mysql'
uses: mheap/phpunit-matcher-action@master

- name: Run PHPUnit
run: |
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE phinx;'; fi
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then psql -c 'CREATE DATABASE phinx;' postgresql://postgres:postgres@127.0.0.1; fi
if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export SQLITE_DSN='sqlite:///phinx'; fi
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export MYSQL_DSN='mysql://root:root@127.0.0.1/phinx'; fi
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export PGSQL_DSN='pgsql://postgres:postgres@127.0.0.1/phinx'; fi
if [[ ${{ matrix.php-version }} == '7.2' ]]; then
vendor/bin/phpunit
elif [[ ${{ matrix.php-version }} == '7.4' && ${{ matrix.db-type }} == 'mysql' ]]; then
vendor/bin/phpunit --teamcity --verbose
else
vendor/bin/phpunit --verbose
fi
coding-standard:
name: Coding Standard
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
coverage: none

- 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') }}

- name: composer install
run: composer install

- name: Run PHP CodeSniffer
run: composer cs-check

static-analysis:
name: Static Analysis
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.2'
coverage: none
tools: cs2pr

- 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') }}

- name: composer install
run: composer stan-setup

- name: Run phpstan
run: vendor/bin/phpstan.phar analyse src/ --error-format=checkstyle | cs2pr
42 changes: 0 additions & 42 deletions .github/workflows/mysql8.yml

This file was deleted.

10 changes: 5 additions & 5 deletions .travis.yml
Expand Up @@ -17,9 +17,9 @@ env:
global:
- CODECOVERAGE=1
matrix:
- PGSQL_DSN='pgsql://postgres@127.0.0.1/phinx_testing'
- MYSQL_DSN='mysql://root@127.0.0.1/phinx_testing' MYSQL_UNIX_SOCKET='/var/run/mysqld/mysqld.sock'
- SQLITE_DSN='sqlite:///phinx_testing'
- PGSQL_DSN='pgsql://postgres@127.0.0.1/phinx'
- MYSQL_DSN='mysql://root@127.0.0.1/phinx' MYSQL_UNIX_SOCKET='/var/run/mysqld/mysqld.sock'
- SQLITE_DSN='sqlite:///phinx'

matrix:
include:
Expand All @@ -30,8 +30,8 @@ matrix:
env: CHECKS=1 CODECOVERAGE=0

before_install:
- if [[ $MYSQL_DSN ]]; then mysql -e 'create database phinx_testing;'; fi
- if [[ $PGSQL_DSN ]]; then psql -c 'create database phinx_testing;' -U postgres; fi
- if [[ $MYSQL_DSN ]]; then mysql -e 'create database phinx;'; fi
- if [[ $PGSQL_DSN ]]; then psql -c 'create database phinx;' -U postgres; fi
- if [[ $PGSQL_DSN ]]; then psql -c 'create extension if not exists citext;' -U postgres; fi

- |
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -60,8 +60,8 @@
"@test",
"@cs-check"
],
"cs-check": "phpcs --colors -p -n --standard=vendor/cakephp/cakephp-codesniffer/CakePHP --ignore=/tests/Phinx/Config/_rootDirectories/,/tests/log/ src/ tests/ app/",
"cs-fix": "phpcbf --colors -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP --ignore=/tests/Phinx/Config/_rootDirectories/,/tests/log/ src/ tests/ app/",
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"stan": "phpstan analyse src/",
"stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:^0.12 && mv composer.backup composer.json",
"test": "phpunit --colors=always"
Expand Down
13 changes: 13 additions & 0 deletions phpcs.xml
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<ruleset name="Phinx">
<config name="installed_paths" value="../../cakephp/cakephp-codesniffer" />

<file>app</file>
<file>src</file>
<file>tests</file>

<arg name="colors"/>
<arg value="np"/>

<rule ref="CakePHP" />
</ruleset>
8 changes: 0 additions & 8 deletions phpcs.xml.dist

This file was deleted.

6 changes: 3 additions & 3 deletions tests/Phinx/Db/Adapter/MysqlAdapterTest.php
Expand Up @@ -460,7 +460,7 @@ public function testCreateTableWithUnsignedNamedPK()

public function testCreateTableWithSchema()
{
$table = new \Phinx\Db\Table('phinx_testing.ntable', [], $this->adapter);
$table = new \Phinx\Db\Table('phinx.ntable', [], $this->adapter);
$table->addColumn('realname', 'string')
->addColumn('email', 'integer')
->save();
Expand Down Expand Up @@ -1436,8 +1436,8 @@ public function testsHasForeignKeyWithSchemaDotTableName()
->addForeignKey(['ref_table_id'], 'ref_table', ['id'])
->save();

$this->assertTrue($this->adapter->hasForeignKey('phinx_testing.' . $table->getName(), ['ref_table_id']));
$this->assertFalse($this->adapter->hasForeignKey('phinx_testing.' . $table->getName(), ['ref_table_id2']));
$this->assertTrue($this->adapter->hasForeignKey('phinx.' . $table->getName(), ['ref_table_id']));
$this->assertFalse($this->adapter->hasForeignKey('phinx.' . $table->getName(), ['ref_table_id2']));
}

public function testHasDatabase()
Expand Down

0 comments on commit 3387700

Please sign in to comment.