Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support 2.1 #8

Merged
merged 6 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# See https://github.com/release-drafter/release-drafter#configuration
categories:
- title: "Breaking Changes"
labels:
- "BC-break"
- title: "Major Features"
labels:
- "MAJOR"
- title: "Documentation enhancements"
labels:
- "Documentation :books:"
template: |
## What’s Changed

Expand Down
72 changes: 53 additions & 19 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,83 @@ 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')))] }}"
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

- name: SQLite Testing
run: vendor/bin/phpunit --configuration phpunit.xml --coverage-text
- 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: 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: 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: 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
if: matrix.php == 'latest'
- 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/clover.xml
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');
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 Agile Toolkit Limited (UK)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
44 changes: 0 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,3 @@ offers a deep integration betwene Agile UI, Agile Data and
chartJS.

![demo](demo.png)

## Documentation

https://github.com/atk4/report/blob/develop/docs/index.md

## Real Usage Example

https://github.com/atk4/report/blob/develop/docs/full-example.md

## Installation

Add the following inside your `composer.json` file:

``` json
{
"require": {
"atk4/report": "dev-develop"
},
"repositories": [
{
"type": "package",
"package": {
"name": "atk4/report",
"version": "dev-develop",
"type": "package",
"source": {
"url": "[email protected]:atk4/report.git",
"type": "git",
"reference": "develop"
}
}
}
],
}
```


``` console
composer install
```

## Current Status

Report extension is currently under development.
11 changes: 11 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ignore:
- demo
comment: false
coverage:
status:
project:
default:
target: auto
threshold: 0.1
patch: false
changes: false
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,30 @@
"chart",
"chartjs"
],
"homepage": "http://agiletoolkit.org/",
"homepage": "https://github.com/atk4/chart",
"license": "MIT",
"minimum-stability": "dev",
"prefer-stable": true,
"authors": [
{
"name": "Romans Malinovskis",
"email": "[email protected]",
"homepage": "https://nearly.guru/"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true
},
"require": {
"atk4/ui": "dev-develop"
},
"require-release": {
"atk4/ui": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "<6"
"friendsofphp/php-cs-fixer": "^2.16",
"phpunit/phpcov": "*",
"phpunit/phpunit": "*"
},
"autoload": {
"psr-4": {
Expand Down
28 changes: 16 additions & 12 deletions demo/index.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
<?php

declare(strict_types=1);

require '../vendor/autoload.php';

use atk4\chart\ChartBox;
use atk4\chart\BarChart;
use atk4\chart\ChartBox;
use atk4\chart\PieChart;
use atk4\data\Model;
use atk4\data\Persistence\Array_;
use atk4\ui\App;
use atk4\ui\Columns;

$p = ['t'=>[
[ 'name'=>'January', 'sales'=>20000, 'purchases'=>10000, ],
[ 'name'=>'February', 'sales'=>23000, 'purchases'=>12000, ],
[ 'name'=>'March', 'sales'=>16000, 'purchases'=>11000, ],
[ 'name'=>'April', 'sales'=>14000, 'purchases'=>13000, ],
$p = ['t' => [
['name' => 'January', 'sales' => 20000, 'purchases' => 10000],
['name' => 'February', 'sales' => 23000, 'purchases' => 12000],
['name' => 'March', 'sales' => 16000, 'purchases' => 11000],
['name' => 'April', 'sales' => 14000, 'purchases' => 13000],
]];
$m = new Model(new Array_($p), 't');
$m->addFields(['name', 'sales', 'purchases', 'profit']);
$m->addHook('afterLoad', function($m) { $m['profit'] = $m['sales'] - $m['purchases']; });
$m->onHook($m::HOOK_AFTER_LOAD, function ($m) { $m->set('profit', $m->get('sales') - $m->get('purchases')); });
$app = new App('Chart Demo');
$app->initLayout('Centered');
$app->initLayout(\atk4\ui\Layout\Centered::class);

// Lets put your chart into a box:
$columns = $app->layout->add('Columns');
$cb = $columns->addColumn(8)->add(new ChartBox(['label'=>['Demo Bar Chart', 'icon'=>'book']]));
$columns = $app->layout->add(Columns::class);
$cb = $columns->addColumn(8)->add(new ChartBox(['label' => ['Demo Bar Chart', 'icon' => 'book']]));
$chart = $cb->add(new BarChart());
$chart->setModel($m, ['name', 'sales', 'purchases','profit']);
$chart->setModel($m, ['name', 'sales', 'purchases', 'profit']);
$chart->withCurrency('$');

// Tweak our chart to support currencies better

$cb = $columns->addColumn(8)->add(new ChartBox(['label'=>['Demo Pie Chart', 'icon'=>'book']]));
$cb = $columns->addColumn(8)->add(new ChartBox(['label' => ['Demo Pie Chart', 'icon' => 'book']]));
$chart = $cb->add(new PieChart());
$chart->setModel($m, ['name', 'profit']);
$chart->withCurrency('$');
14 changes: 7 additions & 7 deletions phpunit.xml → phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<phpunit colors="true" bootstrap="vendor/autoload.php" printerClass="atk4\core\PHPUnit_AgileResultPrinter">
<phpunit colors="true" bootstrap="vendor/autoload.php" printerClass="atk4\core\AtkPhpunit\ResultPrinter">
<php>
<env name="DSN" value="mysql://root:root@localhost/test3" />
<var name="DB_DSN" value="sqlite::memory:" />
<var name="DB_USER" value="" />
<var name="DB_PASSWD" value="" />
<var name="DB_DBNAME" value="" />
</php>
<filter>
<blacklist>
<directory suffix=".php">./vendor</directory>
</blacklist>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<testsuites>
Expand All @@ -16,6 +16,6 @@
</testsuite>
</testsuites>
<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="coverage-php" target="build/logs/clover.cov"/>
</logging>
</phpunit>
Loading