Skip to content

Commit bd7a664

Browse files
committed
Switch to Github Actions for CI
1 parent da79b22 commit bd7a664

File tree

7 files changed

+112
-81
lines changed

7 files changed

+112
-81
lines changed

.gitattributes

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
.editorconfig export-ignore
33
.gitattributes export-ignore
44
.gitignore export-ignore
5+
.github export-ignore
56
phpunit.xml.dist export-ignore
6-
.travis.yml export-ignore
77
tests export-ignore
88
psalm.xml export-ignore
9-
psalm-baseline.xml export-ignore

.github/workflows/ci.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- '*'
10+
11+
jobs:
12+
testsuite:
13+
runs-on: ubuntu-18.04
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
php-version: ['7.4', '8.0']
18+
db-type: [mysql, pgsql]
19+
prefer-lowest: ['']
20+
include:
21+
- php-version: '7.2'
22+
db-type: 'sqlite'
23+
prefer-lowest: 'prefer-lowest'
24+
25+
services:
26+
postgres:
27+
image: postgres
28+
ports:
29+
- 5432:5432
30+
env:
31+
POSTGRES_PASSWORD: postgres
32+
33+
steps:
34+
- uses: actions/checkout@v2
35+
36+
- name: Setup Service
37+
if: matrix.db-type == 'mysql'
38+
run: |
39+
sudo service mysql start
40+
mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp;'
41+
42+
- name: Setup PHP
43+
uses: shivammathur/setup-php@v2
44+
with:
45+
php-version: ${{ matrix.php-version }}
46+
extensions: mbstring, intl, pdo_${{ matrix.db-type }}
47+
coverage: pcov
48+
49+
- name: Composer install
50+
run: |
51+
composer --version
52+
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
53+
composer update --prefer-lowest --prefer-stable
54+
else
55+
composer install
56+
fi
57+
58+
- name: Run PHPUnit
59+
run: |
60+
if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi
61+
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_URL='mysql://root:[email protected]/cakephp?init[]=SET sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"'; fi
62+
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:[email protected]/postgres'; fi
63+
64+
if [[ ${{ matrix.php-version }} == '7.4' && ${{ matrix.db-type }} == 'mysql' ]]; then
65+
vendor/bin/phpunit --coverage-clover=coverage.xml
66+
else
67+
vendor/bin/phpunit
68+
fi
69+
70+
- name: Code Coverage Report
71+
if: success() && matrix.php-version == '7.4' && matrix.db-type == 'mysql'
72+
uses: codecov/codecov-action@v2
73+
74+
cs-stan:
75+
name: Coding Standard & Static Analysis
76+
runs-on: ubuntu-18.04
77+
78+
steps:
79+
- uses: actions/checkout@v1
80+
with:
81+
fetch-depth: 1
82+
83+
- name: Setup PHP
84+
uses: shivammathur/setup-php@v2
85+
with:
86+
php-version: '7.4'
87+
extensions: mbstring, intl
88+
coverage: none
89+
tools: psalm:4.4, phpstan:1.0
90+
91+
- name: Composer Install
92+
run: composer require cakephp/cakephp-codesniffer:^4.2
93+
94+
- name: Run phpcs
95+
run: vendor/bin/phpcs --standard=CakePHP src/ tests/
96+
97+
- name: Run psalm
98+
if: success() || failure()
99+
run: psalm --output-format=github
100+
101+
- name: Run phpstan
102+
if: success() || failure()
103+
run: phpstan analyse src

.travis.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

psalm-baseline.xml

Lines changed: 0 additions & 12 deletions
This file was deleted.

psalm.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xmlns="https://getpsalm.org/schema/config"
66
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
7-
errorBaseline="psalm-baseline.xml"
87
>
98
<projectFiles>
109
<directory name="src" />

src/Model/Behavior/SequenceBehavior.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,12 @@ function ($connection) use ($table, $entity, $config, $scope, $direction) {
337337
$newOrder = $entity->get($orderField) + 1;
338338
}
339339

340+
/** @var \Cake\Datasource\EntityInterface|null $previousEntity */
340341
$previousEntity = $table->find()
341342
->where(array_merge($scope, [$orderField => $newOrder]))
342343
->first();
343344

344-
if (!empty($previousEntity)) {
345+
if ($previousEntity !== null) {
345346
$previousEntity->set($orderField, $oldOrder);
346347
if (!$table->save($previousEntity, ['atomic' => false, 'checkRules' => false])) {
347348
return false;
@@ -445,6 +446,7 @@ protected function _getOldValues(EntityInterface $entity): array
445446
}
446447

447448
if (count($fields) != count($values)) {
449+
/** @psalm-suppress PossiblyInvalidArgument */
448450
$primaryKey = $entity->get($this->_table->getPrimaryKey());
449451
$entity = $this->_table->get($primaryKey, ['fields' => $fields]);
450452
$values = $entity->extract($fields);

tests/bootstrap.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Test suite bootstrap for Sequence
66
*/
77

8+
use Cake\Core\Configure;
89
use Cake\Datasource\ConnectionManager;
910

1011
/*
@@ -36,3 +37,7 @@
3637
require dirname(__DIR__) . '/vendor/cakephp/cakephp/tests/bootstrap.php';
3738

3839
ConnectionManager::get('test')->getDriver()->enableAutoQuoting(true);
40+
41+
Configure::write('Error.ignoredDeprecationPaths', [
42+
'src/TestSuite/Fixture/FixtureInjector.php',
43+
]);

0 commit comments

Comments
 (0)