]>
Commit | Line | Data |
---|---|---|
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 | ||
6 | all: static_analysis_summary check_permissions test | |
7 | ||
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 | ## | |
14 | docker_%: | |
15 | rsync -az /shaarli/ ~/shaarli/ | |
16 | cd ~/shaarli && make $* | |
17 | ||
18 | ## | |
19 | # PHP_CodeSniffer | |
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 | |
24 | ## | |
25 | PHPCS := $(BIN)/phpcs | |
26 | ||
27 | code_sniffer: | |
28 | @$(PHPCS) | |
29 | ||
30 | ### - errors filtered by coding standard: PEAR, PSR1, PSR2, Zend... | |
31 | PHPCS_%: | |
32 | @$(PHPCS) --report-full --report-width=200 --standard=$* | |
33 | ||
34 | ### - errors by Git author | |
35 | code_sniffer_blame: | |
36 | @$(PHPCS) --report-gitblame | |
37 | ||
38 | ### - all errors/warnings | |
39 | code_sniffer_full: | |
40 | @$(PHPCS) --report-full --report-width=200 | |
41 | ||
42 | ### - errors grouped by kind | |
43 | code_sniffer_source: | |
44 | @$(PHPCS) --report-source || exit 0 | |
45 | ||
46 | ## | |
47 | # Checks source file & script permissions | |
48 | ## | |
49 | check_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 \ | |
55 | errors=true; \ | |
56 | echo "$${file} is executable"; \ | |
57 | fi \ | |
58 | done; [ -z $$errors ] || false | |
59 | ||
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 | ## | |
68 | test: translate | |
69 | @echo "-------" | |
70 | @echo "PHPUNIT" | |
71 | @echo "-------" | |
72 | @mkdir -p sandbox coverage | |
73 | @$(BIN)/phpunit --coverage-php coverage/main.cov --bootstrap tests/bootstrap.php --testsuite unit-tests | |
74 | ||
75 | locale_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 | ||
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 | |
87 | ||
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 | ## | |
97 | ARCHIVE_VERSION := shaarli-$$(git describe)-full | |
98 | ARCHIVE_PREFIX=Shaarli/ | |
99 | ||
100 | release_archive: release_tar release_zip | |
101 | ||
102 | ### download 3rd-party PHP libraries | |
103 | composer_dependencies: clean | |
104 | composer install --no-dev --prefer-dist | |
105 | find vendor/ -name ".git" -type d -exec rm -rf {} + | |
106 | ||
107 | ### download 3rd-party frontend libraries | |
108 | frontend_dependencies: | |
109 | yarn install | |
110 | ||
111 | ### Build frontend dependencies | |
112 | build_frontend: frontend_dependencies | |
113 | yarn run build | |
114 | ||
115 | ### generate a release tarball and include 3rd-party dependencies and translations | |
116 | release_tar: composer_dependencies htmldoc translate build_frontend | |
117 | git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).tar HEAD | |
118 | tar rvf $(ARCHIVE_VERSION).tar --transform "s|^vendor|$(ARCHIVE_PREFIX)vendor|" vendor/ | |
119 | tar rvf $(ARCHIVE_VERSION).tar --transform "s|^doc/html|$(ARCHIVE_PREFIX)doc/html|" doc/html/ | |
120 | tar rvf $(ARCHIVE_VERSION).tar --transform "s|^tpl|$(ARCHIVE_PREFIX)tpl|" tpl/ | |
121 | gzip $(ARCHIVE_VERSION).tar | |
122 | ||
123 | ### generate a release zip and include 3rd-party dependencies and translations | |
124 | release_zip: composer_dependencies htmldoc translate build_frontend | |
125 | git archive --prefix=$(ARCHIVE_PREFIX) -o $(ARCHIVE_VERSION).zip -9 HEAD | |
126 | mkdir -p $(ARCHIVE_PREFIX)/{doc,vendor} | |
127 | rsync -a doc/html/ $(ARCHIVE_PREFIX)doc/html/ | |
128 | zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)doc/ | |
129 | rsync -a vendor/ $(ARCHIVE_PREFIX)vendor/ | |
130 | zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)vendor/ | |
131 | rsync -a tpl/ $(ARCHIVE_PREFIX)tpl/ | |
132 | zip -r $(ARCHIVE_VERSION).zip $(ARCHIVE_PREFIX)tpl/ | |
133 | rm -rf $(ARCHIVE_PREFIX) | |
134 | ||
135 | ## | |
136 | # Targets for repository and documentation maintenance | |
137 | ## | |
138 | ||
139 | ### remove all unversioned files | |
140 | clean: | |
141 | @git clean -df | |
142 | @rm -rf sandbox | |
143 | ||
144 | ### generate the AUTHORS file from Git commit information | |
145 | authors: | |
146 | @cp .github/mailmap .mailmap | |
147 | @git shortlog -sne > AUTHORS | |
148 | @rm .mailmap | |
149 | ||
150 | ### generate phpDocumentor documentation | |
151 | phpdoc: clean | |
152 | @docker run --rm -v $(PWD):/data -u `id -u`:`id -g` phpdoc/phpdoc | |
153 | ||
154 | ### generate HTML documentation from Markdown pages with MkDocs | |
155 | htmldoc: | |
156 | python3 -m venv venv/ | |
157 | bash -c 'source venv/bin/activate; \ | |
158 | pip install mkdocs; \ | |
159 | mkdocs build --clean' | |
160 | find doc/html/ -type f -exec chmod a-x '{}' \; | |
161 | rm -r venv | |
162 | ||
163 | ||
164 | ### Generate Shaarli's translation compiled file (.mo) | |
165 | translate: | |
166 | @find inc/languages/ -name shaarli.po -execdir msgfmt shaarli.po -o shaarli.mo \; | |
167 | ||
168 | ### Run ESLint check against Shaarli's JS files | |
169 | eslint: | |
170 | @yarn run eslint -c .dev/.eslintrc.js assets/vintage/js/ | |
171 | @yarn run eslint -c .dev/.eslintrc.js assets/default/js/ | |
172 | ||
173 | ### Run CSSLint check against Shaarli's SCSS files | |
174 | sasslint: | |
175 | @yarn run sass-lint -c .dev/.sasslintrc 'assets/default/scss/*.scss' -v -q |