]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - Makefile
lint: remove unused tools
[github/shaarli/Shaarli.git] / Makefile
CommitLineData
2d97aa77 1# The personal, minimalist, super-fast, database free, bookmarking service.
559315ba 2# Makefile for PHP code analysis & testing, documentation and release generation
f3e89f50 3
00f98bda 4BIN = vendor/bin
a52e8435 5PHP_SOURCE = index.php application tests plugins
00f98bda 6
fc17813b 7all: static_analysis_summary check_permissions test
00f98bda 8
d6916040
V
9##
10# Docker test adapter
11#
12# Shaarli sources and vendored libraries are copied from a shared volume
13# to a user-owned directory to enable running tests as a non-root user.
14##
15docker_%:
16 rsync -az /shaarli/ ~/shaarli/
17 cd ~/shaarli && make $*
18
00f98bda
V
19##
20# PHP_CodeSniffer
00f98bda 21# Detects PHP syntax errors
00f98bda
V
22# Documentation (usage, output formatting):
23# - http://pear.php.net/manual/en/package.php.php-codesniffer.usage.php
24# - http://pear.php.net/manual/en/package.php.php-codesniffer.reporting.php
25##
26code_sniffer: code_sniffer_full
27
3e25f245
V
28### - errors filtered by coding standard: PEAR, PSR1, PSR2, Zend...
29PHPCS_%:
30 @$(BIN)/phpcs $(PHP_SOURCE) --report-full --report-width=200 --standard=$*
31
f3e89f50 32### - errors by Git author
00f98bda
V
33code_sniffer_blame:
34 @$(BIN)/phpcs $(PHP_SOURCE) --report-gitblame
35
f3e89f50 36### - all errors/warnings
00f98bda
V
37code_sniffer_full:
38 @$(BIN)/phpcs $(PHP_SOURCE) --report-full --report-width=200
39
f3e89f50 40### - errors grouped by kind
00f98bda
V
41code_sniffer_source:
42 @$(BIN)/phpcs $(PHP_SOURCE) --report-source || exit 0
43
fc17813b
V
44##
45# Checks source file & script permissions
46##
47check_permissions:
48 @echo "----------------------"
49 @echo "Check file permissions"
50 @echo "----------------------"
1a216fae 51 @for file in `git ls-files | grep -v docker`; do \
fc17813b
V
52 if [ -x $$file ]; then \
53 errors=true; \
54 echo "$${file} is executable"; \
55 fi \
56 done; [ -z $$errors ] || false
57
ca74886f
V
58##
59# PHPUnit
60# Runs unitary and functional tests
61# Generates an HTML coverage report if Xdebug is enabled
62#
63# See phpunit.xml for configuration
64# https://phpunit.de/manual/current/en/appendixes.configuration.html
65##
d6379763 66test: translate
ca74886f
V
67 @echo "-------"
68 @echo "PHPUNIT"
69 @echo "-------"
6c7d6864 70 @mkdir -p sandbox coverage
12266213 71 @$(BIN)/phpunit --coverage-php coverage/main.cov --bootstrap tests/bootstrap.php --testsuite unit-tests
6c7d6864
A
72
73locale_test_%:
74 @UT_LOCALE=$*.utf8 \
75 $(BIN)/phpunit \
76 --coverage-php coverage/$(firstword $(subst _, ,$*)).cov \
77 --bootstrap tests/languages/bootstrap.php \
78 --testsuite language-$(firstword $(subst _, ,$*))
79
80all_tests: test locale_test_de_DE locale_test_en_US locale_test_fr_FR
81 @$(BIN)/phpcov merge --html coverage coverage
82 @# --text doesn't work with phpunit 4.* (v5 requires PHP 5.6)
83 @#$(BIN)/phpcov merge --text coverage/txt coverage
ca74886f 84
559315ba
V
85##
86# Custom release archive generation
87#
88# For each tagged revision, GitHub provides tar and zip archives that correspond
89# to the output of git-archive
90#
91# These targets produce similar archives, featuring 3rd-party dependencies
92# to ease deployment on shared hosting.
93##
94ARCHIVE_VERSION := shaarli-$$(git describe)-full
ca0ed5ca 95ARCHIVE_PREFIX=Shaarli/
559315ba
V
96
97release_archive: release_tar release_zip
98
99### download 3rd-party PHP libraries
100composer_dependencies: clean
eaed9ce8 101 composer install --no-dev --prefer-dist
559315ba
V
102 find vendor/ -name ".git" -type d -exec rm -rf {} +
103
47978e87
A
104### download 3rd-party frontend libraries
105frontend_dependencies:
106 yarn install
107
108### Build frontend dependencies
109build_frontend: frontend_dependencies
110 yarn run build
111
d6379763 112### generate a release tarball and include 3rd-party dependencies and translations
47978e87 113release_tar: composer_dependencies htmldoc translate build_frontend
ca0ed5ca
V
114 git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).tar HEAD
115 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^vendor|$(ARCHIVE_PREFIX)vendor|" vendor/
29712e90 116 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^doc/html|$(ARCHIVE_PREFIX)doc/html|" doc/html/
a136a427 117 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^tpl|$(ARCHIVE_PREFIX)tpl|" tpl/
ca0ed5ca 118 gzip $(ARCHIVE_VERSION).tar
559315ba 119
d6379763 120### generate a release zip and include 3rd-party dependencies and translations
47978e87 121release_zip: composer_dependencies htmldoc translate build_frontend
ca0ed5ca 122 git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).zip -9 HEAD
29712e90
V
123 mkdir -p $(ARCHIVE_PREFIX)/{doc,vendor}
124 rsync -a doc/html/ $(ARCHIVE_PREFIX)doc/html/
125 zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)doc/
ca0ed5ca
V
126 rsync -a vendor/ $(ARCHIVE_PREFIX)vendor/
127 zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)vendor/
a136a427
A
128 rsync -a tpl/ $(ARCHIVE_PREFIX)tpl/
129 zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)tpl/
ca0ed5ca 130 rm -rf $(ARCHIVE_PREFIX)
559315ba 131
1acc87ee 132##
133# Targets for repository and documentation maintenance
f3e89f50 134##
135
136### remove all unversioned files
1acc87ee 137clean:
d0ce99e5 138 @git clean -df
4bf35ba5 139 @rm -rf sandbox
1acc87ee 140
3ee5c697
V
141### generate the AUTHORS file from Git commit information
142authors:
143 @cp .github/mailmap .mailmap
144 @git shortlog -sne > AUTHORS
145 @rm .mailmap
146
05af6f53
V
147### generate Doxygen documentation
148doxygen: clean
149 @rm -rf doxygen
ba2cff15 150 @doxygen Doxyfile
05af6f53 151
dc37a482
V
152### generate HTML documentation from Markdown pages with MkDocs
153htmldoc:
53ed6d7d 154 python3 -m venv venv/
155 bash -c 'source venv/bin/activate; \
156 pip install mkdocs; \
fd2e8fad 157 mkdocs build --clean'
53ed6d7d 158 find doc/html/ -type f -exec chmod a-x '{}' \;
159 rm -r venv
d6379763
A
160
161
162### Generate Shaarli's translation compiled file (.mo)
163translate:
ba2cff15 164 @find inc/languages/ -name shaarli.po -execdir msgfmt shaarli.po -o shaarli.mo \;
47978e87
A
165
166### Run ESLint check against Shaarli's JS files
167eslint:
03b483aa
A
168 @yarn run eslint -c .dev/.eslintrc.js assets/vintage/js/
169 @yarn run eslint -c .dev/.eslintrc.js assets/default/js/
170
171### Run CSSLint check against Shaarli's SCSS files
172sasslint:
173 @yarn run sass-lint -c .dev/.sasslintrc 'assets/default/scss/*.scss' -v -q