Skip to content

Commit eddef82

Browse files
committed
add more useful standard build, add makefile
1 parent 19af3a8 commit eddef82

File tree

5 files changed

+75
-8
lines changed

5 files changed

+75
-8
lines changed

.docker/Dockerfile renamed to Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM php:8.3-cli
22

3+
WORKDIR /app
4+
35
ENV ANSIBLE_VERSION 2.9.17
46

57
# composer

Makefile

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Executables (local)
2+
DOCKER_COMP = docker compose
3+
4+
# Docker containers
5+
PHP_CONT = $(DOCKER_COMP) exec php-ansible
6+
7+
# Executables
8+
PHP = $(PHP_CONT) php
9+
COMPOSER = $(PHP_CONT) composer
10+
11+
# Misc
12+
.DEFAULT_GOAL = help
13+
14+
## —— php-ansible Makefile 🎵 ——————————————————————————————————
15+
help: ## Outputs this help screen
16+
@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/'
17+
18+
## —— Docker 🐳 ————————————————————————————————————————————————————————————————
19+
build: ## Builds the Docker images
20+
@$(DOCKER_COMP) build --pull --no-cache
21+
22+
up: ## Start the docker hub in detached mode (no logs)
23+
@$(DOCKER_COMP) up --detach
24+
25+
start: build up ## Build and start the containers
26+
27+
down: ## Stop the docker hub
28+
@$(DOCKER_COMP) down --remove-orphans
29+
30+
logs: ## Show live logs
31+
@$(DOCKER_COMP) logs --tail=0 --follow
32+
33+
sh: ## Connect to the php-fpm container
34+
@$(PHP_CONT) sh
35+
36+
bash: ## Connect to the php-fpm container via bash so up and down arrows go to previous commands
37+
@$(PHP_CONT) bash
38+
39+
test: ## Start tests with phpunit, pass the parameter "c=" to add options to phpunit, example: make test c="--group e2e --stop-on-failure"
40+
@$(eval c ?=)
41+
@$(PHP_CONT) vendor/bin/phpunit -c phpunit.xml.dist $(c)
42+
43+
analyze: ## Start analysis with phpstan, pass the parameter "c=" to add options to phpstan. Default config ist always used, example: make analyze c="--group e2e"
44+
@$(eval c ?=)
45+
@$(PHP_CONT) vendor/bin/phpstan --configuration=phpstan.neon $(c)
46+
47+
codestyle: ## Start codestyle analysis with phpcs, pass the parameter "c=" to add options to phpcs. Default config ist always used. Example: make codestyle c="--parallel=2"
48+
@$(eval c ?=)
49+
@$(PHP_CONT) vendor/bin/phpcs --standard=phpcs.xml.dist $(c)
50+
51+
codestyle-fix: ## Start codestyle analysis with phpcbf, pass the parameter "c=" to add options to phpcbf. Default config ist always used. Example: make codestyle c="--parallel=2"
52+
@$(eval c ?=)
53+
@$(PHP_CONT) vendor/bin/phpcbf --standard=phpcs.xml.dist $(c)
54+
55+
psalm: ## Start code analysis with psalm, pass the parameter "c=" to add options to psalm. Default config ist always used. Example: make codestyle c="--level=2"
56+
@$(eval c ?=)
57+
@$(DOCKER_COMP) exec -e APP_ENV=dev php vendor/bin/psalm --config=psalm.xml $(c)
58+
59+
## —— Composer 🧙 ——————————————————————————————————————————————————————————————
60+
composer: ## Run composer, pass the parameter "c=" to run a given command, example: make composer c='req phpstan/phpstan'
61+
@$(eval c ?=)
62+
@$(COMPOSER) $(c)
63+
64+
vendor: ## Install vendors according to the current composer.lock file
65+
vendor: c=install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction
66+
vendor: composer

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,10 @@ $ansible
164164

165165
## Development
166166

167-
You can use the provided docker image with ```docker compose up``` which uses a default php-cli docker image and ansible 2.x. See the ```.docker/Dockerfile``` for more info.
168-
169-
Composer install: ```docker exec -u <YOUR_UID> -w /var/php-ansible -it php-ansible composer install```
170-
171-
You can run code or the tests within the container: ```docker exec -u <YOUR_UID> -w /var/php-ansible -it php-ansible php ./vendor/bin/phpunit --testdox```
167+
You can use the provided docker image with ```make build``` which uses a default php-cli docker image and ansible 2.x. See the ```Dockerfile``` for more info.
168+
Start the container with ```make up```.
169+
Composer install: ```make vendor```
170+
You can run code or the tests within the container: ```make test c="--testdox"```
172171

173172
## Thank you for your contributions!
174173

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
php-ansible:
3-
build: ./.docker
3+
build: .
44
container_name: php-ansible
55
volumes:
6-
- ./:/var/php-ansible
6+
- ./:/app

psalm.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<psalm
33
errorLevel="2"
44
resolveFromConfigFile="1"
5-
phpVersion="8.0"
5+
phpVersion="8.3"
66
>
77
<projectFiles>
88
<directory name="Asm" />

0 commit comments

Comments
 (0)