Skip to content

Commit

Permalink
Releasing 0.4 into master (#3)
Browse files Browse the repository at this point in the history
* Update README.md

* merge into develop

* Apply fixes from StyleCI

* should be master

* min php 7.0

* adds support for custom error messages

* update readme

* fix rule merging

* refactor validator again

* Apply fixes from StyleCI

* Update composer.json

* be careful

* Apply fixes from StyleCI

* update

* Create unit-tests.yml

* Create bundler.yml

* Create release-drafter.yml

* draft

* Setting release dependencies

Co-authored-by: Romans Malinovskis <me@nearly.guru>
Co-authored-by: Imants Horsts <DarkSide666@users.noreply.github.com>
Co-authored-by: GitHub Web Flow <noreply@github.com>
  • Loading branch information
4 people authored Feb 11, 2020
1 parent 5d3571f commit 7b12e57
Show file tree
Hide file tree
Showing 12 changed files with 272 additions and 99 deletions.
5 changes: 5 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# See https://github.com/release-drafter/release-drafter#configuration
template: |
## What’s Changed
$CHANGES
43 changes: 43 additions & 0 deletions .github/workflows/bundler.yml
Original file line number Diff line number Diff line change
@@ -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 }}
16 changes: 16 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -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 }}
50 changes: 50 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
language: php

php:
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'

Expand Down
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This is validator add-on for Agile Data (https://github.com/atk4/data).
It uses https://github.com/vlucas/valitron under the hood.


[![Build Status](https://travis-ci.org/atk4/validate.png?branch=master)](https://travis-ci.org/atk4/validate)
[![Build Status](https://travis-ci.org/atk4/validate.png?branch=develop)](https://travis-ci.org/atk4/validate)
[![Code Climate](https://codeclimate.com/github/atk4/validate/badges/gpa.svg)](https://codeclimate.com/github/atk4/validate)
[![StyleCI](https://styleci.io/repos/161695320/shield)](https://styleci.io/repos/161695320)
[![CodeCov](https://codecov.io/gh/atk4/validate/branch/develop/graph/badge.svg)](https://codecov.io/gh/atk4/validate)
Expand All @@ -31,14 +31,14 @@ $v = new \atk4\validate\Validator($model);

// set simple validation rule for one field
// ->rule($field, $rules)
$v->rule('name', ['required','lengthMin'=>3]);
$v->rule('name', [ 'required', ['lengthMin', 3] ]);

// set multiple validation rules in one shot
// ->rules($array_of_rules) // [field=>rules]
$v->rules([
'name' => ['required', 'lengthMin'=>3],
'age' => ['integer', 'min'=>0, 'max'=>99],
'tail_length' => ['integer', 'min'=>0],
'name' => ['required', ['lengthMin',3]],
'age' => ['integer', ['min',0], ['max',99]],
'tail_length' => ['integer', ['min',0]],
]);

// set validation rules based on value of another field
Expand All @@ -48,13 +48,18 @@ $v->if(['type'=>'dog'], [
'age' => ['required'],
'tail_length' => ['required'],
], [
'tail_length' => ['equals'=>''], // balls don't have tail
'tail_length' => [ ['equals',''] ], // balls don't have tail
]);

// you can also pass multiple conditions which will be treated as AND conditions
$v->if(['type'=>'dog', 'age'=>50], $rules_if_true, $rules_if_false);

// you can also set custom error message like this:
$v->rule('age', [ ['min', 3, 'message'=>'Common! {field} to small'] ]);
// and you will get this "Common! Age to small"
```

You can also pass callback instead of array of rules.
Callback receives these parameters $field, $value, $args, $data and should return true/false.

See `/tests` folder for more examples.
83 changes: 49 additions & 34 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,52 @@
{
"name": "atk4/validate",
"type": "library",
"description": "Agile Data - Validator add-on",
"keywords": ["framework", "orm", "query", "active record", "sql", "builder", "nosql", "mongodb", "mysql", "postgresql", "validator", "validate"],
"homepage": "https://github.com/atk4/validate",
"license": "MIT",
"authors": [
{
"name": "Romans Malinovskis",
"email": "romans@agiletoolkit.org",
"homepage": "https://nearly.guru/"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=7.0.0",
"atk4/data": "dev-develop",
"vlucas/valitron": "^1.4"
},
"require-dev": {
"atk4/schema": "dev-develop",
"phpunit/phpunit": "<6",
"phpunit/dbunit": ">=1.2",
"phpunit/phpcov": "*",
"codeclimate/php-test-reporter": "*"
},
"autoload": {
"psr-4": {"atk4\\validate\\":"src/"}
},
"autoload-dev": {
"psr-4": {
"atk4\\validate\\tests\\":"tests/"
}
"name": "atk4/validate",
"type": "library",
"description": "Agile Data - Validator add-on",
"keywords": [
"framework",
"orm",
"query",
"active record",
"sql",
"builder",
"nosql",
"mongodb",
"mysql",
"postgresql",
"validator",
"validate"
],
"homepage": "https://github.com/atk4/validate",
"license": "MIT",
"authors": [
{
"name": "Romans Malinovskis",
"email": "romans@agiletoolkit.org",
"homepage": "https://nearly.guru/"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=7.2.0",
"atk4/data": "^2.0",
"vlucas/valitron": "^1.4"
},
"require-dev": {
"atk4/schema": "^2.0",
"phpunit/phpunit": "<6",
"phpunit/dbunit": ">=1.2",
"phpunit/phpcov": "*",
"codeclimate/php-test-reporter": "*"
},
"autoload": {
"psr-4": {
"atk4\\validate\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"atk4\\validate\\tests\\": "tests/"
}
}
}
1 change: 0 additions & 1 deletion phpunit-mysql.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<testsuites>
<testsuite name="tests">
<directory>tests</directory>
<exclude>tests/smbo/lib</exclude>
</testsuite>
</testsuites>
<logging>
Expand Down
1 change: 0 additions & 1 deletion phpunit-pgsql.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<testsuites>
<testsuite name="tests">
<directory>tests</directory>
<exclude>tests/smbo/lib</exclude>
</testsuite>
</testsuites>
<logging>
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<testsuites>
<testsuite name="tests">
<directory>tests</directory>
<exclude>tests/smbo/lib</exclude>
</testsuite>
</testsuites>
<logging>
Expand Down
Loading

0 comments on commit 7b12e57

Please sign in to comment.