Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
vendor/
var/
.phpunit.cache/
coverage/
infection.log
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ARG PHP_IMAGE=php:8.2-cli

FROM ${PHP_IMAGE} as php

# Maj list paquet
RUN apt-get update \
&& apt-get install -y wget \
# Xdebug
&& pecl install xdebug-3.2.2 \
&& docker-php-ext-enable xdebug \
# zip
&& apt-get install -y zlib1g-dev libzip-dev \
&& docker-php-ext-install zip

# Composer
COPY --from=composer:2.2 /usr/bin/composer /usr/local/bin/composer

# clean
RUN rm -rf /var/lib/apt/lists/* \
&& apt-get clean

CMD tail -f /dev/null
39 changes: 35 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
composer:
docker-compose run composer install
# Greatly inspired by https://github.com/dunglas/symfony-docker Makefile

phpunit:
docker-compose run php vendor/bin/phpunit
.DEFAULT_GOAL = help
.PHONY: init build up start composer vendor test test-with-coverage infection

help: ## Outputs this help screen
@grep -E '(^[a-zA-Z0-9\./_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'


init: start vendor ## Build, start the container and install vendors

## —— Docker 🐳 ————————————————————————————————————————————————————————————————
build: ## Builds the Docker images
docker compose build --pull --no-cache

up: ## Start the docker hub in detached mode (no logs)
docker compose up --detach

start: build up ## Build and start the containers

## —— Composer 🧙 ——————————————————————————————————————————————————————————————
composer: ## Run composer, pass the parameter "c=" to run a given command, examples: make composer c='require --dev approvals/approval-tests:dev-Main', make composer c='require --dev infection/infection'
@$(eval c ?=)
docker compose exec php composer $(c)

vendor: ## Install vendors according to the current composer.lock file
vendor: c=install --prefer-dist --no-progress --no-interaction
vendor: composer

## —— Tools 🔧 —————————————————————————————————————————————————————————————————

test: ## Launch PHPUnit
docker-compose run php vendor/bin/phpunit

test-with-coverage: ## Launch PHPUnit and generate a coverage
docker-compose exec php vendor/bin/phpunit --coverage-html coverage
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ This is a simple php kata starter:

## How to use it:

- `make composer` to install dependencies
- `make phpunit` to run your tests
- `make init` to setup the project
- `make test` to run your tests
- `make test-with-coverage` to run your tests and generate code coverage

## Katas:

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"php": "^8.2"
},
"require-dev": {
"phpunit/phpunit": "^10.3"
"phpunit/phpunit": "^10.3",
"approvals/approval-tests": "dev-Main"
}
}
Loading