aboutsummaryrefslogtreecommitdiffhomepage
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile120
1 files changed, 53 insertions, 67 deletions
diff --git a/Makefile b/Makefile
index 47f3530f..0ae03226 100644
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,6 @@
1# The personal, minimalist, super-fast, database free, bookmarking service. 1# The personal, minimalist, super-fast, database free, bookmarking service.
2# Makefile for PHP code analysis & testing, documentation and release generation 2# Makefile for PHP code analysis & testing, documentation and release generation
3 3
4# Prerequisites:
5# - install Composer, either:
6# - from your distro's package manager;
7# - from the official website (https://getcomposer.org/download/);
8# - install/update test dependencies:
9# $ composer install # 1st setup
10# $ composer update
11# - install Xdebug for PHPUnit code coverage reports:
12# - see http://xdebug.org/docs/install
13# - enable in php.ini
14SHELL := /bin/bash
15
16BIN = vendor/bin 4BIN = vendor/bin
17PHP_SOURCE = index.php application tests plugins 5PHP_SOURCE = index.php application tests plugins
18PHP_COMMA_SOURCE = index.php,application,tests,plugins 6PHP_COMMA_SOURCE = index.php,application,tests,plugins
@@ -20,6 +8,16 @@ PHP_COMMA_SOURCE = index.php,application,tests,plugins
20all: static_analysis_summary check_permissions test 8all: static_analysis_summary check_permissions test
21 9
22## 10##
11# Docker test adapter
12#
13# Shaarli sources and vendored libraries are copied from a shared volume
14# to a user-owned directory to enable running tests as a non-root user.
15##
16docker_%:
17 rsync -az /shaarli/ ~/shaarli/
18 cd ~/shaarli && make $*
19
20##
23# Concise status of the project 21# Concise status of the project
24# These targets are non-blocking: || exit 0 22# These targets are non-blocking: || exit 0
25## 23##
@@ -106,7 +104,7 @@ check_permissions:
106 @echo "----------------------" 104 @echo "----------------------"
107 @echo "Check file permissions" 105 @echo "Check file permissions"
108 @echo "----------------------" 106 @echo "----------------------"
109 @for file in `git ls-files`; do \ 107 @for file in `git ls-files | grep -v docker`; do \
110 if [ -x $$file ]; then \ 108 if [ -x $$file ]; then \
111 errors=true; \ 109 errors=true; \
112 echo "$${file} is executable"; \ 110 echo "$${file} is executable"; \
@@ -121,12 +119,24 @@ check_permissions:
121# See phpunit.xml for configuration 119# See phpunit.xml for configuration
122# https://phpunit.de/manual/current/en/appendixes.configuration.html 120# https://phpunit.de/manual/current/en/appendixes.configuration.html
123## 121##
124test: 122test: translate
125 @echo "-------" 123 @echo "-------"
126 @echo "PHPUNIT" 124 @echo "PHPUNIT"
127 @echo "-------" 125 @echo "-------"
128 @mkdir -p sandbox 126 @mkdir -p sandbox coverage
129 @$(BIN)/phpunit tests 127 @$(BIN)/phpunit --coverage-php coverage/main.cov --bootstrap tests/bootstrap.php --testsuite unit-tests
128
129locale_test_%:
130 @UT_LOCALE=$*.utf8 \
131 $(BIN)/phpunit \
132 --coverage-php coverage/$(firstword $(subst _, ,$*)).cov \
133 --bootstrap tests/languages/bootstrap.php \
134 --testsuite language-$(firstword $(subst _, ,$*))
135
136all_tests: test locale_test_de_DE locale_test_en_US locale_test_fr_FR
137 @$(BIN)/phpcov merge --html coverage coverage
138 @# --text doesn't work with phpunit 4.* (v5 requires PHP 5.6)
139 @#$(BIN)/phpcov merge --text coverage/txt coverage
130 140
131## 141##
132# Custom release archive generation 142# Custom release archive generation
@@ -144,19 +154,22 @@ release_archive: release_tar release_zip
144 154
145### download 3rd-party PHP libraries 155### download 3rd-party PHP libraries
146composer_dependencies: clean 156composer_dependencies: clean
147 composer update --no-dev 157 composer install --no-dev --prefer-dist
148 find vendor/ -name ".git" -type d -exec rm -rf {} + 158 find vendor/ -name ".git" -type d -exec rm -rf {} +
149 159
150### generate a release tarball and include 3rd-party dependencies 160### generate a release tarball and include 3rd-party dependencies and translations
151release_tar: composer_dependencies 161release_tar: composer_dependencies htmldoc translate
152 git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).tar HEAD 162 git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).tar HEAD
153 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^vendor|$(ARCHIVE_PREFIX)vendor|" vendor/ 163 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^vendor|$(ARCHIVE_PREFIX)vendor|" vendor/
164 tar rvf $(ARCHIVE_VERSION).tar --transform "s|^doc/html|$(ARCHIVE_PREFIX)doc/html|" doc/html/
154 gzip $(ARCHIVE_VERSION).tar 165 gzip $(ARCHIVE_VERSION).tar
155 166
156### generate a release zip and include 3rd-party dependencies 167### generate a release zip and include 3rd-party dependencies and translations
157release_zip: composer_dependencies 168release_zip: composer_dependencies htmldoc translate
158 git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).zip -9 HEAD 169 git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).zip -9 HEAD
159 mkdir $(ARCHIVE_PREFIX) 170 mkdir -p $(ARCHIVE_PREFIX)/{doc,vendor}
171 rsync -a doc/html/ $(ARCHIVE_PREFIX)doc/html/
172 zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)doc/
160 rsync -a vendor/ $(ARCHIVE_PREFIX)vendor/ 173 rsync -a vendor/ $(ARCHIVE_PREFIX)vendor/
161 zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)vendor/ 174 zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)vendor/
162 rm -rf $(ARCHIVE_PREFIX) 175 rm -rf $(ARCHIVE_PREFIX)
@@ -170,53 +183,26 @@ clean:
170 @git clean -df 183 @git clean -df
171 @rm -rf sandbox 184 @rm -rf sandbox
172 185
186### generate the AUTHORS file from Git commit information
187authors:
188 @cp .github/mailmap .mailmap
189 @git shortlog -sne > AUTHORS
190 @rm .mailmap
191
173### generate Doxygen documentation 192### generate Doxygen documentation
174doxygen: clean 193doxygen: clean
175 @rm -rf doxygen 194 @rm -rf doxygen
176 @( cat Doxyfile ; echo "PROJECT_NUMBER=`git describe`" ) | doxygen - 195 @( cat Doxyfile ; echo "PROJECT_NUMBER=`git describe`" ) | doxygen -
177 196
178### update the local copy of the documentation 197### generate HTML documentation from Markdown pages with MkDocs
179doc: clean 198htmldoc:
180 @rm -rf doc 199 python3 -m venv venv/
181 @git clone https://github.com/shaarli/Shaarli.wiki.git doc 200 bash -c 'source venv/bin/activate; \
182 @rm -rf doc/.git 201 pip install mkdocs; \
183 202 mkdocs build'
184### Generate a custom sidebar 203 find doc/html/ -type f -exec chmod a-x '{}' \;
185# 204 rm -r venv
186# Sidebar content: 205
187# - convert GitHub-flavoured relative links to standard Markdown 206### Generate Shaarli's translation compiled file (.mo)
188# - trim HTML, only keep the list (<ul>[...]</ul>) part 207translate:
189htmlsidebar: 208 @find inc/languages/ -name shaarli.po -execdir msgfmt shaarli.po -o shaarli.mo \;
190 @echo '<div id="local-sidebar">' > doc/sidebar.html
191 @awk 'BEGIN { FS = "[\\[\\]]{2}" }'\
192 'm = /\[/ { t=$$2; gsub(/ /, "-", $$2); print $$1"["t"]("$$2".html)"$$3 }'\
193 '!m { print $$0 }' doc/_Sidebar.md > doc/tmp.md
194 @pandoc -f markdown -t html5 -s doc/tmp.md | awk '/(ul>|li>)/' >> doc/sidebar.html
195 @echo '</div>' >> doc/sidebar.html
196 @rm doc/tmp.md
197
198### Convert local markdown documentation to HTML
199#
200# For all pages:
201# - infer title from the file name
202# - convert GitHub-flavoured relative links to standard Markdown
203# - insert the sidebar menu
204htmlpages:
205 @for file in `find doc/ -maxdepth 1 -name "*.md"`; do \
206 base=`basename $$file .md`; \
207 sed -i "1i # $${base//-/ }" $$file; \
208 awk 'BEGIN { FS = "[\\[\\]]{2}" }'\
209 'm = /\[/ { t=$$2; gsub(/ /, "-", $$2); print $$1"["t"]("$$2".html)"$$3 }'\
210 '!m { print $$0 }' $$file > doc/tmp.md; \
211 mv doc/tmp.md $$file; \
212 pandoc -f gfm \
213 -t html5 \
214 -s \
215 -c "github-markdown.css" \
216 -T Shaarli \
217 -M pagetitle:"$${base//-/ }" \
218 -B doc/sidebar.html \
219 -o doc/$$base.html $$file; \
220 done;
221
222htmldoc: doc htmlsidebar htmlpages