Skip to content

Commit

Permalink
[update] makefile + code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
TangoMan75 committed Nov 25, 2018
1 parent 712e4e7 commit a56f599
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 73 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,9 @@ Temporary Items

composer.lock

# =========================
# PHPUnit
# =========================

/coverage

15 changes: 4 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,14 @@ cache:
directories:
- $HOME/.composer/cache/files

php:
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- nightly

# Matrix to test in every php version
matrix:
# Fast finish allows to set the build as "finished" even if the "allow_failures" matrix elements are not finished yet.
fast_finish: true
include:
- php: 7.2
- php: nightly
allow_failures:
- php: 5.5
- php: 5.6
- php: nightly

# Install composer dependencies
Expand All @@ -32,4 +25,4 @@ install:

# Run script
script:
- php -d memory-limit=-1 ./vendor/symfony/phpunit-bridge/bin/simple-phpunit
- ./vendor/bin/simple-phpunit
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGELOG
=========

### 2018-11-25
- Updated Makefile
- phpunit.xml.dist whitelist bug
- gitignore /coverage
- Updated README
- Updated travis

### 2018-10-10
- Travis continuous integration

Expand Down
123 changes: 62 additions & 61 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,91 +1,92 @@

# Run "make" to print help
# If you want to add a help message for your rule, just add : "## My help for this rule", on the previous line
# You can give "make" arguments with this syntax: PARAMETER=VALUE

.PHONY: help
.PHONY: help tests coverage composer-install uninstall

# Colors
COLOR_TITLE = \033[1;41m
COLOR_CAPTION = \033[1;44m
COLOR_BOLD = \033[1;34m
COLOR_LABEL = \033[1;32m
COLOR_DANGER = \033[31m
COLOR_SUCCESS = \033[32m
COLOR_WARNING = \033[33m
COLOR_SECONDARY = \033[34m
COLOR_INFO = \033[35m
COLOR_PRIMARY = \033[36m
COLOR_DEFAULT = \033[0m

# Date / Time
DATE=$(shell date -I)
DATETIME=$(shell date '+%Y-%m-%d %H:%M:%S')
TIME=$(shell date -Ins)
TIMESTAMP=$(shell date +%Y%m%d%H%M%S)
EPOCH=$(shell date +%s)
DAY=$(shell LANG=C date +%A)

# Local vars
ifeq (${OS}, Windows_NT)
SYSTEM=${OS}
else
SYSTEM=$(shell uname -s)
endif

WHOAMI=$(shell whoami)

BASEDIR=$(shell basename `git rev-parse --show-toplevel 2>/dev/null` 2>/dev/null)
# get lastest tag from git repository
VERSION=$(shell echo `git describe --exact-match --abbrev=0 2>/dev/null`)

# parameters (usage parameter=value)
parameter?=''
COLOR_TITLE = \033[1;41m
COLOR_CAPTION = \033[1;44m
COLOR_LABEL = \033[1;32m
COLOR_WARNING = \033[33m
COLOR_INFO = \033[35m
COLOR_PRIMARY = \033[36m
COLOR_DEFAULT = \033[0m

# get correct console executable
CONSOLE=$(shell if [ -f ./app/console ]; then echo './app/console'; elif [ -f ./bin/console ]; then echo './bin/console'; fi)
# get correct public folder
PUBLIC=$(shell if [ -d ./web ]; then echo './web'; elif [ -d ./public ]; then echo './public'; else echo './'; fi)

## Print this help
help:
@printf "${COLOR_TITLE}TangoMan ${BASEDIR} ${VERSION}${COLOR_DEFAULT}\n\n"

@printf "${COLOR_PRIMARY} date:${COLOR_DEFAULT} ${COLOR_INFO}${DATETIME}${COLOR_DEFAULT}\n"
@printf "${COLOR_PRIMARY} login:${COLOR_DEFAULT} ${COLOR_INFO}${WHOAMI}${COLOR_DEFAULT}\n"
@printf "${COLOR_PRIMARY} system:${COLOR_DEFAULT} ${COLOR_INFO}${SYSTEM}${COLOR_DEFAULT}\n\n"
@printf "${COLOR_TITLE}TangoMan $(shell basename ${CURDIR}) ${COLOR_DEFAULT}\n\n"
@printf "${COLOR_PRIMARY} date:${COLOR_DEFAULT} ${COLOR_INFO}$(shell date '+%Y-%m-%d %H:%M:%S')${COLOR_DEFAULT}\n"
@printf "${COLOR_PRIMARY} login:${COLOR_DEFAULT} ${COLOR_INFO}$(shell whoami)${COLOR_DEFAULT}\n"
@printf "${COLOR_PRIMARY} system:${COLOR_DEFAULT} ${COLOR_INFO}$(shell uname -s)${COLOR_DEFAULT}\n\n"

@printf "${COLOR_CAPTION}description:${COLOR_DEFAULT}\n\n"
@printf "$(COLOR_WARNING) Callback Symfony Twig Extension Bundle${COLOR_DEFAULT}\n\n"

@printf "${COLOR_CAPTION}Usage:${COLOR_DEFAULT}\n\n"
@printf "$(COLOR_WARNING) make tests${COLOR_DEFAULT}\n\n"
@printf "$(COLOR_WARNING) make test${COLOR_DEFAULT}\n\n"

@printf "${COLOR_CAPTION}Available commands:${COLOR_DEFAULT}\n\n"
@awk '/^### .+$$/ { printf "\n${COLOR_BOLD}%s${COLOR_DEFAULT}\n", substr($$0, 5) } \
/^[a-zA-Z\-\_0-9\@]+:/ { \
@awk '/^[a-zA-Z\-\_0-9\@]+:/ { \
HELP_LINE = match(LAST_LINE, /^## (.*)/); \
HELP_COMMAND = substr($$1, 0, index($$1, ":")); \
HELP_MESSAGE = substr(LAST_LINE, RSTART + 3, RLENGTH); \
printf " ${COLOR_LABEL}%-8s${COLOR_DEFAULT} ${COLOR_PRIMARY}%s${COLOR_DEFAULT}\n", HELP_COMMAND, HELP_MESSAGE; \
printf " ${COLOR_LABEL}%-16s${COLOR_DEFAULT} ${COLOR_PRIMARY}%s${COLOR_DEFAULT}\n", HELP_COMMAND, HELP_MESSAGE; \
} \
{ LAST_LINE = $$0 }' ${MAKEFILE_LIST}

## Run test suite
tests: update run

## Update composer dependencies
update:
## Run tests
tests:
@if [ ! -d ./vendor ]; then \
make --no-print-directory composer-install; \
fi
@if [ -x ./bin/phpunit ]; then \
php -d memory-limit=-1 ./bin/phpunit --stop-on-failure; \
elif [ -x ./vendor/bin/phpunit ]; then \
bash ./vendor/bin/phpunit --stop-on-failure; \
elif [ -x ./vendor/bin/simple-phpunit ]; then \
php -d memory-limit=-1 ./vendor/bin/simple-phpunit --stop-on-failure; \
else \
printf 'error: phpunit executable not found\n'; \
exit 1; \
fi

## Dump coverage (requires XDebug)
coverage:
@if [ ! -d ./vendor ]; then \
make --no-print-directory composer-install; \
fi
@if [ -x ./bin/phpunit ]; then \
php -d memory-limit=-1 ./bin/phpunit --coverage-html ${PUBLIC}/coverage; \
elif [ -x ./vendor/bin/phpunit ]; then \
bash ./vendor/bin/phpunit --coverage-html ${PUBLIC}/coverage; \
elif [ -x ./vendor/bin/simple-phpunit ]; then \
php -d memory-limit=-1 ./vendor/bin/simple-phpunit --coverage-html ${PUBLIC}/coverage; \
else \
printf 'error: phpunit executable not found\n'; \
exit 1; \
fi
ifeq (${OS}, Windows_NT)
composer update
@start "${PUBLIC}/coverage/index.html"
else
php -d memory_limit=-1 `which composer` update
@nohup xdg-open "${PUBLIC}/coverage/index.html" >/dev/null 2>&1
endif

## Run test suite
run:
## Composer install Symfony project
composer-install:
ifeq (${OS}, Windows_NT)
php -d memory_limit=-1 ./vendor/symfony/phpunit-bridge/bin/simple-phpunit --stop-on-failure
composer install
else
php -d memory_limit=-1 ./vendor/bin/simple-phpunit --stop-on-failure
php -d memory-limit=-1 $(shell which composer) install
endif

## Delete vendors
clean:
rm -rf /vendor
rm -f composer.lock
## Remove vendors, var/cache, var/logs & var/sessions
uninstall:
rm -f ./composer.lock
rm -rf ./coverage
rm -rf ./vendor
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ $ make tests

On windows machine you will need to install [cygwin](http://www.cygwin.com/) or [GnuWin make](http://gnuwin32.sourceforge.net/packages/make.htm) first to execute make script.

If you have XDebug installed, you can generate code coverage report with:
```bash
$ make coverage
```

Note
====

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tangoman/callback-bundle",
"description": "Callback Symfony Twig Extension Bundle",
"version": "2.1.2",
"version": "2.2.0",
"license": "MIT",
"type": "library",
"keywords": [
Expand Down
8 changes: 8 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@
<directory>Tests/</directory>
</testsuite>
</testsuites>

<!-- whitelist is mandatory as of PHPUnit 5.0
https://github.com/sebastianbergmann/phpunit-documentation/issues/335 -->
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./TwigExtension/</directory>
</whitelist>
</filter>
</phpunit>

0 comments on commit a56f599

Please sign in to comment.