Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Commit

Permalink
Feature/support 2.1 (#35)
Browse files Browse the repository at this point in the history
* wip

* tests

* Update release-drafter.yml

* Update unit-tests.yml

* fix

* fix

* wip

* fix

* cs

* cs

* proper db name

* Update unit-tests.yml
  • Loading branch information
DarkSide666 authored Jun 18, 2020
1 parent 88602ba commit 53d3f8b
Show file tree
Hide file tree
Showing 24 changed files with 565 additions and 423 deletions.
11 changes: 8 additions & 3 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# See https://github.com/release-drafter/release-drafter#configuration
categories:
- title: 'Enhancements'
- title: "Breaking Changes"
labels:
- enhancement
- "BC-break"
- title: "Major Features"
labels:
- "MAJOR"
- title: "Documentation enhancements"
labels:
- "Documentation :books:"
template: |
## What’s Changed
Expand Down
100 changes: 69 additions & 31 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,108 @@ name: Unit Testing

on:
pull_request:
branches: '*'
branches: '**'
push:
branches:
- master
- develop
branches: '**'
schedule:
- cron: '0 * * * *'

jobs:
unit-test:
name: Unit Testing
name: Unit
runs-on: ubuntu-latest
container:
image: atk4/image:${{ matrix.php }} # https://github.com/atk4/image
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', 'latest']
type: ['Phpunit']
include:
- php: 'latest'
type: 'CodingStyle'
env:
LOG_COVERAGE: "${{ fromJSON('{true: \"1\", false: \"\"}')[matrix.php == 'latest' && matrix.type == 'Phpunit' && (github.event_name == 'pull_request' || (github.event_name == 'push' && (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master')))] }}"
services:
mysql:
image: mysql:5.7
image: mariadb:10.5.1
env:
MYSQL_ROOT_PASSWORD: password
DB_DATABASE: db
MYSQL_ROOT_PASSWORD: atk4_pass
MYSQL_USER: atk4_test
MYSQL_PASSWORD: atk4_pass
MYSQL_DATABASE: atk4_test__report
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
postgres:
image: postgres:10-alpine
image: postgres:12-alpine
env:
POSTGRES_PASSWORD: password
POSTGRES_USER: postgres
POSTGRES_USER: atk4_test
POSTGRES_PASSWORD: atk4_pass
POSTGRES_DB: atk4_test__report
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v2
- run: php --version
# Need this to trick composer
# - run: "git branch develop; git checkout develop"
- name: Get Composer Cache Directory
- name: Checkout
uses: actions/checkout@v2

- name: Configure PHP
run: |
if [ -z "$LOG_COVERAGE" ]; then rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini ; fi
php --version
# trick composer that this is a "atk4/data:develop" dependency to install atk4/schema
- name: Rename HEAD to develop for Composer
run: git switch -C develop HEAD

- name: Setup cache 1/2
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v1
- name: Setup cache 2/2
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }}
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.type }}-${{ hashFiles('composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: Install PHP dependencies
run: |
if [ "${{ matrix.type }}" != "Phpunit" ]; then composer remove --no-interaction --no-update phpunit/phpunit phpunit/dbunit phpunit/phpcov --dev ; fi
if [ "${{ matrix.type }}" != "CodingStyle" ]; then composer remove --no-interaction --no-update friendsofphp/php-cs-fixer --dev ; fi
composer install --no-suggest --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader
- name: Run Tests
- name: Init
run: |
mkdir -p build/logs
mysql -uroot -ppassword -h mysql -e 'CREATE DATABASE db;'
PGPASSWORD=password psql -h postgres -c 'create database "atk4-db";' -U postgres
- name: SQLite Testing
run: vendor/bin/phpunit --configuration phpunit.xml --coverage-text --exclude-group dns || echo 'ignoring errors..'
- name: MySQL Testing
run: vendor/bin/phpunit --configuration phpunit-mysql-workflow.xml --exclude-group dns
- name: "Run tests: SQLite (only for Phpunit)"
if: matrix.type == 'Phpunit'
run: "vendor/bin/phpunit \"$(if [ -n \"$LOG_COVERAGE\" ]; then echo '--coverage-text'; else echo '--no-coverage'; fi)\" -v"

- name: "Run tests: MySQL (only for Phpunit)"
if: matrix.type == 'Phpunit'
run: "vendor/bin/phpunit --configuration phpunit-mysql.xml.dist \"$(if [ -n \"$LOG_COVERAGE\" ]; then echo '--coverage-text'; else echo '--no-coverage'; fi)\" -v"

- name: "Run tests: PostgreSQL (expected errors) (only for Phpunit)"
if: matrix.type == 'Phpunit'
continue-on-error: true
run: "vendor/bin/phpunit --configuration phpunit-pgsql.xml.dist \"$(if [ -n \"$LOG_COVERAGE\" ]; then echo '--coverage-text'; else echo '--no-coverage'; fi)\" -v"

- name: Lint / check syntax (only for CodingStyle)
if: matrix.type == 'CodingStyle'
run: find . \( -type d \( -path './vendor/*' \) \) -prune -o ! -type d -name '*.php' -print0 | xargs -0 -n1 php -l

- name: PgSQL Testing (expected errors)
run: vendor/bin/phpunit --configuration phpunit-pgsql-workflow.xml --exclude-group dns || echo 'ignoring errors..'
- name: Check Coding Style (only for CodingStyle)
if: matrix.type == 'CodingStyle'
run: vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --diff --diff-format=udiff --verbose --show-progress=dots

- name: Merge coverage logs
run: vendor/bin/phpcov merge build/logs/ --clover build/logs/cc.xml;
- name: Upload coverage logs 1/2 (only for "latest" Phpunit)
if: env.LOG_COVERAGE
run: vendor/bin/phpcov merge build/logs/ --clover build/logs/cc.xml

- uses: codecov/codecov-action@v1
- name: Upload coverage logs 2/2 (only for "latest" Phpunit)
if: env.LOG_COVERAGE
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: build/logs/cc.xml
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
docs/build
/composer.lock
/build
/vendor
/composer.lock
.idea
nbproject
.DS_Store

local
*.local
*.local.*
cache
*.cache
*.cache.*

/phpunit.xml
/phpunit-*.xml
63 changes: 63 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in([__DIR__])
->exclude([
'cache',
'build',
'vendor',
]);

return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' =>true,
'@PHP71Migration:risky' => true,

// required by PSR-12
'concat_space' => [
'spacing' => 'one',
],

// disable some too strict rules
'phpdoc_types_order' => [
'null_adjustment' => 'always_last',
'sort_algorithm' => 'none',
],
'single_line_throw' => false,
'yoda_style' => [
'equal' => false,
'identical' => false,
],
'native_function_invocation' => false,
'non_printable_character' => [
'use_escape_sequences_in_strings' => true,
],
'void_return' => false,
'combine_consecutive_issets' => false,
'combine_consecutive_unsets' => false,
'multiline_whitespace_before_semicolons' => false,
'no_superfluous_elseif' => false,
'ordered_class_elements' => false,
'php_unit_internal_class' => false,
'php_unit_test_case_static_method_calls' => [
'call_type' => 'this',
],
'php_unit_test_class_requires_covers' => false,
'phpdoc_add_missing_param_annotation' => false,
'return_assignment' => false,
'comment_to_phpdoc' => false,
'general_phpdoc_annotation_remove' => [
'annotations' => ['author', 'copyright', 'throws'],
],
'nullable_type_declaration_for_default_null_value' => [
'use_nullable_type_declaration' => false,
],

// @TODO fix later
'strict_comparison' => false,
'php_unit_strict' => false,
])
->setFinder($finder)
->setCacheFile(__DIR__ . '/.php_cs.cache');
3 changes: 0 additions & 3 deletions CHANGES.md

This file was deleted.

11 changes: 11 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ignore:
- docs
comment: false
coverage:
status:
project:
default:
target: auto
threshold: 0.1
patch: false
changes: false
21 changes: 14 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,28 @@
],
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true
},
"require": {
"php": ">=7.2.0",
"atk4/data": "dev-develop",
"atk4/schema": "dev-develop"
"atk4/data": "dev-develop"
},
"require-release": {
"php": ">=7.2.0",
"atk4/data": "^2.0",
"atk4/schema": "^2.0"
"atk4/data": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "<6",
"phpunit/dbunit": ">=1.2",
"atk4/schema": "dev-develop",
"friendsofphp/php-cs-fixer": "^2.16",
"phpunit/phpcov": "*",
"phpunit/phpunit": "*"
},
"require-dev-release": {
"atk4/schema": "^2.0",
"friendsofphp/php-cs-fixer": "^2.16",
"phpunit/phpcov": "*",
"codeclimate/php-test-reporter": "*"
"phpunit/phpunit": "*"
},
"autoload": {
"psr-4": {
Expand Down
24 changes: 0 additions & 24 deletions phpunit-mysql-workflow.xml

This file was deleted.

24 changes: 0 additions & 24 deletions phpunit-mysql.xml

This file was deleted.

21 changes: 21 additions & 0 deletions phpunit-mysql.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<phpunit colors="true" bootstrap="vendor/autoload.php" printerClass="atk4\core\AtkPhpunit\ResultPrinter">
<php>
<var name="DB_DSN" value="mysql:dbname=atk4_test__report;host=mysql" />
<var name="DB_USER" value="atk4_test" />
<var name="DB_PASSWD" value="atk4_pass" />
<var name="DB_DBNAME" value="atk4_test__report" />
</php>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="tests">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-php" target="build/logs/clover-mysql.cov"/>
</logging>
</phpunit>
21 changes: 21 additions & 0 deletions phpunit-pgsql.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<phpunit colors="true" bootstrap="vendor/autoload.php" printerClass="atk4\core\AtkPhpunit\ResultPrinter">
<php>
<var name="DB_DSN" value="pgsql:dbname=atk4_test__report;host=postgres" />
<var name="DB_USER" value="atk4_test" />
<var name="DB_PASSWD" value="atk4_pass" />
<var name="DB_DBNAME" value="atk4_test__report" />
</php>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="tests">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-php" target="build/logs/clover-pgsql.cov"/>
</logging>
</phpunit>
Loading

0 comments on commit 53d3f8b

Please sign in to comment.