-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PoC] Provide common make files #34660
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
93c7157
Provide common make files
phil-davis 9a2aa94
Move php_codesnifffer into its own test-accceptance-style makefile ta…
phil-davis 80ffb1b
Find occ and phpunit locally or up 2 levels
phil-davis 8e1c037
Remove test-all.mk as it is not much useful
phil-davis 6ecb29e
Add more files to default doc_files
phil-davis 41347fc
Add LICENSE LICENSE.md CONTRIBUTING.md only if they exist
phil-davis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Check that composer exists | ||
|
||
ifndef COMPOSER_CHECK_HAS_BEEN_DONE | ||
COMPOSER_CHECK_HAS_BEEN_DONE=true | ||
|
||
COMPOSER_BIN := $(shell command -v composer 2> /dev/null) | ||
ifndef COMPOSER_BIN | ||
$(error composer is not available on your system, please install composer) | ||
endif | ||
|
||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Check that npm exists | ||
|
||
ifndef NPM_CHECK_HAS_BEEN_DONE | ||
NPM_CHECK_HAS_BEEN_DONE=true | ||
|
||
NPM := $(shell command -v npm 2> /dev/null) | ||
ifndef NPM | ||
$(error npm is not available on your system, please install npm) | ||
endif | ||
|
||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## | ||
## Common clean rules | ||
##-------------------------------------- | ||
|
||
ifndef CLEAN_HAS_BEEN_INCLUDED | ||
CLEAN_HAS_BEEN_INCLUDED=true | ||
|
||
.PHONY: clean-deps | ||
clean-deps: ## Clean all dependencies | ||
clean-deps: $(clean_deps_rules) | ||
|
||
.PHONY: clean | ||
clean: ## Clean all dependencies, build and dist | ||
clean: clean-deps $(clean_dist_rules) $(clean_build_rules) | ||
|
||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
## | ||
## Distribution tarball | ||
##-------------------------------------- | ||
|
||
# signing | ||
PATH_TO_OCC=$(CURDIR)/occ | ||
ifeq ("$(wildcard $(PATH_TO_OCC))","") | ||
PATH_TO_OCC=$(CURDIR)/../../occ | ||
endif | ||
occ=$(PATH_TO_OCC) | ||
private_key=$(HOME)/.owncloud/certificates/$(app_name).key | ||
certificate=$(HOME)/.owncloud/certificates/$(app_name).crt | ||
sign=$(occ) integrity:sign-app --privateKey="$(private_key)" --certificate="$(certificate)" | ||
sign_skip_msg="Skipping signing, either no key and certificate found in $(private_key) and $(certificate) or occ can not be found at $(occ)" | ||
ifneq (,$(wildcard $(private_key))) | ||
ifneq (,$(wildcard $(certificate))) | ||
ifneq (,$(wildcard $(occ))) | ||
CAN_SIGN=true | ||
endif | ||
endif | ||
endif | ||
|
||
# If the app_name has not been specified by the caller, | ||
# then use the name of the directory that the main "make" is being run from. | ||
ifndef app_name | ||
app_name=$(notdir $(CURDIR)) | ||
endif | ||
|
||
# If not specified by the caller, then select some common doc files to put in the tarball. | ||
ifndef doc_files | ||
doc_files=CHANGELOG.md README.md | ||
ifneq ("$(wildcard LICENSE)","") | ||
doc_files+=LICENSE | ||
endif | ||
ifneq ("$(wildcard LICENSE.md)","") | ||
doc_files+=LICENSE.md | ||
endif | ||
ifneq ("$(wildcard CONTRIBUTING.md)","") | ||
doc_files+=CONTRIBUTING.md | ||
endif | ||
endif | ||
|
||
# If not specified by the caller, then select a "standard" set of dirs to put in the tarball. | ||
ifndef src_dirs | ||
src_dirs=appinfo css img js l10n lib templates | ||
endif | ||
|
||
all_src=$(src_dirs) $(extra_dirs) $(doc_files) $(extra_files) | ||
|
||
# Put the tarball and any other artifacts in a build dir by default | ||
ifndef build_dir | ||
build_dir=$(CURDIR)/build | ||
endif | ||
|
||
# Put the tarball in a dist sub-dir of build_dir by default | ||
ifndef dist_dir | ||
dist_dir=$(build_dir)/dist | ||
endif | ||
|
||
# | ||
# dist | ||
# | ||
$(dist_dir)/$(app_name): $(composer_deps) $(bower_deps) $(nodejs_deps) | ||
rm -Rf $@; mkdir -p $@ | ||
cp -R $(all_src) $@ | ||
|
||
ifdef CAN_SIGN | ||
$(sign) --path="$(dist_dir)/$(app_name)" | ||
else | ||
@echo $(sign_skip_msg) | ||
endif | ||
tar -czf $(dist_dir)/$(app_name).tar.gz -C $(dist_dir) $(app_name) | ||
|
||
.PHONY: dist | ||
dist: ## Make the tarball for release distribution | ||
dist: $(dist_dir)/$(app_name) | ||
|
||
clean_dist_rules+=clean-dist | ||
clean_build_rules+=clean-build | ||
|
||
.PHONY: clean-dist | ||
clean-dist: ## Clean the dist directory | ||
clean-dist: | ||
rm -Rf $(dist_dir) | ||
|
||
.PHONY: clean-build | ||
clean-build: ## Clean the build directory | ||
clean-build: | ||
rm -Rf $(build_dir) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Define the help target and make it the default | ||
|
||
.DEFAULT_GOAL := help | ||
|
||
# start with displaying help | ||
help: | ||
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' | sed -e 's/ */ /' | column -t -s : | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
## | ||
## Acceptance Tests | ||
##-------------------------------------- | ||
|
||
RELATIVE_PATH := $(dir $(lastword $(MAKEFILE_LIST))) | ||
include $(RELATIVE_PATH)check-composer.mk | ||
|
||
acceptance_test_deps=vendor-bin/behat/vendor | ||
|
||
# bin file definitions | ||
BEHAT_BIN=vendor-bin/behat/vendor/bin/behat | ||
PHP_CODESNIFFER=vendor-bin/php_codesniffer/vendor/bin/phpcs | ||
|
||
.PHONY: test-acceptance-api | ||
test-acceptance-api: ## Run API acceptance tests | ||
test-acceptance-api: $(acceptance_test_deps) | ||
BEHAT_BIN=$(BEHAT_BIN) ../../tests/acceptance/run.sh --remote --type api | ||
|
||
.PHONY: test-acceptance-cli | ||
test-acceptance-cli: ## Run CLI acceptance tests | ||
test-acceptance-cli: $(acceptance_test_deps) | ||
BEHAT_BIN=$(BEHAT_BIN) ../../tests/acceptance/run.sh --remote --type cli | ||
|
||
.PHONY: test-acceptance-webui | ||
test-acceptance-webui: ## Run webUI acceptance tests | ||
test-acceptance-webui: $(acceptance_test_deps) | ||
BEHAT_BIN=$(BEHAT_BIN) ../../tests/acceptance/run.sh --remote --type webui | ||
|
||
.PHONY: test-acceptance-style | ||
test-acceptance-style: ## Run php_codesniffer and check acceptance test code-style | ||
test-acceptance-style: vendor-bin/php_codesniffer/vendor | ||
$(PHP_CODESNIFFER) --runtime-set ignore_warnings_on_exit --standard=phpcs.xml tests/acceptance | ||
|
||
# | ||
# Dependency management | ||
#-------------------------------------- | ||
|
||
include $(RELATIVE_PATH)vendor-bin.mk | ||
|
||
vendor-bin/behat/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/behat/composer.lock | ||
composer bin behat install --no-progress | ||
|
||
vendor-bin/behat/composer.lock: vendor-bin/behat/composer.json | ||
@echo behat composer.lock is not up to date. | ||
|
||
vendor-bin/php_codesniffer/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/php_codesniffer/composer.lock | ||
composer bin php_codesniffer install --no-progress | ||
|
||
vendor-bin/php_codesniffer/composer.lock: vendor-bin/php_codesniffer/composer.json | ||
@echo php_codesniffer composer.lock is not up to date. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## | ||
## JavaScript Tests | ||
##-------------------------------------- | ||
|
||
# bin file definitions | ||
NODE_PREFIX=$(shell pwd) | ||
KARMA=$(NODE_PREFIX)/node_modules/.bin/karma | ||
|
||
nodejs_deps=node_modules | ||
|
||
.PHONY: test-js | ||
test-js: ## Run JS test suites (single run) | ||
test-js: $(KARMA) | ||
$(KARMA) start tests/js/karma.config.js --single-run | ||
|
||
test-js-debug: ## Run JS test suites and watch for changes | ||
test-js-debug: $(KARMA) | ||
$(KARMA) start tests/js/karma.config.js | ||
|
||
$(KARMA): $(nodejs_deps) | ||
|
||
# | ||
# Dependency management | ||
#-------------------------------------- | ||
|
||
$(nodejs_deps): package.json yarn.lock | ||
yarn install | ||
touch $@ | ||
|
||
clean_deps_rules+=clean-js-deps | ||
|
||
.PHONY: clean-js-deps | ||
clean-js-deps: | ||
rm -Rf $(nodejs_deps) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
## | ||
## PHP Tests | ||
##-------------------------------------- | ||
|
||
RELATIVE_PATH := $(dir $(lastword $(MAKEFILE_LIST))) | ||
include $(RELATIVE_PATH)check-composer.mk | ||
|
||
# bin file definitions | ||
PATH_TO_PHPUNIT=$(CURDIR)/lib/composer/bin/phpunit | ||
ifeq ("$(wildcard $(PATH_TO_PHPUNIT))","") | ||
PATH_TO_PHPUNIT=$(CURDIR)/../../lib/composer/bin/phpunit | ||
endif | ||
PHPUNIT=php -d zend.enable_gc=0 "$(PATH_TO_PHPUNIT)" | ||
PHPUNITDBG=phpdbg -qrr -d memory_limit=4096M -d zend.enable_gc=0 "$(PATH_TO_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 | ||
|
||
.PHONY: test-php-unit | ||
test-php-unit: ## Run php unit tests | ||
test-php-unit: | ||
$(PHPUNIT) --configuration ./phpunit.xml --testsuite unit | ||
|
||
.PHONY: test-php-unit-dbg | ||
test-php-unit-dbg: ## Run php unit tests using phpdbg | ||
test-php-unit-dbg: | ||
$(PHPUNITDBG) --configuration ./phpunit.xml --testsuite 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 --diff-format udiff --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 --diff-format udiff --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 | ||
|
||
# | ||
# Dependency management | ||
#-------------------------------------- | ||
|
||
include $(RELATIVE_PATH)vendor-bin.mk | ||
|
||
vendor-bin/owncloud-codestyle/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/owncloud-codestyle/composer.lock | ||
composer 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 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 phpstan install --no-progress | ||
|
||
vendor-bin/phpstan/composer.lock: vendor-bin/phpstan/composer.json | ||
@echo phpstan composer.lock is not up to date. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Dependencies for getting the vendor and vendor-bin directory happening | ||
|
||
ifndef VENDOR_BIN_HAS_BEEN_INCLUDED | ||
VENDOR_BIN_HAS_BEEN_INCLUDED=true | ||
|
||
composer.lock: composer.json | ||
@echo composer.lock is not up to date. | ||
|
||
vendor: composer.lock | ||
composer install --no-dev | ||
|
||
vendor/bamarni/composer-bin-plugin: composer.lock | ||
composer install | ||
|
||
clean_deps_rules+=clean-vendor clean-vendor-bin | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, you aready have this |
||
|
||
.PHONY: clean-vendor | ||
clean-vendor: | ||
rm -Rf vendor | ||
|
||
.PHONY: clean-vendor-bin | ||
clean-vendor-bin: | ||
rm -Rf vendor-bin/**/vendor vendor-bin/**/composer.lock | ||
|
||
endif |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the clean rules need to be part of each module
the dist rules module has clean-dist, the npm deps has clean-npm-deps, etc
you can use a generic variable to which every module can add their clean rules to the main "clean" target.
see https://github.com/owncloud/customgroups/blob/master/Makefile#L25 and https://github.com/owncloud/customgroups/blob/master/rules/deps.mk#L16