Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
christeredvartsen committed Nov 14, 2021
2 parents 01db017 + 95a93fd commit a82b939
Show file tree
Hide file tree
Showing 40 changed files with 1,135 additions and 671 deletions.
21 changes: 5 additions & 16 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,16 @@ Behat API Extension has both [Behat](http://docs.behat.org/) and [PHPUnit](https

The Behat tests requires a web server hosting the `features/bootstrap/index.php` script. A quick and easy alternative is to use PHPs built in web server:

composer run dev --timeout=0

which is a composer script that simply runs:

php -S localhost:8080 -t ./features/bootstrap > server.log 2>&1

After this has been started you can execute the test suites by running:

composer test

If you want to run the suites separately they can be executed like this:

./vendor/bin/behat --strict
./vendor/bin/phpunit

PHPStan is used for static code analysis, and a composer script has been added to run this tool:

composer run sa

You can also run both test suites along with the static analysis with a single composer script:
Psalm is used for static code analysis:

composer run ci
vendor/bin/psalm

## Documentation

Expand All @@ -53,7 +41,8 @@ If the pull request is a bug fix, remember to file an issue in the issue tracker
/**
* @see https://github.com/imbo/behat-api-extension/issues/<issue number>
*/
public function testSomething
public function testSomething()
{
// ...
}
```
Expand All @@ -62,4 +51,4 @@ Please also specify which commit that resolves the bug by adding `Resolves #<iss

## Coding standards

Simply use the same coding standard already found in the PHP files in the project.
This library follows the [imbo/imbo-coding-standard](https://github.com/imbo/imbo-coding-standard) coding standard, and runs [php-cs-fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) as a step in the CI workflow.
20 changes: 12 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ jobs:
strategy:
matrix:
php: ['7.4', '8.0']
name: Validate, lint and test on PHP ${{ matrix.php }}
name: Validate and test on PHP ${{ matrix.php }}
steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: php-cs-fixer

- name: Debug PHP installation
run: |
Expand All @@ -24,9 +25,6 @@ jobs:
- name: Validate composer files
run: composer validate --strict

- name: Lint all PHP files
run: composer run lint

- name: Get Composer cache directory
id: composer-cache-dir
run: |
Expand All @@ -45,10 +43,16 @@ jobs:
run: composer install

- name: Start dev server
run: composer run dev --timeout=0 &
run: php -S localhost:8080 -t ./features/bootstrap > server.log 2>&1 &

- name: Run unit tests
run: vendor/bin/phpunit

- name: Run tests
run: composer run test
- name: Run integration tests
run: vendor/bin/behat --strict

- name: Run static code analysis
run: composer run sa
run: vendor/bin/psalm

- name: Check coding standard
run: php-cs-fixer fix --dry-run --diff
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ docs/_build
.idea
.phpunit.result.cache
.vscode
.php-cs-fixer.cache
11 changes: 11 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php declare(strict_types=1);
require 'vendor/autoload.php';

$finder = (new Symfony\Component\Finder\Finder())
->files()
->name('*.php')
->in(__DIR__)
->exclude('vendor');

return (new Imbo\CodingStandard\Config())
->setFinder($finder);
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog for Behat API Extension
=================================

v3.0.1
------
__TBA__

* [#106](https://github.com/imbo/behat-api-extension/issues/106): Adopt coding standard

v3.0.0
------
__2021-05-25__
Expand Down
17 changes: 3 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
},
"require-dev": {
"alexeyshockov/guzzle-psalm-plugin": "^0.3.1",
"imbo/imbo-coding-standard": "^2.0",
"phpunit/phpunit": "^9.5",
"psalm/plugin-phpunit": "^0.15.1",
"slim/psr7": "^1.3",
Expand All @@ -48,23 +49,11 @@
}
},
"scripts": {
"lint": "for file in `git ls-files '*php'`; do php -l $file; done",
"phpunit": "vendor/bin/phpunit",
"phpunit:coverage": "vendor/bin/phpunit --coverage-html build/coverage",
"behat": "vendor/bin/behat --strict",
"psalm": "vendor/bin/psalm",
"test": [
"@phpunit",
"@behat"
],
"sa": [
"@psalm"
],
"ci": [
"@lint",
"@test",
"@sa"
],
"sa": "vendor/bin/psalm",
"cs": "php-cs-fixer fix --dry-run --diff",
"dev": "php -S localhost:8080 -t ./features/bootstrap > server.log 2>&1",
"docs": "cd docs; make html"
},
Expand Down
56 changes: 54 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a82b939

Please sign in to comment.