diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..dd13e1f --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,48 @@ +# Contributing + +## Quick Guide + +1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local machine. +2. Install the dependencies (`composer install --dev`) +3. Create a new branch (`git checkout -b feat/new-feature`) +4. Write your feature or fix and make sure tests pass and code standards are met (see below) +5. Commit your changes (`git commit -m 'feat(new-feature): some feature or fix'`) +6. Push to the branch (`git push origin feat/new-feature`) +7. Open a pull request + +## Working with Docker 🐳 + +This project provides a Docker setup that allows working on it using any of the supported PHP versions. + +To use it, you first need to install: + +* [Docker](https://docs.docker.com/get-docker/) +* [Docker Compose](https://docs.docker.com/compose/install/) + +Make sure the versions installed support [Compose file format 3.9](https://docs.docker.com/compose/compose-file/). + +You can then build the images: + +```console +docker compose up --build -d +``` + +Now you can run commands needed to work on the project. For example, say you want to install the dependencies on PHP 8.0: + +```console +docker-compose run codice-fiscale-php-80 composer install +``` + +or for enter the container + +```console +docker-compose exec codice-fiscale-php-80 sh +``` + +## Testing + +To run the test use the command below: + +```bash +composer test +``` diff --git a/README-it.md b/README-it.md index d6c15a3..375f073 100644 --- a/README-it.md +++ b/README-it.md @@ -334,7 +334,7 @@ Test ---- ``` bash -$ vendor\bin\phpunit +$ composer test ``` diff --git a/README.md b/README.md index d35bf16..eabfa6e 100644 --- a/README.md +++ b/README.md @@ -334,7 +334,7 @@ Test ---- ``` bash -$ vendor\bin\phpunit +$ composer test ``` diff --git a/composer.json b/composer.json index 7e39779..02cb155 100644 --- a/composer.json +++ b/composer.json @@ -34,5 +34,11 @@ "name": "davidepastore", "email": "pasdavide@gmail.com" } - ] + ], + "config": { + "sort-packages": true + }, + "scripts": { + "test": "vendor/bin/phpunit" + } } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..17220ce --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +version: '3.9' + +services: + codice-fiscale-71: + build: docker/php-7.1 + container_name: codice-fiscale-php-71 + working_dir: /app + tty: true + volumes: + - .:/app:cached + + codice-fiscale-80: + build: docker/php-8.0 + container_name: codice-fiscale-php-80 + working_dir: /app + tty: true + volumes: + - .:/app:cached diff --git a/docker/php-7.1/Dockerfile b/docker/php-7.1/Dockerfile new file mode 100644 index 0000000..e5cdb53 --- /dev/null +++ b/docker/php-7.1/Dockerfile @@ -0,0 +1,3 @@ +FROM php:7.1-alpine3.9 + +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer diff --git a/docker/php-8.0/Dockerfile b/docker/php-8.0/Dockerfile new file mode 100644 index 0000000..4459c8b --- /dev/null +++ b/docker/php-8.0/Dockerfile @@ -0,0 +1,3 @@ +FROM php:8.0-cli-alpine3.16 + +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d9374b7..029c218 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,7 +2,7 @@ - + ./test @@ -11,4 +11,4 @@ ./src - \ No newline at end of file +