From c9e310154b7b35785ec0debfd32b44e29ab86e72 Mon Sep 17 00:00:00 2001 From: Stephen Tallowitz Date: Tue, 14 May 2019 16:23:52 +0200 Subject: [PATCH 1/3] Add Makefile and test file --- Makefile | 32 ++++++++++++++++++++++++++++++++ test/test.php | 13 +++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 Makefile create mode 100644 test/test.php diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1ee7e8a --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +# Makefile for petzi/docker-pre-commit +# 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"; + +?> From cbde84f852a11625f157709e85b7e7782a3fdbd8 Mon Sep 17 00:00:00 2001 From: Stephen Tallowitz Date: Tue, 14 May 2019 16:25:22 +0200 Subject: [PATCH 2/3] Make pre-commit rules local --- .pre-commit-config.yaml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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] From a23199e5666e933ad3d2db9519c050d8705e6b90 Mon Sep 17 00:00:00 2001 From: Stephen Tallowitz Date: Tue, 14 May 2019 16:39:01 +0200 Subject: [PATCH 3/3] Fix typo --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1ee7e8a..ffd7383 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Makefile for petzi/docker-pre-commit +# Makefile for petzi/docker-pre-commit-php # Make targets to help in the development of this docker image .DEFAULT_GOAL := help