diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1ec20dd..c134a57 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,16 +1,22 @@ --- fail_fast: false repos: - - repo: https://github.com/digitalpulp/pre-commit-php - rev: 1.3.0 + - repo: local hooks: - id: php-cbf + name: Fix php code with php-cbf + language: system + entry: phpcbf verbose: true stages: [manual] types: [php] - - repo: https://github.com/digitalpulp/pre-commit-php - rev: 1.3.0 + args: [-n] + - repo: local hooks: - id: php-cs + name: Check php code style with php-cs + language: system + entry: phpcs verbose: true types: [php] + args: [-n] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ffd7383 --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +# Makefile for petzi/docker-pre-commit-php +# Make targets to help in the development of this docker image + +.DEFAULT_GOAL := help + +# Docker configuration +DOCKER=docker +# Docker build configuration +DOCKER_TAG=petzi/pre-commit-php + +# Docker run configuration for the main image +DOCKER_VOL=-v "${PWD}:/src" +DOCKER_WD=-w "/src" +DOCKER_RUN_TEST=$(DOCKER) run --rm $(DOCKER_VOL) $(DOCKER_WD) + +# The help command is inspired by this post: +# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html +.PHONY: help +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +.PHONY: build +build: ## Build the images on development + $(DOCKER) build -t $(DOCKER_TAG) . + +.PHONY: test +test: ## Run each image once to test the build result + $(DOCKER_RUN_TEST) $(DOCKER_TAG) --all-files + +.PHONY: test-php-cbf +test-php-cbf: ## Run php-cbf on all files + $(DOCKER_RUN_TEST) $(DOCKER_TAG) --all-files --hook-stage=manual php-cbf diff --git a/test/test.php b/test/test.php new file mode 100644 index 0000000..1781d23 --- /dev/null +++ b/test/test.php @@ -0,0 +1,13 @@ + + * @license https://github.com/petzich/docker-pre-commit-php/blob/master/LICENSE MIT + * @link None + * */ +echo "hello world"; + +?>