diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..a375920 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,281 @@ +workspace: + base: /var/www/owncloud + path: apps/announcementcenter + +branches: [master, release*, release/*] + +pipeline: + install-server: + image: owncloudci/core + version: ${OC_VERSION} + pull: true + db_type: ${DB_TYPE} + db_name: ${DB_NAME} + db_host: ${DB_TYPE} + db_username: autotest + db_password: owncloud + when: + matrix: + NEED_SERVER: true + + install-app: + image: owncloudci/php:${PHP_VERSION} + pull: true + commands: + - cd /var/www/owncloud/ + - php occ a:l + - php occ a:e announcementcenter + - php occ a:e testing + - php occ a:l + - php occ config:system:set trusted_domains 1 --value=owncloud + - php occ log:manage --level 0 + when: + matrix: + NEED_INSTALL_APP: true + + fix-permissions: + image: owncloudci/php:${PHP_VERSION} + pull: true + commands: + - chown www-data /var/www/owncloud -R + - chmod 777 /var/www/owncloud/tests/acceptance/filesForUpload -R + - chmod +x /var/www/owncloud/tests/acceptance/run.sh + when: + matrix: + NEED_SERVER: true + + owncloud-log: + image: owncloud/ubuntu:16.04 + detach: true + pull: true + commands: + - tail -f /var/www/owncloud/data/owncloud.log + when: + matrix: + NEED_SERVER: true + + owncloud-coding-standard: + image: owncloudci/php:${PHP_VERSION} + pull: true + commands: + - make test-php-style + when: + matrix: + TEST_SUITE: owncloud-coding-standard + + codecheck-test: + image: owncloudci/php:${PHP_VERSION} + pull: true + commands: + - su-exec www-data make test-codecheck + when: + matrix: + TEST_SUITE: codecheck + + codecheck-deprecations-test: + image: owncloudci/php:${PHP_VERSION} + pull: true + commands: + - su-exec www-data make test-codecheck-deprecations + when: + matrix: + TEST_SUITE: codecheck-deprecations + + phpunit-tests: + image: owncloudci/php:${PHP_VERSION} + pull: true + environment: + - PHP_VERSION=${PHP_VERSION} + - COVERAGE=${COVERAGE} + commands: + - if [ -z "${COVERAGE}" ]; then make test-php-unit; fi + - if [ "${COVERAGE}" = "true" ]; then make test-php-unit-dbg; fi + when: + matrix: + TEST_SUITE: phpunit + + codecov: + image: plugins/codecov:2 + secrets: [codecov_token] + pull: true + files: + - tests/output/clover.xml + when: + matrix: + COVERAGE: true + + notify: + image: plugins/slack:1 + pull: true + secrets: [ slack_webhook ] + channel: builds + when: + status: [ failure, changed ] + event: [ push, tag ] + +services: + mysql: + image: mysql:5.5 + environment: + - MYSQL_USER=autotest + - MYSQL_PASSWORD=owncloud + - MYSQL_DATABASE=${DB_NAME} + - MYSQL_ROOT_PASSWORD=owncloud + when: + matrix: + DB_TYPE: mysql + + pgsql: + image: postgres:9.4 + environment: + - POSTGRES_USER=autotest + - POSTGRES_PASSWORD=owncloud + - POSTGRES_DB=${DB_NAME} + when: + matrix: + DB_TYPE: pgsql + + oci: + image: deepdiver/docker-oracle-xe-11g + environment: + - ORACLE_USER=system + - ORACLE_PASSWORD=oracle + - ORACLE_DB=${DB_NAME} + when: + matrix: + DB_TYPE: oci + + owncloud: + image: owncloudci/php:${PHP_VERSION} + pull: true + environment: + - APACHE_WEBROOT=/var/www/owncloud/ + command: [ "/usr/local/bin/apachectl", "-e", "debug", "-D", "FOREGROUND" ] + when: + matrix: + NEED_SERVER: true + +matrix: + include: + # code check tests + - PHP_VERSION: 7.2 + OC_VERSION: daily-master-qa + TEST_SUITE: codecheck + NEED_SERVER: true + NEED_INSTALL_APP: true + + - PHP_VERSION: 7.2 + OC_VERSION: daily-master-qa + TEST_SUITE: codecheck-deprecations + NEED_SERVER: true + NEED_INSTALL_APP: true + + - PHP_VERSION: 7.1 + OC_VERSION: daily-stable10-qa + TEST_SUITE: codecheck + NEED_SERVER: true + NEED_INSTALL_APP: true + + - PHP_VERSION: 7.1 + OC_VERSION: daily-stable10-qa + TEST_SUITE: codecheck-deprecations + NEED_SERVER: true + NEED_INSTALL_APP: true + + # Unit Tests + - PHP_VERSION: 7.1 + OC_VERSION: daily-master-qa + TEST_SUITE: phpunit + DB_TYPE: sqlite + DB_NAME: owncloud + NEED_SERVER: true + NEED_INSTALL_APP: true + + - PHP_VERSION: 7.1 + OC_VERSION: daily-master-qa + TEST_SUITE: phpunit + DB_TYPE: mysql + DB_NAME: owncloud + NEED_SERVER: true + NEED_INSTALL_APP: true + + - PHP_VERSION: 7.1 + OC_VERSION: daily-master-qa + TEST_SUITE: phpunit + DB_TYPE: pgsql + DB_NAME: owncloud + NEED_SERVER: true + NEED_INSTALL_APP: true + + - PHP_VERSION: 7.1 + OC_VERSION: daily-master-qa + TEST_SUITE: phpunit + DB_TYPE: oci + DB_NAME: XE + NEED_SERVER: true + NEED_INSTALL_APP: true + + - PHP_VERSION: 7.2 + OC_VERSION: daily-master-qa + TEST_SUITE: phpunit + DB_TYPE: mysql + DB_NAME: owncloud + NEED_SERVER: true + NEED_INSTALL_APP: true + + - PHP_VERSION: 5.6 + OC_VERSION: daily-stable10-qa + TEST_SUITE: phpunit + DB_TYPE: sqlite + DB_NAME: owncloud + NEED_SERVER: true + NEED_INSTALL_APP: true + + - PHP_VERSION: 5.6 + OC_VERSION: daily-stable10-qa + TEST_SUITE: phpunit + DB_TYPE: mysql + DB_NAME: owncloud + NEED_SERVER: true + NEED_INSTALL_APP: true + + - PHP_VERSION: 7.0 + OC_VERSION: daily-stable10-qa + TEST_SUITE: phpunit + DB_TYPE: mysql + DB_NAME: owncloud + NEED_SERVER: true + NEED_INSTALL_APP: true + + - PHP_VERSION: 7.0 + OC_VERSION: daily-stable10-qa + TEST_SUITE: phpunit + DB_TYPE: pgsql + DB_NAME: owncloud + NEED_SERVER: true + NEED_INSTALL_APP: true + COVERAGE: true + + - PHP_VERSION: 7.0 + OC_VERSION: daily-stable10-qa + TEST_SUITE: phpunit + DB_TYPE: oci + DB_NAME: XE + NEED_SERVER: true + NEED_INSTALL_APP: true + + - PHP_VERSION: 7.1 + OC_VERSION: daily-stable10-qa + TEST_SUITE: phpunit + DB_TYPE: mysql + DB_NAME: owncloud + NEED_SERVER: true + NEED_INSTALL_APP: true + + - PHP_VERSION: 7.2 + OC_VERSION: daily-stable10-qa + TEST_SUITE: phpunit + DB_TYPE: mysql + DB_NAME: owncloud + NEED_SERVER: true + NEED_INSTALL_APP: true diff --git a/.gitignore b/.gitignore index a571cf5..34b6aff 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,16 @@ nbproject # Tests - auto-generated files /tests/coverage* /tests/clover.xml +/tests/output/clover.xml /tests/js/node_modules +/tests/output/ build + +.php_cs.cache + +# Composer +composer.phar +vendor/ +vendor-bin/**/composer.lock +vendor-bin/**/vendor diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 0000000..2d1a88c --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,14 @@ +setUsingCache(true) + ->getFinder() + ->exclude('l10n') + ->exclude('vendor') + ->exclude('vendor-bin') + ->notPath('/^c3.php/') + ->in(__DIR__); + +return $config; diff --git a/.travis.yml b/.travis.yml index 094f588..7a12478 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,13 +40,11 @@ script: - cd apps/$APP_NAME/ # Run phpunit tests - - cd tests/ - - sh -c "if [ '$JSTESTS' != '1' -a '$CODECHECK' != '1' -a '$CODECHECK' != '2' ]; then ../../../lib/composer/bin/phpunit --configuration phpunit.xml; fi" + - sh -c "if [ '$JSTESTS' != '1' -a '$CODECHECK' != '1' -a '$CODECHECK' != '2' ]; then make test-php-unit; fi" # Create coverage report - sh -c "if [ '$JSTESTS' != '1' -a '$CODECHECK' != '1' -a '$CODECHECK' != '2' ]; then wget https://scrutinizer-ci.com/ocular.phar; fi" - - sh -c "if [ '$JSTESTS' != '1' -a '$CODECHECK' != '1' -a '$CODECHECK' != '2' ]; then php ocular.phar code-coverage:upload --format=php-clover clover.xml; fi" - - cd ../ + - sh -c "if [ '$JSTESTS' != '1' -a '$CODECHECK' != '1' -a '$CODECHECK' != '2' ]; then php ocular.phar code-coverage:upload --format=php-clover ./tests/output/clover.xml; fi" after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/Makefile b/Makefile index 3393a04..3e4a105 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,10 @@ endif endif endif +# 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 # Removes the appstore build .PHONY: clean @@ -72,3 +76,63 @@ else @echo $(sign_skip_msg) endif tar -czf $(appstore_package_name).tar.gz -C $(appstore_package_name)/../ $(app_name) + +## +## Tests +##-------------------------------------- + +.PHONY: test-syntax-php +test-syntax-php: + for F in $(shell find . -name \*.php | grep -v -e 'lib/composer' -e 'vendor' -e 'vendor-bin' -e 'l10n'); do \ + php -l "$$F" > /dev/null || exit $?; \ + done + +.PHONY: test-php-unit +test-php-unit: ## Run php unit tests +test-php-unit: vendor/bin/phpunit + $(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: vendor/bin/phpunit + $(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-codecheck +test-codecheck: test-syntax-php + $(occ) app:check-code $(app_name) -c private -c strong-comparison + +.PHONY: test-codecheck-deprecations +test-codecheck-deprecations: + $(occ) app:check-code $(app_name) -c deprecation + +# +# Dependency management +#-------------------------------------- + +composer.lock: composer.json + @echo composer.lock is not up to date. + +vendor: composer.lock + composer install --no-dev + +vendor/bin/phpunit: composer.lock + composer install + +vendor/bamarni/composer-bin-plugin: composer.lock + composer install + +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. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..9ea16b5 --- /dev/null +++ b/composer.json @@ -0,0 +1,19 @@ +{ + "name": "owncloud/announcementcenter", + "config" : { + "platform": { + "php": "5.6.37" + } + }, + "require": { + }, + "require-dev": { + "jakub-onderka/php-parallel-lint": "^1.0", + "bamarni/composer-bin-plugin": "^1.2" + }, + "extra": { + "bamarni-bin": { + "bin-links": false + } + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..2507eaa --- /dev/null +++ b/composer.lock @@ -0,0 +1,108 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "c14467363581e4c25e7eb78d2b092ab8", + "packages": [], + "packages-dev": [ + { + "name": "bamarni/composer-bin-plugin", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/bamarni/composer-bin-plugin.git", + "reference": "62fef740245a85f00665e81ea8f0aa0b72afe6e7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/bamarni/composer-bin-plugin/zipball/62fef740245a85f00665e81ea8f0aa0b72afe6e7", + "reference": "62fef740245a85f00665e81ea8f0aa0b72afe6e7", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0" + }, + "require-dev": { + "composer/composer": "dev-master", + "symfony/console": "^2.5 || ^3.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Bamarni\\Composer\\Bin\\Plugin", + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Bamarni\\Composer\\Bin\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "time": "2017-09-11T13:13:58+00:00" + }, + { + "name": "jakub-onderka/php-parallel-lint", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/JakubOnderka/PHP-Parallel-Lint.git", + "reference": "04fbd3f5fb1c83f08724aa58a23db90bd9086ee8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/JakubOnderka/PHP-Parallel-Lint/zipball/04fbd3f5fb1c83f08724aa58a23db90bd9086ee8", + "reference": "04fbd3f5fb1c83f08724aa58a23db90bd9086ee8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "jakub-onderka/php-console-highlighter": "~0.3", + "nette/tester": "~1.3", + "squizlabs/php_codesniffer": "~2.7" + }, + "suggest": { + "jakub-onderka/php-console-highlighter": "Highlight syntax in code snippet" + }, + "bin": [ + "parallel-lint" + ], + "type": "library", + "autoload": { + "classmap": [ + "./" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Jakub Onderka", + "email": "ahoj@jakubonderka.cz" + } + ], + "description": "This tool check syntax of PHP files about 20x faster than serial check.", + "homepage": "https://github.com/JakubOnderka/PHP-Parallel-Lint", + "time": "2018-02-24T15:31:20+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "platform-overrides": { + "php": "5.6.37" + } +} diff --git a/tests/phpunit.xml b/phpunit.xml similarity index 51% rename from tests/phpunit.xml rename to phpunit.xml index 2884941..9235143 100644 --- a/tests/phpunit.xml +++ b/phpunit.xml @@ -1,24 +1,24 @@ - - - . + + ./tests - ../../announcementcenter/appinfo - ../../announcementcenter/lib + ./appinfo + ./lib - + diff --git a/vendor-bin/owncloud-codestyle/composer.json b/vendor-bin/owncloud-codestyle/composer.json new file mode 100644 index 0000000..322a204 --- /dev/null +++ b/vendor-bin/owncloud-codestyle/composer.json @@ -0,0 +1,10 @@ +{ + "config" : { + "platform": { + "php": "5.6.37" + } + }, + "require": { + "owncloud/coding-standard": "^1.0" + } +}