Skip to content

Commit d70c33a

Browse files
authored
Improve contributor experience (#654)
* Add "configlet:fmt" command * Combine all CI tests to command "ci" * Install / update configlet with composer packages * Remove PHP 7.4 from 'composer.json' * Do not run composer scripts in CI
1 parent b3edb30 commit d70c33a

File tree

3 files changed

+46
-18
lines changed

3 files changed

+46
-18
lines changed

.github/workflows/exercise-lint-phpcs-psr-12.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,24 @@ on:
1010
jobs:
1111
test:
1212
name: PHPCS Linting - ${{ github.event_name }}
13-
runs-on: ubuntu-22.04
13+
runs-on: ${{ matrix.os }}
1414
strategy:
1515
fail-fast: false
16+
matrix:
17+
php-version: [8.2]
18+
os: [ubuntu-22.04]
1619

1720
steps:
1821
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
1922

2023
- uses: shivammathur/setup-php@a4e22b60bbb9c1021113f2860347b0759f66fe5d
2124
with:
22-
php-version: '8.2'
25+
php-version: ${{ matrix.php-version }}
2326
extensions: gmp
2427
tools: composer
2528

26-
- name: Install dependencies
27-
shell: bash
28-
run: |
29-
curl -Lo bin/phpcs.phar https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
30-
chmod +x bin/phpcs.phar
31-
3229
- name: Install composer packages
33-
run: composer install
30+
run: composer install --no-scripts
3431

3532
- name: Lint exercises
3633
shell: bash

README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,24 @@ To solve the exercises, head to the [PHP track][exercism-track-home] and check t
1010
The following system dependencies are required:
1111

1212
- `composer`, as recommended in the [PHP track installation docs][exercism-track-installation-composer].
13-
- [`bash` shell][gnu-bash]
14-
- PHP V8.2+ CLI
13+
- [`bash` shell][gnu-bash].
14+
- PHP V8.2+ CLI.
15+
- An active Internet connection for installing required tools / composer packages.
1516

16-
Run the following commands to get started with this project:
17+
Run the following command to get started with this project:
1718

1819
```shell
19-
bin/fetch-configlet # The official tool for managing Exercism language track repositories
2020
composer install # Required dependencies to develop this track
2121
```
2222

2323
## Running Exercism resources management
2424

25-
`bin/configlet` is a tool to manage exercism resources in this track.
25+
`bin/configlet` is the official tool for managing Exercism language track repositories.
2626
See [Building Exercism docs][exercism-configlet].
2727

28+
For convenience, you can use `composer configlet:fmt` to fix formatting issues in the Exercism track files.
29+
This is included in `composer ci` to run the CI checks locally.
30+
2831
## Running Unit Test Suite
2932

3033
The tests are run with PHPUnit. A shell loop injecting `exemplar.php` is provided to ease testing.
@@ -35,22 +38,27 @@ Execute the following command to run the tests:
3538
composer test:run
3639
```
3740

41+
This is included in `composer ci` to run the CI checks locally.
42+
3843
## Running Style Checker
3944

40-
This project use a slightly [modified][local-file-phpcs-config] version of [PSR-12].
45+
This project uses a slightly [modified][local-file-phpcs-config] version of [PSR-12].
4146
Use the following commands to apply code style:
4247

4348
```shell
4449
composer lint:check # Checks the files against the code style rules
45-
composer lint:fix # Automatically fix codestyle issues
50+
composer lint:fix # Automatically fix code style issues
4651
```
4752

53+
The `lint:check` is included in `composer ci` to run the CI checks locally.
54+
4855
## Contributing
4956

5057
- Read the documentation at [Exercism][exercism-docs].
5158
- Follow the [PSR-12] coding style (Exercisms PHP track uses a slightly [modified][local-file-phpcs-config] version of [PSR-12]).
59+
- Run `composer ci` to run CI checks locally before pushing.
5260
- CI is run on all pull requests, it must pass the required checks for merge.
53-
- CI is running all tests on PHP 8.0 to PHP 8.2
61+
- CI is running all tests on PHP 8.0 to PHP 8.2 for Linux, Windows and MacOS.
5462

5563
## Generating new practice exercises
5664

composer.json

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,35 @@
1010
}
1111
},
1212
"require-dev": {
13-
"php": "^7.4 || ^8.0",
13+
"php": "^8.0",
1414
"phpunit/phpunit": "^9.6 || ^10.5",
1515
"slevomat/coding-standard": "^8.14.1",
1616
"squizlabs/php_codesniffer": "^3.9"
1717
},
1818
"scripts": {
19+
"post-install-cmd": [
20+
"@tool:configlet:fetch"
21+
],
22+
"post-update-cmd": [
23+
"@tool:configlet:update"
24+
],
25+
"ci": [
26+
"@configlet:fmt",
27+
"@lint:check",
28+
"@tests:run"
29+
],
30+
"tool:configlet:fetch": "[ -x bin/configlet ] || bin/fetch-configlet",
31+
"tool:configlet:update": [
32+
"rm bin/configlet || true",
33+
"bin/fetch-configlet"
34+
],
35+
"configlet:fmt": [
36+
"bin/configlet fmt"
37+
],
38+
"format:fix": [
39+
"@lint:fix",
40+
"@configlet:fmt"
41+
],
1942
"lint:check": "phpcs",
2043
"lint:fix": "phpcbf",
2144
"tests:run": "PHPUNIT_BIN='phpunit' bin/test.sh"

0 commit comments

Comments
 (0)