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