1 # The personal, minimalist, super-fast, database free, bookmarking service.
2 # Makefile for PHP code analysis & testing, documentation and release generation
6 all: check_permissions test
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.
15 rsync -az /shaarli/ ~/shaarli/
16 cd ~/shaarli && make $*
20 # Detects PHP syntax errors
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
30 ### - errors filtered by coding standard: PEAR, PSR1, PSR2, Zend...
32 @$(PHPCS) --report-full --report-width=200 --standard=$*
34 ### - errors by Git author
36 @$(PHPCS) --report-gitblame
38 ### - all errors/warnings
40 @$(PHPCS) --report-full --report-width=200
42 ### - errors grouped by kind
44 @$(PHPCS) --report-source || exit 0
47 # Checks source file & script permissions
50 @echo "----------------------"
51 @echo "Check file permissions"
52 @echo "----------------------"
53 @for file in `git ls-files | grep -v docker`; do \
54 if [ -x $$file ]; then \
56 echo "$${file} is executable"; \
58 done; [ -z $$errors ] || false
62 # Runs unitary and functional tests
63 # Generates an HTML coverage report if Xdebug is enabled
65 # See phpunit.xml for configuration
66 # https://phpunit.de/manual/current/en/appendixes.configuration.html
72 @mkdir -p sandbox coverage
73 @$(BIN)/phpunit --coverage-php coverage/main.cov --bootstrap tests/bootstrap.php --testsuite unit-tests
78 --coverage-php coverage/$(firstword $(subst _, ,$*)).cov \
79 --bootstrap tests/languages/bootstrap.php \
80 --testsuite language-$(firstword $(subst _, ,$*))
82 all_tests: test locale_test_de_DE locale_test_en_US locale_test_fr_FR
83 @# --The current version is not compatible with PHP 7.2
84 @#$(BIN)/phpcov merge --html coverage coverage
85 @# --text doesn't work with phpunit 4.* (v5 requires PHP 5.6)
86 @#$(BIN)/phpcov merge --text coverage/txt coverage
88 ### download 3rd-party PHP libraries, including dev dependencies
89 composer_dependencies_dev: clean
90 composer install --prefer-dist
93 # Custom release archive generation
95 # For each tagged revision, GitHub provides tar and zip archives that correspond
96 # to the output of git-archive
98 # These targets produce similar archives, featuring 3rd-party dependencies
99 # to ease deployment on shared hosting.
101 ARCHIVE_VERSION := shaarli-$$(git describe)-full
102 ARCHIVE_PREFIX=Shaarli/
104 release_archive: release_tar release_zip
106 ### download 3rd-party PHP libraries
107 composer_dependencies: clean
108 composer install --no-dev --prefer-dist
109 find vendor/ -name ".git" -type d -exec rm -rf {} +
111 ### download 3rd-party frontend libraries
112 frontend_dependencies:
115 ### Build frontend dependencies
116 build_frontend: frontend_dependencies
119 ### generate a release tarball and include 3rd-party dependencies and translations
120 release_tar: composer_dependencies htmldoc translate build_frontend
121 git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).tar HEAD
122 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^vendor|$(ARCHIVE_PREFIX)vendor|" vendor/
123 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^doc/html|$(ARCHIVE_PREFIX)doc/html|" doc/html/
124 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^tpl|$(ARCHIVE_PREFIX)tpl|" tpl/
125 gzip $(ARCHIVE_VERSION).tar
127 ### generate a release zip and include 3rd-party dependencies and translations
128 release_zip: composer_dependencies htmldoc translate build_frontend
129 git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).zip -9 HEAD
130 mkdir -p $(ARCHIVE_PREFIX)/doc
131 mkdir -p $(ARCHIVE_PREFIX)/vendor
132 rsync -a doc/html/ $(ARCHIVE_PREFIX)doc/html/
133 zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)doc/
134 rsync -a vendor/ $(ARCHIVE_PREFIX)vendor/
135 zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)vendor/
136 rsync -a tpl/ $(ARCHIVE_PREFIX)tpl/
137 zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)tpl/
138 rm -rf $(ARCHIVE_PREFIX)
141 # Targets for repository and documentation maintenance
144 ### remove all unversioned files
149 ### generate the AUTHORS file from Git commit information
151 @cp .github/mailmap .mailmap
152 @git shortlog -sne > AUTHORS
155 ### generate phpDocumentor documentation
157 @docker run --rm -v $(PWD):/data -u `id -u`:`id -g` phpdoc/phpdoc
159 ### generate HTML documentation from Markdown pages with MkDocs
161 python3 -m venv venv/
162 bash -c 'source venv/bin/activate; \
164 pip install mkdocs; \
165 mkdocs build --clean'
166 find doc/html/ -type f -exec chmod a-x '{}' \;
170 ### Generate Shaarli's translation compiled file (.mo)
172 @find inc/languages/ -name shaarli.po -execdir msgfmt shaarli.po -o shaarli.mo \;
174 ### Run ESLint check against Shaarli's JS files
176 @yarn run eslint -c .dev/.eslintrc.js assets/vintage/js/
177 @yarn run eslint -c .dev/.eslintrc.js assets/default/js/
178 @yarn run eslint -c .dev/.eslintrc.js assets/common/js/
180 ### Run CSSLint check against Shaarli's SCSS files
182 @yarn run stylelint --config .dev/.stylelintrc.js 'assets/default/scss/*.scss'