Skip to content

Commit

Permalink
Option to install githooks, tests lints
Browse files Browse the repository at this point in the history
  • Loading branch information
gocom committed Jan 14, 2020
1 parent 89263c8 commit 525b562
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ process.
Requirements depend on how the tools are ran. Development tools can either be ran within Docker containers, or natively
on the host machine.

#### Running inside containers
#### Running inside container

When ran with Docker:

Expand Down Expand Up @@ -111,11 +111,11 @@ $ make
```

The above will setup the whole environment and reset and update dependencies if re-ran. If the container environment
has already been set up, you can re-run specific step, such as just the linter or tests:
has already been set up, you can re-run specific step, such as just the linter or unit tests:

```
$ make cs
$ make test
$ make unit
```

To see available steps:
Expand Down
46 changes: 29 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all build install cs csfix test unit static clean testall docs help
.PHONY: all build install cs csfix test unit static clean testall docs help githooks githooks-pre-push

IMAGE?=latest

Expand All @@ -15,28 +15,30 @@ build:
install:

ifeq ($(IMAGE),latest)
docker-compose run $(IMAGE) composer install
docker-compose run $(IMAGE) bash -c 'test -e vendor || composer install'
endif

update:
docker-compose run $(IMAGE) composer update

cs:
$(MAKE) install
docker-compose run $(IMAGE) composer cs

csfix:
$(MAKE) install
docker-compose run $(IMAGE) composer csfix

test:
@docker-compose run $(IMAGE) bash -c 'test -e vendor || composer install'
$(MAKE) install
docker-compose run $(IMAGE) composer test

unit:
@docker-compose run $(IMAGE) bash -c 'test -e vendor || composer install'
$(MAKE) install
docker-compose run $(IMAGE) composer test:unit

static:
@docker-compose run $(IMAGE) bash -c 'test -e vendor || composer install'
$(MAKE) install
docker-compose run $(IMAGE) composer test:static

clean:
Expand All @@ -53,6 +55,12 @@ testall:
docs:
docker-compose run phpdoc --template markdown

githooks:
echo "make githooks-pre-push" > .git/hooks/pre-push

githooks-pre-push:
@$(MAKE) test

help:
@echo "Run PHP-Textile test suite"
@echo ""
Expand All @@ -61,23 +69,27 @@ help:
@echo ""
@echo "Commands:"
@echo ""
@echo " make all Run all"
@echo " make help Display this message"
@echo ""
@echo " make all Build and run tests"
@echo ""
@echo " make build Build image"
@echo " make clean Reset Composer dependencies"
@echo " make install Install Composer dependencies"
@echo " make update Update Composer dependencies"
@echo ""
@echo " make build Build image"
@echo " make clean Reset Composer dependencies"
@echo " make install Install Composer dependencies"
@echo " make update Update Composer dependencies"
@echo " make cs Check code style"
@echo " make csfix Try to fix code style"
@echo ""
@echo " make cs Check code style"
@echo " make csfix Try to fix code style"
@echo " make test Run linter, static and unit tests"
@echo " make unit Run only unit tests"
@echo " make static Run only static tests"
@echo ""
@echo " make test Run static and unit tests"
@echo " make unit Run only unit tests"
@echo " make static Run only static tests"
@echo " make testall Run tests against each image"
@echo ""
@echo " make testall Run tests against each image"
@echo " make docs Generate API documentation"
@echo ""
@echo " make docs Generate API documentation"
@echo " make githooks Install git hooks"
@echo ""
@echo "Images:"
@echo ""
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
},
"scripts": {
"test": [
"@composer cs",
"@composer test:static",
"@composer test:unit"
],
Expand All @@ -45,7 +46,7 @@
"test:unit": "phpunit"
},
"scripts-descriptions": {
"test": "Run unit tests and static analysis.",
"test": "Check coding style, and run unit tests and static analysis.",
"cs": "Check coding style.",
"csfix": "Fix coding style issues.",
"test:static": "Run static analysis.",
Expand Down

0 comments on commit 525b562

Please sign in to comment.