-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
229 lines (178 loc) · 6.89 KB
/
Copy pathMakefile
File metadata and controls
229 lines (178 loc) · 6.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
SHELL := /bin/bash
YARN := $(shell command -v yarn 2> /dev/null)
NODE_PREFIX=$(shell pwd)
COMPOSER_BIN := $(shell command -v composer 2> /dev/null)
NPM := $(shell command -v npm 2> /dev/null)
# bin file definitions
PHPUNIT=php -d zend.enable_gc=0 "$(PWD)/../../lib/composer/bin/phpunit"
PHPUNITDBG=phpdbg -qrr -d memory_limit=4096M -d zend.enable_gc=0 "$(PWD)/../../lib/composer/bin/phpunit"
PHP_CS_FIXER=php -d zend.enable_gc=0 vendor-bin/owncloud-codestyle/vendor/bin/php-cs-fixer
PHAN=php -d zend.enable_gc=0 vendor-bin/phan/vendor/bin/phan
PHPSTAN=php -d zend.enable_gc=0 vendor-bin/phpstan/vendor/bin/phpstan
KARMA=$(NODE_PREFIX)/node_modules/.bin/karma
app_name=migrate_to_ocis
build_dir=$(CURDIR)/build
dist_dir=$(build_dir)/dist
src_files=README.md
src_dirs=appinfo bin lib vendor
all_src=$(src_dirs) $(src_files)
# Signing (ownCloud 11 / signature.json schema v2).
# oc11 removed `occ integrity:sign-app`; apps are signed out-of-band with the
# standalone `ocsign` CLI (https://github.com/owncloud/ocsign) using a G2 leaf
# certificate. Override cert_dir to point at a different certificate store.
ocsign=$(shell command -v ocsign 2> /dev/null)
cert_dir=$(HOME)/.owncloud/certificates/G2
private_key=$(cert_dir)/$(app_name).key
certificate=$(cert_dir)/$(app_name).crt
chain=$(cert_dir)/intermediate.crt
# Kept overridable so CI can supply its own signing command - the release
# workflow passes sign="ocsign --key=... --cert=... --chain=..." pointing at key
# material written from repository secrets instead of the local certificate store.
sign=$(ocsign) --key="$(private_key)" --cert="$(certificate)" $(chain_arg)
sign_skip_msg="Skipping signing, either no key and certificate found in $(private_key) and $(certificate) or ocsign can not be found in PATH (install from https://github.com/owncloud/ocsign)"
ifneq (,$(wildcard $(private_key)))
ifneq (,$(wildcard $(certificate)))
ifneq (,$(ocsign))
CAN_SIGN=true
endif
endif
endif
ifneq (,$(wildcard $(chain)))
chain_arg=--chain="$(chain)"
endif
.DEFAULT_GOAL := all
help:
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' | sed -e 's/ */ /' | column -t -s :
##
## Entrypoints
##----------------------
.PHONY: all
all: install-deps
# Remove the appstore build
.PHONY: clean
clean: clean-nodejs-deps clean-composer-deps
rm -rf ./build
.PHONY: clean-nodejs-deps
clean-nodejs-deps:
rm -Rf $(nodejs_deps)
.PHONY: clean-composer-deps
clean-composer-deps:
rm -rf ./vendor
rm -Rf vendor-bin/**/vendor vendor-bin/**/composer.lock
.PHONY: dev
dev: ## Initialize dev environment
dev: install-deps
$(KARMA): $(nodejs_deps)
.PHONY: dist
dist: ## Build distribution
dist: composer distdir sign package
.PHONY: composer
composer:
$(COMPOSER_BIN) install --no-dev
.PHONY: distdir
distdir:
rm -rf $(dist_dir)
mkdir -p $(dist_dir)/$(app_name)
cp -R $(all_src) $(dist_dir)/$(app_name)
rm -Rf $(dist_dir)/$(app_name)/l10n/.tx
.PHONY: sign
sign:
ifdef CAN_SIGN
$(sign) --path="$(dist_dir)/$(app_name)"
else
@echo $(sign_skip_msg)
endif
.PHONY: package
package:
tar -czf $(dist_dir)/$(app_name).tar.gz -C $(dist_dir) $(app_name)
##
## Tests
##----------------------
.PHONY: test-php-unit
test-php-unit: ## Run php unit tests
test-php-unit: vendor/bin/phpunit
$(PHPUNIT) --configuration ./phpunit.xml --testsuite migrate_to_ocis-unit
.PHONY: test-php-unit-dbg
test-php-unit-dbg: ## Run php unit tests using phpdbg
test-php-unit-dbg: vendor/bin/phpunit
$(PHPUNITDBG) --configuration ./phpunit.xml --testsuite migrate_to_ocis-unit
.PHONY: test-php-style
test-php-style: ## Run php-cs-fixer and check owncloud code-style
test-php-style: vendor-bin/owncloud-codestyle/vendor
$(PHP_CS_FIXER) fix -v --diff --allow-risky yes --dry-run
.PHONY: test-php-style-fix
test-php-style-fix: ## Run php-cs-fixer and fix code style issues
test-php-style-fix: vendor-bin/owncloud-codestyle/vendor
$(PHP_CS_FIXER) fix -v --diff --allow-risky yes
.PHONY: test-php-phan
test-php-phan: ## Run phan
test-php-phan: vendor-bin/phan/vendor
$(PHAN) --config-file .phan/config.php --require-config-exists
.PHONY: test-php-phpstan
test-php-phpstan: ## Run phpstan
test-php-phpstan: vendor-bin/phpstan/vendor
$(PHPSTAN) analyse --memory-limit=4G --configuration=./phpstan.neon --no-progress --level=5 appinfo lib
.PHONY: test-js
test-js: $(nodejs_deps)
$(KARMA) start tests/js/karma.config.js --single-run
.PHONY: test-acceptance
test-acceptance: ## Run end-to-end acceptance tests (docker: ownCloud Classic + oCIS)
bash tests/acceptance/run.sh
.PHONY: test-acceptance-reset-ocis
test-acceptance-reset-ocis: ## Recycle only oCIS so the migration can be re-run
cd tests/acceptance && docker compose -f docker/docker-compose.yml rm -sfv ocis \
&& docker compose -f docker/docker-compose.yml up -d --wait ocis
##
## Dependency management
##----------------------
.PHONY: install-deps
install-deps: ## Install dependencies
install-deps: install-php-deps install-js-deps
composer.lock: composer.json
@echo composer.lock is not up to date.
.PHONY: install-php-deps
install-php-deps: ## Install PHP dependencies
install-php-deps: vendor vendor-bin composer.json composer.lock
.PHONY: install-js-deps
install-js-deps: ## Install PHP dependencies
install-js-deps: $(nodejs_deps)
vendor: composer.lock
$(COMPOSER_BIN) install --no-dev
vendor/bin/phpunit: composer.lock
$(COMPOSER_BIN) install
vendor/bamarni/composer-bin-plugin: composer.lock
$(COMPOSER_BIN) install
vendor-bin/owncloud-codestyle/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/owncloud-codestyle/composer.lock
$(COMPOSER_BIN) bin owncloud-codestyle install --no-progress
vendor-bin/owncloud-codestyle/composer.lock: vendor-bin/owncloud-codestyle/composer.json
@echo owncloud-codestyle composer.lock is not up to date.
vendor-bin/phan/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/phan/composer.lock
$(COMPOSER_BIN) bin phan install --no-progress
vendor-bin/phan/composer.lock: vendor-bin/phan/composer.json
@echo phan composer.lock is not up to date.
vendor-bin/phpstan/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/phpstan/composer.lock
$(COMPOSER_BIN) bin phpstan install --no-progress
vendor-bin/phpstan/composer.lock: vendor-bin/phpstan/composer.json
@echo phpstan composer.lock is not up to date.
#
# Translation
#--------------------------------------
.PHONY: l10n-push
l10n-push:
cd l10n && tx push -s --skip
.PHONY: l10n-pull
l10n-pull:
cd l10n && tx pull -a --skip --minimum-perc=75
.PHONY: l10n-clean
l10n-clean:
rm -rf l10n/l10n.pl
find l10n -type f -name \*.po -or -name \*.pot | xargs rm -f
find l10n -type f -name uz.\* -or -name yo.\* -or -name ne.\* -or -name or_IN.\* | xargs git rm -f || true
.PHONY: l10n-read
l10n-read: l10n/l10n.pl
cd l10n && perl l10n.pl $(app_name) read
.PHONY: l10n-write
l10n-write: l10n/l10n.pl
cd l10n && perl l10n.pl $(app_name) write
l10n/l10n.pl:
wget -qO l10n/l10n.pl https://raw.githubusercontent.com/owncloud-ci/transifex/d1c63674d791fe8812216b29da9d8f2f26e7e138/rootfs/usr/bin/l10n