Skip to content
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

Standardize CI and move unit tests to Unit folder #112

Merged
merged 3 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ workspace:
branches: [master, release*, release/*]

pipeline:
install-server:
install-core:
image: owncloudci/core
version: ${OC_VERSION}
pull: true
Expand All @@ -16,7 +16,7 @@ pipeline:
db_password: owncloud
when:
matrix:
NEED_SERVER: true
NEED_CORE: true

install-app:
image: owncloudci/php:${PHP_VERSION}
Expand Down Expand Up @@ -85,7 +85,6 @@ pipeline:
image: owncloudci/php:${PHP_VERSION}
pull: true
environment:
- PHP_VERSION=${PHP_VERSION}
- COVERAGE=${COVERAGE}
commands:
- if [ -z "${COVERAGE}" ]; then make test-php-unit; fi
Expand All @@ -98,20 +97,20 @@ pipeline:
image: plugins/codecov:2
secrets: [codecov_token]
pull: true
files:
- tests/output/clover.xml
paths:
- tests/output/*.xml
when:
matrix:
COVERAGE: true

notify:
image: plugins/slack:1
pull: true
secrets: [ slack_webhook ]
secrets: [slack_webhook]
channel: builds
when:
status: [ failure, changed ]
event: [ push, tag ]
status: [failure, changed]
event: [push, tag]

services:
mysql:
Expand Down Expand Up @@ -168,24 +167,28 @@ matrix:
- PHP_VERSION: 7.2
OC_VERSION: daily-master-qa
TEST_SUITE: codecheck
NEED_CORE: true
NEED_SERVER: true
NEED_INSTALL_APP: true

- PHP_VERSION: 7.2
OC_VERSION: daily-master-qa
TEST_SUITE: codecheck-deprecations
NEED_CORE: true
NEED_SERVER: true
NEED_INSTALL_APP: true

- PHP_VERSION: 7.1
OC_VERSION: daily-stable10-qa
TEST_SUITE: codecheck
NEED_CORE: true
NEED_SERVER: true
NEED_INSTALL_APP: true

- PHP_VERSION: 7.1
OC_VERSION: daily-stable10-qa
TEST_SUITE: codecheck-deprecations
NEED_CORE: true
NEED_SERVER: true
NEED_INSTALL_APP: true

Expand All @@ -195,71 +198,71 @@ matrix:
TEST_SUITE: phpunit
DB_TYPE: sqlite
DB_NAME: owncloud
NEED_SERVER: true
NEED_CORE: 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_CORE: 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_CORE: 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_CORE: 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_CORE: 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_CORE: 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_CORE: 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_CORE: 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_CORE: true
NEED_INSTALL_APP: true
COVERAGE: true

Expand All @@ -268,21 +271,21 @@ matrix:
TEST_SUITE: phpunit
DB_TYPE: oci
DB_NAME: XE
NEED_SERVER: true
NEED_CORE: 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_CORE: 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_CORE: true
NEED_INSTALL_APP: true
15 changes: 5 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,14 @@ nbproject
.well-known
/.buildpath

# Tests - auto-generated files
/tests/coverage*
/tests/clover.xml
/tests/output/clover.xml
/tests/js/node_modules
/tests/output/

build

/build/
/l10n/.transifexrc
.php_cs.cache

# Composer
composer.phar
vendor/
vendor-bin/**/composer.lock
vendor-bin/**/vendor

# Tests - auto-generated files
/tests/output
109 changes: 109 additions & 0 deletions .phan/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php
/**
* @author Patrick Jahns <[email protected]>
*
* @copyright Copyright (c) 2018, ownCloud GmbH
* @license GPL-2.0
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/

return [

// Supported values: '7.0', '7.1', '7.2', null.
// If this is set to null,
// then Phan assumes the PHP version which is closest to the minor version
// of the php executable used to execute phan.
'target_php_version' => null,

// A list of directories that should be parsed for class and
// method information. After excluding the directories
// defined in exclude_analysis_directory_list, the remaining
// files will be statically analyzed for errors.
//
// Thus, both first-party and third-party code being used by
// your application should be included in this list.
'directory_list' => [
'appinfo',
'lib',
'vendor',
'../../lib',
'../../core'
],

// A directory list that defines files that will be excluded
// from static analysis, but whose class and method
// information should be included.
//
// Generally, you'll want to include the directories for
// third-party code (such as "vendor/") in this list.
//
// n.b.: If you'd like to parse but not analyze 3rd
// party code, directories containing that code
// should be added to both the `directory_list`
// and `exclude_analysis_directory_list` arrays.
'exclude_analysis_directory_list' => [
'vendor',
'../../lib',
'../../core'
],

// A regular expression to match files to be excluded
// from parsing and analysis and will not be read at all.
//
// This is useful for excluding groups of test or example
// directories/files, unanalyzable files, or files that
// can't be removed for whatever reason.
// (e.g. '@Test\.php$@', or '@vendor/.*/(tests|Tests)/@')
'exclude_file_regex' => '@.*/[^/]*(tests|Tests|templates)/@',

// If true, missing properties will be created when
// they are first seen. If false, we'll report an
// error message.
"allow_missing_properties" => false,

// If enabled, allow null to be cast as any array-like type.
// This is an incremental step in migrating away from null_casts_as_any_type.
// If null_casts_as_any_type is true, this has no effect.
"null_casts_as_any_type" => true,

// Backwards Compatibility Checking. This is slow
// and expensive, but you should consider running
// it before upgrading your version of PHP to a
// new version that has backward compatibility
// breaks.
'backward_compatibility_checks' => false,

// The initial scan of the function's code block has no
// type information for `$arg`. It isn't until we see
// the call and rescan test()'s code block that we can
// detect that it is actually returning the passed in
// `string` instead of an `int` as declared.
'quick_mode' => false,

// The minimum severity level to report on. This can be
// set to Issue::SEVERITY_LOW, Issue::SEVERITY_NORMAL or
// Issue::SEVERITY_CRITICAL. Setting it to only
// critical issues is a good place to start on a big
// sloppy mature code base.
'minimum_severity' => 5,

// A set of fully qualified class-names for which
// a call to parent::__construct() is required
'parent_constructor_required' => [
],

];
44 changes: 43 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
# later. See the COPYING file.
# @author Ilja Neumann <[email protected]>

SHELL := /bin/bash

COMPOSER_BIN := $(shell command -v composer 2> /dev/null)
ifndef COMPOSER_BIN
$(error composer is not available on your system, please install composer)
endif

app_name=$(notdir $(CURDIR))
project_directory=$(CURDIR)/../$(app_name)
Expand All @@ -11,8 +17,14 @@ source_package_name=$(source_build_directory)/$(app_name)
appstore_build_directory=$(CURDIR)/build/artifacts/appstore
appstore_package_name=$(appstore_build_directory)/$(app_name)
npm=$(shell which npm 2> /dev/null)
composer=$(shell which composer 2> /dev/null)

# dependency folders (leave empty if not required)
composer_deps=
composer_dev_deps=
nodejs_deps=
bower_deps=

# signing
occ=$(CURDIR)/../../occ
private_key=$(HOME)/.owncloud/certificates/$(app_name).key
certificate=$(HOME)/.owncloud/certificates/$(app_name).crt
Expand All @@ -30,6 +42,14 @@ endif
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

.DEFAULT_GOAL := help

# start with displaying help
help:
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

# Removes the appstore build
.PHONY: clean
Expand Down Expand Up @@ -107,6 +127,16 @@ 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

.PHONY: test-codecheck
test-codecheck: test-syntax-php
$(occ) app:check-code $(app_name) -c private -c strong-comparison
Expand Down Expand Up @@ -136,3 +166,15 @@ vendor-bin/owncloud-codestyle/vendor: vendor/bamarni/composer-bin-plugin vendor-

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.
Loading