diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..937faad --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,5 @@ +# See https://github.com/release-drafter/release-drafter#configuration +template: | + ## What’s Changed + + $CHANGES diff --git a/.github/workflows/bundler.yml b/.github/workflows/bundler.yml new file mode 100644 index 0000000..107fac9 --- /dev/null +++ b/.github/workflows/bundler.yml @@ -0,0 +1,43 @@ +name: Bundler + +on: create + +jobs: + autocommit: + name: Update to stable dependencies + if: startsWith(github.ref, 'refs/heads/release/') + runs-on: ubuntu-latest + container: + image: atk4/image:latest # https://github.com/atk4/image + steps: + - uses: actions/checkout@master + - run: echo ${{ github.ref }} + - name: Update to stable dependencies + run: | + # replaces X keys with X-release keys + jq '. as $in | reduce (keys_unsorted[] | select(endswith("-release")|not)) as $k ({}; . + {($k) : (($k + "-release") as $kr | $in | if has($kr) then .[$kr] else .[$k] end) } )' < composer.json > tmp && mv tmp composer.json + v=$(echo ${{ github.ref }} | cut -d / -f 4) + echo "::set-env name=version::$v" + + - uses: teaminkling/autocommit@master + with: + commit-message: Setting release dependencies + - uses: ad-m/github-push-action@master + with: + branch: ${{ github.ref }} + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: pull-request + uses: romaninsh/pull-request@master + with: + source_branch: "release/${{ env.version }}" + destination_branch: "master" # If blank, default: master + pr_title: "Releasing ${{ env.version }} into master" + pr_body: | + - [ ] Review changes (must include stable dependencies) + - [ ] Merge this PR into master (will delete ${{ github.ref }}) + - [ ] Go to Releases and create TAG from master + Do not merge master into develop + pr_reviewer: "romaninsh" + pr_assignee: "romaninsh" + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..68fcd9a --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,16 @@ +name: Release Drafter + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - develop + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: toolmantim/release-drafter@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000..cf671a3 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,50 @@ +name: Unit Testing + +on: + pull_request: + branches: '*' + push: + branches: + - master + - develop + +jobs: + unit-test: + name: Unit Testing + runs-on: ubuntu-latest + container: + image: atk4/image:${{ matrix.php }} # https://github.com/atk4/image + strategy: + matrix: + php: ['7.2', '7.3', 'latest'] + steps: + - uses: actions/checkout@v1 + # need this to trick composer + - run: php --version + - run: "git branch develop; git checkout develop" + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + + - uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('composer.json') }} + restore-keys: | + ${{ runner.os }}-composer- + + - run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader + + - name: Run Tests + run: | + mkdir -p build/logs + + - name: SQLite Testing + run: vendor/bin/phpunit --configuration phpunit.xml --coverage-text + + - uses: codecov/codecov-action@v1 + if: matrix.php == 'latest' + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: build/logs/clover.xml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..865320b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,20 @@ +# Change Log + +## [1.0.0](https://github.com/atk4/chart/tree/1.0.0) (2019-03-01) + +[Full Changelog](https://github.com/atk4/chart/compare/09fd17a39a808f84b05f75a0222814eb82c0b05e...1.0.0) + +**Closed issues:** + +- Composer didn't update to 4b593ed34af271af3dea054f2a2dc2dc69592383 [\#5](https://github.com/atk4/chart/issues/5) + +**Merged pull requests:** + +- show "no data" in label if there is no data [\#4](https://github.com/atk4/chart/pull/4) ([DarkSide666](https://github.com/DarkSide666)) +- fix options [\#3](https://github.com/atk4/chart/pull/3) ([DarkSide666](https://github.com/DarkSide666)) +- bugfix [\#2](https://github.com/atk4/chart/pull/2) ([DarkSide666](https://github.com/DarkSide666)) +- add descriptions, add withCurrencyY [\#1](https://github.com/atk4/chart/pull/1) ([DarkSide666](https://github.com/DarkSide666)) + + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/composer.json b/composer.json index e7cbe89..b1d86b5 100644 --- a/composer.json +++ b/composer.json @@ -1,21 +1,39 @@ { - "name": "atk4/chart", - "type": "library", - "description": "ChartJS for Agile UI", - "keywords": ["agile", "data", "framework", "chart", "chartjs"], - "homepage": "http://agiletoolkit.org/", - "license": "MIT", - "authors": [ - { - "name": "Romans Malinovskis", - "email": "romans@agiletoolkit.org", - "homepage": "https://nearly.guru/" - } - ], - "require": { - "atk4/ui": "dev-develop|*" - }, - "autoload": { - "psr-4": {"atk4\\chart\\":"src/"} + "name": "atk4/chart", + "type": "library", + "description": "ChartJS for Agile UI", + "keywords": [ + "agile", + "data", + "framework", + "chart", + "chartjs" + ], + "homepage": "http://agiletoolkit.org/", + "license": "MIT", + "minimum-stability": "dev", + "prefer-stable": true, + "authors": [ + { + "name": "Romans Malinovskis", + "email": "romans@agiletoolkit.org", + "homepage": "https://nearly.guru/" } + ], + "require": { + "atk4/ui": "^2.0" + }, + "require-dev": { + "phpunit/phpunit": "<6" + }, + "autoload": { + "psr-4": { + "atk4\\chart\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "atk4\\chart\\tests\\": "tests/" + } + } } diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..8e1406d --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,21 @@ + + + + + + + ./vendor + + + ./src + + + + + tests + + + + + + diff --git a/src/Chart.php b/src/Chart.php index 64d4ce8..c9f1ee6 100644 --- a/src/Chart.php +++ b/src/Chart.php @@ -153,7 +153,7 @@ public function setModel(\atk4\data\Model $model, $columns = []) { $colors = array_shift($this->nice_colors); $this->dataSets[$column] = [ - 'label'=>$model->getElement($column)->getCaption(), + 'label'=>$model->getField($column)->getCaption(), 'backgroundColor'=>$colors[0], 'borderColor'=>$colors[1], 'borderWidth'=>1, diff --git a/src/PieChart.php b/src/PieChart.php index a692c47..48585c4 100644 --- a/src/PieChart.php +++ b/src/PieChart.php @@ -69,7 +69,7 @@ public function setModel(\atk4\data\Model $model, $columns = []) * * @return $this */ - public function withCurrency($char = '€') + public function withCurrency($char = '€', $axis='y') { $options['tooltips'] = [ //'enabled' => true, diff --git a/tests/.keep b/tests/.keep new file mode 100644 index 0000000..e69de29 diff --git a/tests/BasicTest.php b/tests/BasicTest.php new file mode 100644 index 0000000..a837fc0 --- /dev/null +++ b/tests/BasicTest.php @@ -0,0 +1,15 @@ +assertEquals('foo', 'foo'); + } + +} diff --git a/tools/release.sh b/tools/release.sh new file mode 100755 index 0000000..002437e --- /dev/null +++ b/tools/release.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +set -e + +product=$(basename $PWD) + + +check=$(git symbolic-ref HEAD | cut -d / -f3) +if [ $check != "develop" ]; then + echo "Must be on develop branch" + exit -1 +fi + +# So that we can see un-committed stuff +git status + +# Display list of recently released versions +git fetch --tags +git log --tags --simplify-by-decoration --pretty="format:%d - %cr" | head -n5 + +echo "Which version we are releasing: " +read version + +function finish { + git checkout develop + git branch -D release/$version + git checkout composer.json +} +trap finish EXIT + +# Create temporary branch (local only) +git branch release/$version +git checkout release/$version + +# Find out previous version +prev_version=$(git log --tags --simplify-by-decoration --pretty="format:%d" | grep -Eo '[0-9\.A-Z-]+' | head -1) + +echo "Releasing $prev_version -> $version" + +gcg --future-release $version --unreleased false +vimr CHANGELOG.md + +# Compute diffs +#git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative $prev_version... + +#git log --pretty=full $prev_version... | grep '#[0-9]*' | sed 's/.*#\([0-9]*\).*/\1/' | sort | uniq | while read i; do + #echo "-[ $i ]-------------------------------------------------------------------------------" + #ghi --color show $i | head -50 +#done + +#open "https://github.com/atk4/$product/compare/$prev_version...develop" + +# Update dependency versions +sed -i "" -e '/atk4.*dev-develop/d' composer.json +composer update +composer require atk4/ui + +composer update +./vendor/phpunit/phpunit/phpunit --no-coverage + +echo "Press enter to publish the release" +read junk + +git commit -m "Added release notes for $version" CHANGELOG.md || echo "but its ok" +merge_tag=$(git rev-parse HEAD) + +# use stable verisons +git commit -m "Set up stable dependencies for $version" composer.json + + +git tag $version +git push origin release/$version +git push --tags + +git checkout develop +git merge $merge_tag --no-edit +git push + +echo '=[ SUCCESS ]================================================' +echo "Released atk4/$product Version $version" +echo '============================================================' +echo + +open https://github.com/atk4/$product/releases/tag/$version + +# do we care about master branch? nah