Skip to content

Commit

Permalink
Merge pull request #3 from petzich/develop
Browse files Browse the repository at this point in the history
Improvements - Makefile and internalise pre-commit rules
  • Loading branch information
devste authored May 14, 2019
2 parents 1665e08 + a23199e commit add63c8
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
14 changes: 10 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions test/test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* A (valid) test file for php-cs
*
* @category None
* @package None
* @author Test Author <[email protected]>
* @license https://github.com/petzich/docker-pre-commit-php/blob/master/LICENSE MIT
* @link None
* */
echo "hello world";

?>

0 comments on commit add63c8

Please sign in to comment.