]> git.immae.eu Git - github/shaarli/Shaarli.git/blob - Makefile
lint: remove unused tools
[github/shaarli/Shaarli.git] / Makefile
1 # The personal, minimalist, super-fast, database free, bookmarking service.
2 # Makefile for PHP code analysis & testing, documentation and release generation
3
4 BIN = vendor/bin
5 PHP_SOURCE = index.php application tests plugins
6
7 all: static_analysis_summary check_permissions test
8
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 ##
15 docker_%:
16 rsync -az /shaarli/ ~/shaarli/
17 cd ~/shaarli && make $*
18
19 ##
20 # PHP_CodeSniffer
21 # Detects PHP syntax errors
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 ##
26 code_sniffer: code_sniffer_full
27
28 ### - errors filtered by coding standard: PEAR, PSR1, PSR2, Zend...
29 PHPCS_%:
30 @$(BIN)/phpcs $(PHP_SOURCE) --report-full --report-width=200 --standard=$*
31
32 ### - errors by Git author
33 code_sniffer_blame:
34 @$(BIN)/phpcs $(PHP_SOURCE) --report-gitblame
35
36 ### - all errors/warnings
37 code_sniffer_full:
38 @$(BIN)/phpcs $(PHP_SOURCE) --report-full --report-width=200
39
40 ### - errors grouped by kind
41 code_sniffer_source:
42 @$(BIN)/phpcs $(PHP_SOURCE) --report-source || exit 0
43
44 ##
45 # Checks source file & script permissions
46 ##
47 check_permissions:
48 @echo "----------------------"
49 @echo "Check file permissions"
50 @echo "----------------------"
51 @for file in `git ls-files | grep -v docker`; do \
52 if [ -x $$file ]; then \
53 errors=true; \
54 echo "$${file} is executable"; \
55 fi \
56 done; [ -z $$errors ] || false
57
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 ##
66 test: translate
67 @echo "-------"
68 @echo "PHPUNIT"
69 @echo "-------"
70 @mkdir -p sandbox coverage
71 @$(BIN)/phpunit --coverage-php coverage/main.cov --bootstrap tests/bootstrap.php --testsuite unit-tests
72
73 locale_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
80 all_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
84
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 ##
94 ARCHIVE_VERSION := shaarli-$$(git describe)-full
95 ARCHIVE_PREFIX=Shaarli/
96
97 release_archive: release_tar release_zip
98
99 ### download 3rd-party PHP libraries
100 composer_dependencies: clean
101 composer install --no-dev --prefer-dist
102 find vendor/ -name ".git" -type d -exec rm -rf {} +
103
104 ### download 3rd-party frontend libraries
105 frontend_dependencies:
106 yarn install
107
108 ### Build frontend dependencies
109 build_frontend: frontend_dependencies
110 yarn run build
111
112 ### generate a release tarball and include 3rd-party dependencies and translations
113 release_tar: composer_dependencies htmldoc translate build_frontend
114 git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).tar HEAD
115 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^vendor|$(ARCHIVE_PREFIX)vendor|" vendor/
116 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^doc/html|$(ARCHIVE_PREFIX)doc/html|" doc/html/
117 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^tpl|$(ARCHIVE_PREFIX)tpl|" tpl/
118 gzip $(ARCHIVE_VERSION).tar
119
120 ### generate a release zip and include 3rd-party dependencies and translations
121 release_zip: composer_dependencies htmldoc translate build_frontend
122 git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).zip -9 HEAD
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/
126 rsync -a vendor/ $(ARCHIVE_PREFIX)vendor/
127 zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)vendor/
128 rsync -a tpl/ $(ARCHIVE_PREFIX)tpl/
129 zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)tpl/
130 rm -rf $(ARCHIVE_PREFIX)
131
132 ##
133 # Targets for repository and documentation maintenance
134 ##
135
136 ### remove all unversioned files
137 clean:
138 @git clean -df
139 @rm -rf sandbox
140
141 ### generate the AUTHORS file from Git commit information
142 authors:
143 @cp .github/mailmap .mailmap
144 @git shortlog -sne > AUTHORS
145 @rm .mailmap
146
147 ### generate Doxygen documentation
148 doxygen: clean
149 @rm -rf doxygen
150 @doxygen Doxyfile
151
152 ### generate HTML documentation from Markdown pages with MkDocs
153 htmldoc:
154 python3 -m venv venv/
155 bash -c 'source venv/bin/activate; \
156 pip install mkdocs; \
157 mkdocs build --clean'
158 find doc/html/ -type f -exec chmod a-x '{}' \;
159 rm -r venv
160
161
162 ### Generate Shaarli's translation compiled file (.mo)
163 translate:
164 @find inc/languages/ -name shaarli.po -execdir msgfmt shaarli.po -o shaarli.mo \;
165
166 ### Run ESLint check against Shaarli's JS files
167 eslint:
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
172 sasslint:
173 @yarn run sass-lint -c .dev/.sasslintrc 'assets/default/scss/*.scss' -v -q