Skip to content

Commit

Permalink
Use phpunit from composer in contribution workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mk-mxp committed Dec 6, 2023
1 parent 8eb0ed0 commit 054d6e9
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 116 deletions.
49 changes: 28 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,60 @@
# Exercism PHP Track

![Configlet Status](https://github.com/exercism/php/workflows/Configlet%20CI/badge.svg)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/68242198cd124a3ebcbdc291d0e0eda4)](https://www.codacy.com/app/borgogelli/php?utm_source=github.com&utm_medium=referral&utm_content=borgogelli/php&utm_campaign=Badge_Grade)

Exercism exercises in PHP

## Install Dependencies
Follow these instructions, if you want to contribute to the track.
You must have a BASH shell to run the tooling locally.

### All dependencies
If you only want to solve the exercises, go to the [track docs][track-docs] and choose your installation option there.

```shell
> ./bin/install.sh
```
## Install Dependencies

### Only tests dependencies
You must have installed `composer` as a global tool as recommended in the [PHP track installation docs][composer-installation-docs].

```shell
> ./bin/install-phpunit-9.sh
bin/fetch-configlet
composer install
```

### Only style-check dependencies
You now have all tools required to contribute.

```shell
> ./bin/install-phpcs.sh
```
## Running Exercism resources management

`bin/configlet` is a tool to manage exercism resources in this track.
See [Building Exercism docs][configlet-docs].

## Running Unit Test Suite

### PHPUnit 9
We use PHPUnit 9.6.x and a shell loop injecting `exemplar.php` as the solution for testing:

```shell
> PHPUNIT_BIN="./bin/phpunit-9.phar" ./bin/test.sh
composer test:run
```

## Running Style Checker

### PSR-12 rules
We apply PSR-12 rules with minor tweaks and some exceptions:

```shell
> PHPCS_BIN="./bin/phpcs.phar" PHPCS_RULES="./phpcs-php.xml" ./bin/lint.sh
composer lint:check
```

To auto-fix the coding styles:

```shell
composer lint:fix
```

## Contributing

- Read the documentation at [Exercism][docs].
- Follow the [PSR-12] coding style (PHP uses a slightly [modified] version of [PSR-12]).
- Follow the [PSR-12] coding style (Exercisms PHP track uses a slightly [modified] version of [PSR-12]).
- CI is run on all pull requests, it must pass the required checks for merge.
- CI is running all tests on PHP 8.0 to PHP 8.2

[psr-12]: https://www.php-fig.org/psr/psr-12
[composer-installation-docs]: https://exercism.org/docs/tracks/php/installation#h-install-composer
[configlet-docs]: https://exercism.org/docs/building/configlet
[docs]: https://exercism.org/docs
[@group annotation]: https://phpunit.de/manual/4.1/en/appendixes.annotations.html#appendixes.annotations.group
[modified]: phpcs-php.xml
[psr-12]: https://www.php-fig.org/psr/psr-12
[track-docs]: https://exercism.org/docs/tracks/php/installation
6 changes: 0 additions & 6 deletions bin/install-phpcs.sh

This file was deleted.

6 changes: 0 additions & 6 deletions bin/install-phpunit-9.sh

This file was deleted.

6 changes: 0 additions & 6 deletions bin/install.sh

This file was deleted.

76 changes: 0 additions & 76 deletions bin/lint.sh

This file was deleted.

4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
},
"require-dev": {
"php": "^7.4|^8.0",
"phpunit/phpunit": "^9.6",
"slevomat/coding-standard": "^8.5",
"squizlabs/php_codesniffer": "^3.6"
},
"scripts": {
"lint:check": "phpcs --standard=phpcs-php.xml",
"lint:fix": "phpcbf --standard=phpcs-php.xml"
"lint:fix": "phpcbf --standard=phpcs-php.xml",
"tests:run": "PHPUNIT_BIN='phpunit' bin/test.sh"
}
}

0 comments on commit 054d6e9

Please sign in to comment.