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