Skip to content

Commit

Permalink
chore(dev): Makefile to run project commands more easily
Browse files Browse the repository at this point in the history
Let's make it easy to run `phpcs`, `phpcbf`, `phpunit` ...

Refs #104 maybe?
  • Loading branch information
xurizaemon committed Jul 8, 2023
1 parent 965e77f commit c95d26e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 9 deletions.
8 changes: 8 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ Changelog:
echo -e "⚠️\e[93m (or an explanatory comment in MR if it's not CHANGELOG-worthy)"
exit 1
Makefile:
image: registry.gitlab.com/behat-chrome/docker-chrome-headless
stage: lint
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
script:
- make --dry-run test_make

GrumPHP:
image: composer
stage: lint
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
## Unreleased
* Error handling for invalid form values (#140)
* Introduce code coverage in CI (!154, !160)
* Add `make` commands for development tasks (!159)

## 2.9.2

Expand Down
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.PHONY: container install phpcbf phpcs test test_make

docker_run=docker run --rm -t -v .:/code -e DOCROOT=/code/vendor/mink/driver-testsuite/web-fixtures registry.gitlab.com/behat-chrome/docker-chrome-headless

# This is used to validate the makefile by calling each command with `-n`.
test_make: container install phpcs phpcbf test

container:
$(docker_run) bash

install:
$(docker_run) composer install --no-interaction

phpcbf: install
$(docker_run) vendor/bin/phpcbf

phpcs: install
$(docker_run) vendor/bin/phpcs

test: install
$(docker_run) bash -c "sleep 3 && vendor/bin/phpunit"
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,31 @@ Contributions are welcome! Use the [issue queue and merge requests to propose ch

## Tests

To run tests locally:
The project has test coverage, which you can execute using the commands below.

```bash
cd chrome-mink-driver
docker run --rm -it -v $(pwd):/code -e DOCROOT=/code/vendor/mink/driver-testsuite/web-fixtures registry.gitlab.com/behat-chrome/docker-chrome-headless bash
```
Test execution requires a webserver configured to serve fixtures from [minkphp/driver-testsuite](https://github.com/minkphp/driver-testsuite/), which is provided by a docker image from the related [behat-chrome/docker-chrome-headless](https://gitlab.com/behat-chrome/docker-chrome-headless/) project. Tests executed are both [tests specific to this driver](https://gitlab.com/behat-chrome/chrome-mink-driver/-/tree/main/tests) and the more comprehensive test suite from [mink/driver-testsuite](https://github.com/minkphp/driver-testsuite/), which is the common testsuite to ensure consistency across Mink driver implementations.

Then in the shell:
### Using `make`

```bash
| command | purpose |
|--|--|
| `make install` | Install dependencies with `composer` |
| `make test` | Run tests with `phpunit` |
| `make phpcbf` | Tidy code using `phpcbf` |
| `make phpcs` | Check coding standards with `phpcs` |

### Without `make`

To perform these tasks without `make`, you can execute the same commands as above in a container. To run the tests using `phpunit`:
```text
docker run --rm -it -v .:/code -e DOCROOT=/code/vendor/mink/driver-testsuite/web-fixtures registry.gitlab.com/behat-chrome/docker-chrome-headless bash
```
then, in the container shell:
```text
composer install
vendor/bin/phpunit
```

This will execute both [tests specific to this driver](https://gitlab.com/behat-chrome/chrome-mink-driver/-/tree/main/tests) and the more comprehensive test suite from [mink/driver-testsuite](https://github.com/minkphp/driver-testsuite/), which is the common testsuite to ensure consistency across Mink driver implementations.

## Versioning & releases

- Releases are distributed through Packagist at https://packagist.org/packages/dmore/chrome-mink-driver
Expand Down

0 comments on commit c95d26e

Please sign in to comment.