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