-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overhaul tool usage in CI and for contribution (#591)
- Loading branch information
Showing
12 changed files
with
94 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,61 @@ | ||
# 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 | ||
|
||
Follow these instructions to contribute to the PHP track. | ||
To solve the exercises, head to the [PHP track][exercism-track-home] and check the [documentation][exercism-track-installation]. | ||
|
||
## Install Dependencies | ||
|
||
### All dependencies | ||
The following system dependencies are required: | ||
|
||
```shell | ||
> ./bin/install.sh | ||
``` | ||
- `composer`, as recommended in the [PHP track installation docs][exercism-track-installation-composer]. | ||
- [`bash` shell][gnu-bash] | ||
|
||
### Only tests dependencies | ||
Run the following commands to get started with this project: | ||
|
||
```shell | ||
> ./bin/install-phpunit-9.sh | ||
bin/fetch-configlet # The official tool for managing Exercism language track repositories | ||
composer install # Required dependencies to develop this track | ||
``` | ||
|
||
### Only style-check dependencies | ||
## Running Exercism resources management | ||
|
||
```shell | ||
> ./bin/install-phpcs.sh | ||
``` | ||
`bin/configlet` is a tool to manage exercism resources in this track. | ||
See [Building Exercism docs][exercism-configlet]. | ||
|
||
## Running Unit Test Suite | ||
|
||
### PHPUnit 9 | ||
The tests are run with PHPUnit. A shell loop injecting `exemplar.php` is provided to ease testing. | ||
|
||
Execute the following command to run the tests: | ||
|
||
```shell | ||
> PHPUNIT_BIN="./bin/phpunit-9.phar" ./bin/test.sh | ||
composer test:run | ||
``` | ||
|
||
## Running Style Checker | ||
|
||
### PSR-12 rules | ||
This project use a slightly [modified][local-file-phpcs-config] version of [PSR-12]. | ||
Use the following commands to apply code style: | ||
|
||
```shell | ||
> PHPCS_BIN="./bin/phpcs.phar" PHPCS_RULES="./phpcs-php.xml" ./bin/lint.sh | ||
composer lint:check # Checks the files against the code style rules | ||
composer lint:fix # Automatically fix codestyle issues | ||
``` | ||
|
||
## Contributing | ||
|
||
- Read the documentation at [Exercism][docs]. | ||
- Follow the [PSR-12] coding style (PHP uses a slightly [modified] version of [PSR-12]). | ||
- Read the documentation at [Exercism][exercism-docs]. | ||
- Follow the [PSR-12] coding style (Exercisms PHP track uses a slightly [modified][local-file-phpcs-config] 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 | ||
|
||
[exercism-configlet]: https://exercism.org/docs/building/configlet | ||
[exercism-docs]: https://exercism.org/docs | ||
[exercism-track-home]: https://exercism.org/docs/tracks/php | ||
[exercism-track-installation]: https://exercism.org/docs/tracks/php/installation | ||
[exercism-track-installation-composer]: https://exercism.org/docs/tracks/php/installation#h-install-composer | ||
[gnu-bash]: https://www.gnu.org/software/bash/ | ||
[local-file-phpcs-config]: phpcs.xml | ||
[psr-12]: https://www.php-fig.org/psr/psr-12 | ||
[docs]: https://exercism.org/docs | ||
[@group annotation]: https://phpunit.de/manual/4.1/en/appendixes.annotations.html#appendixes.annotations.group | ||
[modified]: phpcs-php.xml |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,4 +34,3 @@ public function canLiberate( | |
); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,4 +46,3 @@ public function pair( | |
HEART; | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0"?> | ||
<ruleset | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd" | ||
name="Exercism PHP Coding Standard" | ||
> | ||
<description>Coding standard for Exercism PHP exercises</description> | ||
|
||
<!-- Expect all files are UTF-8 --> | ||
<arg name="encoding" value="utf-8" /> | ||
|
||
<!-- No warnings (ignore them) --> | ||
<arg value="n" /> | ||
|
||
<!-- Show sniffs (it's easy to find solutions knowing the code) --> | ||
<arg value="s" /> | ||
|
||
<!-- A TAB is 4 chars wide (does not replace them, for calculation only!) --> | ||
<arg name="tab-width" value="4" /> | ||
|
||
<!-- Run on 60 files in parallel --> | ||
<arg name="parallel" value="60" /> | ||
|
||
<file>exercises</file> | ||
<file>src</file> | ||
|
||
<!-- Include all sniffs in the PSR12 standard except... --> | ||
<rule ref="PSR12"> | ||
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" /> | ||
<exclude name="PSR1.Classes.ClassDeclaration.MultipleClasses" /> | ||
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" /> | ||
</rule> | ||
<rule ref="Squiz.Scope.MethodScope.Missing"> | ||
<exclude-pattern>*/concept/city-office/*</exclude-pattern> | ||
<exclude-pattern>*/concept/windowing-system/*</exclude-pattern> | ||
</rule> | ||
<rule ref="vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/TypeHints/DeclareStrictTypesSniff.php"> | ||
<exclude-pattern>*/.meta/*\.php</exclude-pattern> | ||
<exclude-pattern>*/concept/*</exclude-pattern> | ||
<exclude-pattern>*/hello-world/*</exclude-pattern> | ||
<properties> | ||
<property name="linesCountBeforeDeclare" value="1" /> | ||
<property name="linesCountAfterDeclare" value="1" /> | ||
<property name="spacesCountAroundEqualsSign" value="0" /> | ||
</properties> | ||
</rule> | ||
<rule ref="src/Sniffs/ExplainStrictTypesSniff.php"> | ||
<exclude-pattern>*/*Test\.php</exclude-pattern> | ||
<exclude-pattern>*/.meta/*\.php</exclude-pattern> | ||
<exclude-pattern>src/*</exclude-pattern> | ||
</rule> | ||
</ruleset> |