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

Code quality and tests #18

Merged
merged 15 commits into from
Sep 22, 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: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
; top-most EditorConfig file
root = true

# All files.
[*]
end_of_line = LF
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
13 changes: 13 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Ignore all test and documentation with "export-ignore".
/.editorconfig export-ignore
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/phpcs.xml.dist export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml.dist export-ignore
/tests export-ignore
31 changes: 31 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Contributing

Contributions are **welcome** and will be fully **credited**. We accept contributions via Pull Requests on [GitHub](https://github.com/dflydev/dflydev-dot-access-data).

## Pull Requests

- **[PSR-12 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md)** - The easiest way to apply the conventions is to run `./vendor/bin/phpcbf`.

- **Add tests!** - Your patch won't be accepted if it doesn't have tests.

- **Tests must pass** - All automated tests, including things like code style checks, but be passing before we'll consider merging the change.

- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.

- **Create feature branches** - Don't ask us to pull from your default branch.

- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.

- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.


## Running Tests

``` bash
$ composer test
```


**Happy coding**!
100 changes: 100 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Tests

on:
push: ~
pull_request: ~

jobs:
phpcs:
name: PHPCS
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: shivammathur/setup-php@v2
with:
php-version: 7.1
extensions: curl, mbstring
coverage: none
tools: composer:v2, cs2pr

- run: composer update --no-progress

- run: vendor/bin/phpcs -q --report=checkstyle | cs2pr

phpunit:
name: PHPUnit on ${{ matrix.php }} ${{ matrix.composer-flags }}
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.2', '7.3', '7.4']
coverage: [pcov]
composer-flags: ['']
include:
- php: '7.1'
coverage: xdebug
composer-flags: ''
- php: '8.0'
coverage: false
composer-flags: '--ignore-platform-req=php'

steps:
- uses: actions/checkout@v2

- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: curl
coverage: ${{ matrix.coverage }}
tools: composer:v2

- run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: "Use PHPUnit 9.3+ on PHP 8"
run: composer require --no-update --dev phpunit/phpunit:^9.3
if: "matrix.php == '8.0'"

- run: composer update --no-progress ${{ matrix.composer-flags }}

- run: vendor/bin/phpunit --no-coverage
if: ${{ matrix.coverage == 'none' }}

- run: vendor/bin/phpunit --coverage-text
if: ${{ matrix.coverage != 'none' }}

phpstan:
name: PHPStan
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: shivammathur/setup-php@v2
with:
php-version: 7.1
extensions: curl
coverage: none
tools: composer:v2

- run: composer update --no-progress

- run: vendor/bin/phpstan analyse --no-progress

psalm:
name: Psalm
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: shivammathur/setup-php@v2
with:
php-version: 7.1
extensions: curl
coverage: none
tools: composer:v2

- run: composer update --no-progress

- run: vendor/bin/psalm --no-progress --output-format=github
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
.phpcs-cache
.phpunit.result.cache
composer.lock
phpcs.xml
phpstan.neon
phpunit.xml
psalm.xml
vendor
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Given a deep data structure, access data by dot notation.
Requirements
------------

* PHP (7.0+)
* PHP (7.1+)

> For PHP (5.3+) please refer to version `1.0`.

Expand Down
19 changes: 17 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
}
],
"require": {
"php": "^7.0"
"php": "^7.1 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
"phpstan/phpstan": "^0.12.42",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.3",
"squizlabs/php_codesniffer": "^3.5",
"vimeo/psalm": "^3.14"
},
"autoload": {
"psr-4": {
Expand All @@ -42,5 +45,17 @@
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"scripts": {
"phpcs": "phpcs",
"phpstan": "phpstan analyse",
"phpunit": "phpunit --no-coverage",
"psalm": "psalm",
"test": [
"@phpcs",
"@phpstan",
"@psalm",
"@phpunit"
]
}
}
17 changes: 17 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<ruleset>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>

<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>

<!-- Directories to be checked -->
<file>src</file>
<file>tests</file>

<rule ref="PSR12"/>
</ruleset>
4 changes: 4 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: max
paths:
- src
11 changes: 10 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true">
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Dot Access Data Test Suite">
<directory>./tests</directory>
Expand Down
16 changes: 16 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
errorLevel="3"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
Loading