summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml84
-rw-r--r--Makefile199
-rw-r--r--README.md46
-rw-r--r--gulpfile.js14
-rw-r--r--package.json5
-rw-r--r--phpunit.integration.xml6
-rw-r--r--phpunit.xml4
-rw-r--r--tests/bootstrap.php12
-rw-r--r--tests/travis/php.ini2
9 files changed, 308 insertions, 64 deletions
diff --git a/.travis.yml b/.travis.yml
index f67149a0..824f4d90 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,14 @@
sudo: false
-language: node_js
+dist: trusty
+language: php
+php:
+ - 5.6
+ - 7
+env:
+ global:
+ - CORE_BRANCH=stable9
+ matrix:
+ - DB=pgsql
branches:
only:
@@ -7,23 +16,66 @@ branches:
- /^stable\d+(\.\d+)?$/
- /^v\d++(\.\d+)?+(\.\d+)?+(\.\d+)?$/
+matrix:
+ allow_failures:
+ - env: DB=pgsql CORE_BRANCH=master
+ include:
+ - php: 5.6
+ env: DB=sqlite
+ - php: 5.6
+ env: DB=mysql
+ - php: 5.6
+ env: DB=pgsql CORE_BRANCH=master
+ fast_finish: true
+
before_install:
- - export DISPLAY=:99.0
- - sh -e /etc/init.d/xvfb start
+ - export DISPLAY=:99.0
+ - sh -e /etc/init.d/xvfb start
+ - nvm install 5.6
+ - npm install -g npm@latest
+ - make dist
+ # install core
+ - cd ../
+ - git clone https://github.com/owncloud/core.git --recursive --depth 1 -b $CORE_BRANCH owncloud
+ - mv contacts owncloud/apps/
+
+before_script:
+ - if [[ "$DB" == 'pgsql' ]]; then createuser -U travis -s oc_autotest; fi
+ - if [[ "$DB" == 'mysql' ]]; then mysql -u root -e 'create database oc_autotest;'; fi
+ - if [[ "$DB" == 'mysql' ]]; then mysql -u root -e "CREATE USER 'oc_autotest'@'localhost' IDENTIFIED BY '';"; fi
+ - if [[ "$DB" == 'mysql' ]]; then mysql -u root -e "grant all on oc_autotest.* to 'oc_autotest'@'localhost';"; fi
+ # fill owncloud with default configs and enable contacts
+ - cd owncloud
+ - mkdir data
+ - ./occ maintenance:install --database-name oc_autotest --database-user oc_autotest --admin-user admin --admin-pass admin --database $DB --database-pass=''
+ - ./occ app:enable contacts
+ - ./occ background:cron # enable default cron
+ - php -S localhost:8080 &
+ - cd apps/contacts
script:
- - node_modules/.bin/bower install
- - node_modules/.bin/gulp eslint
- - node_modules/.bin/gulp
- - npm test
- - make appstore_package
+ - make test
+
+after_failure:
+ - cat ../../data/owncloud.log
+
+after_success:
+ # codecov has issues when not run exactly in the cloned folder on travis, so
+ # revert everything
+ - cd ../../../
+ - mv owncloud/apps/contacts .
+ - cd contacts
+ - node_modules/codecov/bin/codecov
deploy:
- provider: releases
- api_key:
- secure: IBNQc4MsBqOc6bj2fD1PnMFfELFpP2GqpZjmBsqP43dWixo8vZzafg7JwlsfnuC0rfcOE/2NwHQl43d+37sXMbMl+ZXgz2ax/wOyLAS2PK/EQEDkzYOdI0E/8u2D7V7m9LlCQ8MOGSGmjYwFcDLzcmgU8AOWg4N85ktpOkaiVF1287Rr+wcRZ0o4/VTVvykYzfKDIBaACAX+EaXtpBtD0cTr1lFN4vKuUma2+iX+MyPVZcvIbCWv2bTzqXzfkT3NagZuFXcooXhvPGFoOb8AisxRSoVP48Vpt8ziG+7wDFlIrNe+fjNJxOEMDEP8cYljoUU6MaOxcm012s/CqHjWBuTI5MRAWlH4w9YJ/1BhFoSJOUb21401zp255puPZJ+Vq8i720F21xm7g7Vc/1NsEAwmTzLgaG8cnV98SonITVDuR4qIaMWpHwTMhap6sHMW7UfH4QnCKypo1mgITFdjM9ANYbcfF8GBfrK4MZtuw75AcLoytFia+KnAOO7OpC93eo6Czcqu6ILOBz1XNWZcFQJTrkLKkFslZLhSSrgPrTL4Py0zVmBurxdOmoZkDcxyKmk/1ggQmZKhh7OS1TGW/7tckscwMhukLwnQiXBCQJ7VWAJ/2eaolym1+fDbqJ4z8t9q2KEfZyqlYAL4VxPqQzxwO9O19ej1WtncvpFHlQw=
- file: build/artifacts/appstore/contacts.tar.gz
- skip_cleanup: true
- on:
- repo: owncloud/contacts
- tags: true
+ provider: releases
+ api_key:
+ secure: IBNQc4MsBqOc6bj2fD1PnMFfELFpP2GqpZjmBsqP43dWixo8vZzafg7JwlsfnuC0rfcOE/2NwHQl43d+37sXMbMl+ZXgz2ax/wOyLAS2PK/EQEDkzYOdI0E/8u2D7V7m9LlCQ8MOGSGmjYwFcDLzcmgU8AOWg4N85ktpOkaiVF1287Rr+wcRZ0o4/VTVvykYzfKDIBaACAX+EaXtpBtD0cTr1lFN4vKuUma2+iX+MyPVZcvIbCWv2bTzqXzfkT3NagZuFXcooXhvPGFoOb8AisxRSoVP48Vpt8ziG+7wDFlIrNe+fjNJxOEMDEP8cYljoUU6MaOxcm012s/CqHjWBuTI5MRAWlH4w9YJ/1BhFoSJOUb21401zp255puPZJ+Vq8i720F21xm7g7Vc/1NsEAwmTzLgaG8cnV98SonITVDuR4qIaMWpHwTMhap6sHMW7UfH4QnCKypo1mgITFdjM9ANYbcfF8GBfrK4MZtuw75AcLoytFia+KnAOO7OpC93eo6Czcqu6ILOBz1XNWZcFQJTrkLKkFslZLhSSrgPrTL4Py0zVmBurxdOmoZkDcxyKmk/1ggQmZKhh7OS1TGW/7tckscwMhukLwnQiXBCQJ7VWAJ/2eaolym1+fDbqJ4z8t9q2KEfZyqlYAL4VxPqQzxwO9O19ej1WtncvpFHlQw=
+ file: build/artifacts/appstore/contacts.tar.gz
+ skip_cleanup: true
+ on:
+ repo: owncloud/contacts
+ tags: true
+
+addons:
+ firefox: "latest"
diff --git a/Makefile b/Makefile
index 0331949f..9f39e857 100644
--- a/Makefile
+++ b/Makefile
@@ -1,38 +1,175 @@
-# Makefile for building the project
+# This file is licensed under the Affero General Public License version 3 or
+# later. See the COPYING file.
+# @author Bernhard Posselt <dev@bernhard-posselt.com>
+# @copyright Bernhard Posselt 2016
-app_name=contacts
-project_dir=$(CURDIR)/../$(app_name)
-build_dir=$(CURDIR)/build/artifacts
-appstore_dir=$(build_dir)/appstore
-source_dir=$(build_dir)/source
-package_name=$(app_name)
+# Generic Makefile for building and packaging an ownCloud app which uses npm and
+# Composer.
+#
+# Dependencies:
+# * make
+# * which
+# * curl: used if phpunit and composer are not installed to fetch them from the web
+# * tar: for building the archive
+# * npm: for building and testing everything JS
+#
+# If no composer.json is in the app root directory, the Composer step
+# will be skipped. The same goes for the package.json which can be located in
+# the app root or the js/ directory.
+#
+# The npm command by launches the npm build script:
+#
+# npm run build
+#
+# The npm test command launches the npm test script:
+#
+# npm run test
+#
+# The idea behind this is to be completely testing and build tool agnostic. All
+# build tools and additional package managers should be installed locally in
+# your project, since this won't pollute people's global namespace.
+#
+# The following npm scripts in your package.json install and update the bower
+# and npm dependencies and use gulp as build system (notice how everything is
+# run from the node_modules folder):
+#
+# "scripts": {
+# "test": "node node_modules/gulp-cli/bin/gulp.js karma",
+# "prebuild": "npm install && node_modules/bower/bin/bower install && node_modules/bower/bin/bower update",
+# "build": "node node_modules/gulp-cli/bin/gulp.js"
+# },
-all: appstore
+app_name=$(notdir $(CURDIR))
+project_directory=$(CURDIR)/../$(app_name)
+build_tools_directory=$(CURDIR)/build/tools
+source_build_directory=$(CURDIR)/build/artifacts/source
+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)
+all: build
+
+# Fetches the PHP and JS dependencies and compiles the JS. If no composer.json
+# is present, the composer step is skipped, if no package.json or js/package.json
+# is present, the npm step is skipped
+.PHONY: build
+build:
+ifneq (,$(wildcard $(CURDIR)/composer.json))
+ make composer
+endif
+ifneq (,$(wildcard $(CURDIR)/package.json))
+ make npm
+endif
+ifneq (,$(wildcard $(CURDIR)/js/package.json))
+ make npm
+endif
+
+# Installs and updates the composer dependencies. If composer is not installed
+# a copy is fetched from the web
+.PHONY: composer
+composer:
+ifeq (, $(composer))
+ @echo "No composer command available, downloading a copy from the web"
+ mkdir -p $(build_tools_directory)
+ curl -sS https://getcomposer.org/installer | php
+ mv composer.phar $(build_tools_directory)
+ php $(build_tools_directory)/composer.phar install --prefer-dist
+ php $(build_tools_directory)/composer.phar update --prefer-dist
+else
+ composer install --prefer-dist
+ composer update --prefer-dist
+endif
+
+# Installs npm dependencies
+.PHONY: npm
+npm:
+ifeq (,$(wildcard $(CURDIR)/package.json))
+ cd js && $(npm) run build
+else
+ npm run build
+endif
+
+# Removes the appstore build
+.PHONY: clean
clean:
- rm -rf $(build_dir)
+ rm -rf ./build
-appstore: appstore_package
+# Same as clean but also removes dependencies installed by composer, bower and
+# npm
+.PHONY: distclean
+distclean: clean
+ rm -rf vendor
+ rm -rf node_modules
+ rm -rf js/vendor
+ rm -rf js/node_modules
-appstore_package: clean
- mkdir -p $(appstore_dir)
- tar cvzf $(appstore_dir)/$(package_name).tar.gz \
+# Builds the source and appstore package
+.PHONY: dist
+dist:
+ make source
+ make appstore
+
+# Builds the source package
+.PHONY: source
+source:
+ make build
+ rm -rf $(source_build_directory)
+ mkdir -p $(source_build_directory)
+ tar cvzf $(source_package_name).tar.gz ../$(app_name) \
+ --exclude-vcs \
+ --exclude="../$(app_name)/build" \
+ --exclude="../$(app_name)/js/node_modules" \
+ --exclude="../$(app_name)/node_modules" \
+ --exclude="../$(app_name)/*.log" \
+ --exclude="../$(app_name)/js/*.log" \
+
+# Builds the source package for the app store, ignores php and js tests
+.PHONY: appstore
+appstore:
+ make build
+ rm -rf $(appstore_build_directory)
+ mkdir -p $(appstore_build_directory)
+ tar cvzf $(appstore_package_name).tar.gz \
--exclude-vcs \
- $(project_dir)/appinfo \
- $(project_dir)/controller \
- $(project_dir)/css \
- $(project_dir)/img \
- $(project_dir)/l10n \
- $(project_dir)/templates \
- $(project_dir)/js/public \
- $(project_dir)/js/dav/dav.js \
- $(project_dir)/js/vendor/angular/angular.js \
- $(project_dir)/js/vendor/angular-route/angular-route.js \
- $(project_dir)/js/vendor/angular-cache/dist/angular-cache.js \
- $(project_dir)/js/vendor/angular-uuid4/angular-uuid4.js \
- $(project_dir)/js/vendor/vcard/src/vcard.js \
- $(project_dir)/js/vendor/angular-bootstrap/ui-bootstrap.min.js \
- $(project_dir)/js/vendor/angular-bootstrap/ui-bootstrap-tpls.min.js \
- $(project_dir)/js/vendor/angular-sanitize/angular-sanitize.js \
- $(project_dir)/js/vendor/ui-select/dist/select.js \
- $(project_dir)/js/vendor/jquery-timepicker/jquery.ui.timepicker.js
+ $(project_directory)/appinfo \
+ $(project_directory)/controller \
+ $(project_directory)/css \
+ $(project_directory)/img \
+ $(project_directory)/l10n \
+ $(project_directory)/templates \
+ $(project_directory)/js/public \
+ $(project_directory)/js/dav/dav.js \
+ $(project_directory)/js/vendor/angular/angular.js \
+ $(project_directory)/js/vendor/angular-route/angular-route.js \
+ $(project_directory)/js/vendor/angular-cache/dist/angular-cache.js \
+ $(project_directory)/js/vendor/angular-uuid4/angular-uuid4.js \
+ $(project_directory)/js/vendor/vcard/src/vcard.js \
+ $(project_directory)/js/vendor/angular-bootstrap/ui-bootstrap.min.js \
+ $(project_directory)/js/vendor/angular-bootstrap/ui-bootstrap-tpls.min.js \
+ $(project_directory)/js/vendor/angular-sanitize/angular-sanitize.js \
+ $(project_directory)/js/vendor/ui-select/dist/select.js \
+ $(project_directory)/js/vendor/jquery-timepicker/jquery.ui.timepicker.js
+
+# Command for running JS and PHP tests. Works for package.json files in the js/
+# and root directory. If phpunit is not installed systemwide, a copy is fetched
+# from the internet
+.PHONY: test
+test:
+ifneq (,$(wildcard $(CURDIR)/js/package.json))
+ cd js && $(npm) run test
+endif
+ifneq (,$(wildcard $(CURDIR)/package.json))
+ $(npm) run test
+endif
+ifeq (, $(shell which phpunit 2> /dev/null))
+ @echo "No phpunit command available, downloading a copy from the web"
+ mkdir -p $(build_tools_directory)
+ curl -sSL https://phar.phpunit.de/phpunit.phar -o $(build_tools_directory)/phpunit.phar
+ php $(build_tools_directory)/phpunit.phar -c phpunit.xml --coverage-clover build/php-unit.clover
+ php $(build_tools_directory)/phpunit.phar -c phpunit.integration.xml --coverage-clover build/php-integration.clover
+else
+ phpunit -c phpunit.xml --coverage-clover build/php-unit.clover
+ phpunit -c phpunit.integration.xml --coverage-clover build/php-unit.clover
+endif
diff --git a/README.md b/README.md
index 76085bbc..aa0acd7d 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# ownCloud Contacts
+# ownCloud Contacts
[![irc](https://img.shields.io/badge/irc%20channel-%23owncloud--contacts%20on%20freenode-blue.svg)](https://webchat.freenode.net/?channels=owncloud-contacts)
[![Build Status](https://scrutinizer-ci.com/g/owncloud/contacts/badges/build.png?b=master)](https://scrutinizer-ci.com/g/owncloud/contacts/build-status/master)
@@ -9,7 +9,7 @@
**A contacts app for [ownCloud](https://owncloud.org).**
-This is the new contacts app that has replaced the [old contacts app](https://github.com/owncloudarchive/contacts) with ownCloud 9.0, and is only the frontend for the new CardDAV-Backend which has moved into the [ownCloud Core](https://github.com/owncloud/core).
+This is the new contacts app that has replaced the [old contacts app](https://github.com/owncloudarchive/contacts) with ownCloud 9.0, and is only the frontend for the new CardDAV-Backend which has moved into the [ownCloud Core](https://github.com/owncloud/core).
![](https://raw.githubusercontent.com/owncloud/screenshots/master/contacts/contacts.png)
@@ -17,9 +17,49 @@ This is the new contacts app that has replaced the [old contacts app](https://gi
- [Thomas Müller](https://github.com/DeepDiver1975)
- [Hendrik Leppelsack](https://github.com/Henni)
-- [Jan-Christoph Borchardt](https://github.com/jancborchardt)
+- [Jan-Christoph Borchardt](https://github.com/jancborchardt)
- [Alexander Weidinger](https://github.com/irgendwie)
- [Tom Needham](https://github.com/tomneedham)
If you’d like to join, just go through the [issue list](https://github.com/owncloud/contacts/issues) and fix some. :)
+
+
+## Building the app
+
+The app can be built by using the provided Makefile by running:
+
+ make
+
+This requires the following things to be present:
+* make
+* which
+* tar: for building the archive
+* curl: used if phpunit and composer are not installed to fetch them from the web
+* npm: for building and testing everything JS
+
+
+## Publish to App Store
+
+First get an account for the [App Store](http://apps.owncloud.com/) then run:
+
+ make appstore
+
+The archive is located in build/artifacts/appstore and can then be uploaded to the App Store.
+
+## Running tests
+You can use the provided Makefile to run all tests by using:
+
+ make test
+
+This will run the PHP unit and integration tests and if a package.json is present in the **js/** folder will execute **npm run test**
+
+Of course you can also install [PHPUnit](http://phpunit.de/getting-started.html) and use the configurations directly:
+
+ phpunit -c phpunit.xml
+
+or:
+
+ phpunit -c phpunit.integration.xml
+
+for integration tests
diff --git a/gulpfile.js b/gulpfile.js
index 9dea8248..52794481 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -2,9 +2,10 @@ var gulp = require('gulp'),
concat = require('gulp-concat'),
eslint = require('gulp-eslint'),
ngAnnotate = require('gulp-ng-annotate'),
+ KarmaServer = require('karma').Server,
sourcemaps = require('gulp-sourcemaps');
-gulp.task('js', function() {
+gulp.task('default', ['eslint'], function() {
return gulp.src([
'js/main.js',
'js/components/**/*.js',
@@ -12,10 +13,6 @@ gulp.task('js', function() {
'js/services/**/*.js',
'js/filters/**/*.js'
])
- // ESlint
- .pipe(eslint())
- .pipe(eslint.format())
-
// concat (+sourcemaps)
.pipe(sourcemaps.init())
.pipe(ngAnnotate({ single_quotes: true }))
@@ -42,4 +39,9 @@ gulp.task('watch', ['js'], function() {
gulp.watch(['js/**/*.js', '!js/public/**/*.js'], ['js']);
});
-gulp.task('default', ['js']);
+gulp.task('karma', (done) => {
+ new KarmaServer({
+ configFile: __dirname + '/karma.conf.js',
+ singleRun: true
+ }, done).start();
+});
diff --git a/package.json b/package.json
index 6a566fe8..3bbac320 100644
--- a/package.json
+++ b/package.json
@@ -17,13 +17,16 @@
},
"homepage": "https://github.com/owncloud/contacts#readme",
"scripts": {
- "test": "karma start karma.conf.js && codecov"
+ "test": "node node_modules/gulp-cli/bin/gulp.js karma",
+ "prebuild": "npm install && npm update && node_modules/bower/bin/bower install && node_modules/bower/bin/bower update",
+ "build": "node node_modules/gulp-cli/bin/gulp.js"
},
"devDependencies": {
"bower": "",
"chai": "^3.5.0",
"codecov": ">1.0.0",
"gulp": "^3.9.0",
+ "gulp-cli": "^1.2.1",
"gulp-concat": "^2.6.0",
"gulp-eslint": "^2.0.0",
"gulp-ng-annotate": "^2.0.0",
diff --git a/phpunit.integration.xml b/phpunit.integration.xml
index 17747640..839e1a02 100644
--- a/phpunit.integration.xml
+++ b/phpunit.integration.xml
@@ -1,7 +1,7 @@
-<phpunit bootstrap="../../lib/base.php">
+<phpunit bootstrap="tests/bootstrap.php" colors="true">
<testsuites>
- <testsuite name="unit">
+ <testsuite name="integration">
<directory>./tests/integration</directory>
</testsuite>
</testsuites>
-</phpunit> \ No newline at end of file
+</phpunit>
diff --git a/phpunit.xml b/phpunit.xml
index 783af304..5c67f0a6 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -1,7 +1,7 @@
-<phpunit bootstrap="../../lib/base.php">
+<phpunit bootstrap="tests/bootstrap.php" colors="true">
<testsuites>
<testsuite name="unit">
<directory>./tests/unit</directory>
</testsuite>
</testsuites>
-</phpunit> \ No newline at end of file
+</phpunit>
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
new file mode 100644
index 00000000..8fcc88e9
--- /dev/null
+++ b/tests/bootstrap.php
@@ -0,0 +1,12 @@
+<?php
+/**
+ * ownCloud - contacts
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2016
+ */
+
+require_once __DIR__ . '/../../../tests/bootstrap.php';
diff --git a/tests/travis/php.ini b/tests/travis/php.ini
deleted file mode 100644
index 3b365b09..00000000
--- a/tests/travis/php.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-default_charset = "UTF-8"
-always_populate_raw_post_data = -1 \ No newline at end of file