Setup Javascript and PHP tests and badges

Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
This commit is contained in:
Raimund Schlüßler 2019-06-12 21:27:23 +02:00
parent e5c1312955
commit eb179b0087
No known key found for this signature in database
GPG Key ID: 036FA7EB1A599178
8 changed files with 225 additions and 10 deletions

View File

@ -1,18 +1,128 @@
dist: trusty
language: php
php:
- 7.0
- 7.1
- 7.2
addons:
apt:
packages:
- mysql-server-5.6
- mysql-client-core-5.6
- mysql-client-5.6
- libxml2-utils
branches:
only:
- master
- /^stable\d+(\.\d+)?$/
cache:
directories:
- "$HOME/.composer/cache/files"
- "$HOME/.npm"
env:
global:
- CORE_BRANCH=master
- PHP_COVERAGE=FALSE
- DB=mysql
before_install:
- php --info
# Set up DB
- 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
- cd ..
- git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b $CORE_BRANCH core
- mv tasks core/apps/
before_script:
# Set up core
- php -f core/occ maintenance:install --database-name oc_autotest --database-user oc_autotest --admin-user admin --admin-pass admin --database $DB --database-pass=''
# Set up app
- php -f core/occ app:enable tasks
# Enable app twice to check occ errors of registered commands
- php -f core/occ app:enable tasks
- cd core/apps/tasks
# Run JS tests
- npm install -g npm@latest
- make dev-setup
# XDebug is only needed if we report coverage -> speeds up other builds
- if [[ "$PHP_COVERAGE" = "FALSE" ]];
then phpenv config-rm xdebug.ini;
fi
script:
- make
- make test
# Check info.xml schema validity
- wget https://apps.nextcloud.com/schema/apps/info.xsd
- xmllint appinfo/info.xml --schema info.xsd --noout
- rm info.xsd
# Check PHP syntax errors
- find . -name \*.php -not -path './vendor/*' -exec php -l "{}" \;
# Run server's app code checker
- php ../../occ app:check-code tasks
# Test php
- make test-php
- if [[ "$PHP_COVERAGE" = "TRUE" ]];
then make test-php-coverage;
else make test-php;
fi
after_success:
- if [[ "$PHP_COVERAGE" = "TRUE" ]];
then bash <(curl -s https://codecov.io/bash) -cF php;
fi
after_failure:
- cat ../../data/nextcloud.log
matrix:
include:
- stage: build
language: node_js
node_js:
- "10"
before_install:
before_script:
script:
- make
after_failure:
after_success:
- stage: test
language: node_js
node_js:
- "10"
before_install:
before_script:
install:
- npm install -g codecov
script:
- make dev-setup
- make test
- bash <(curl -s https://codecov.io/bash) -cF javascript;
after_failure:
after_success:
- language: php
php: 7.1
- language: php
php: 7.2
- language: php
php: 7.3
env: "DB=mysql CORE_BRANCH=master PHP_COVERAGE=TRUE"
fast_finish: true

View File

@ -168,3 +168,11 @@ endif
.PHONY: test
test:
$(npm) run test
test-php:
phpunit -c phpunit.xml
phpunit -c phpunit.integration.xml
test-php-coverage:
phpunit -c phpunit.xml --coverage-clover=coverage-unit.xml
phpunit -c phpunit.integration.xml --coverage-clover=coverage-integration.xml

View File

@ -1,6 +1,5 @@
# Tasks
[![Build Status](https://scrutinizer-ci.com/g/nextcloud/tasks/badges/build.png?b=master)](https://scrutinizer-ci.com/g/nextcloud/tasks/build-status/master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/nextcloud/tasks/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/nextcloud/tasks/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/nextcloud/tasks/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/nextcloud/tasks/?branch=master)
![Downloads](https://img.shields.io/github/downloads/nextcloud/tasks/total.svg) [![Build Status](https://scrutinizer-ci.com/g/nextcloud/tasks/badges/build.png?b=master)](https://scrutinizer-ci.com/g/nextcloud/tasks/build-status/master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/nextcloud/tasks/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/nextcloud/tasks/?branch=master) [![Code coverage](https://img.shields.io/codecov/c/github/nextcloud/tasks.svg)](https://codecov.io/gh/nextcloud/tasks/) [![Dependabot status](https://img.shields.io/badge/Dependabot-enabled-brightgreen.svg?longCache=true&logo=dependabot)](https://dependabot.com)
**A tasks app for [Nextcloud](http://nextcloud.com). Easily sync tasks from various devices with your Nextcloud and edit them online.**

View File

@ -109,6 +109,7 @@
"snapshotSerializers": [
"<rootDir>/node_modules/jest-serializer-vue"
],
"coverageDirectory": "./coverage/",
"collectCoverage": true,
"collectCoverageFrom": [
"<rootDir>/src/**/*.{js,vue}",
@ -117,7 +118,9 @@
"coverageReporters": [
"json",
"text",
"html"
"html",
"lcov",
"clover"
]
}
}

22
phpunit.integration.xml Normal file
View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="tests/bootstrap.php"
verbose="true"
colors="true"
timeoutForSmallTests="900"
timeoutForMediumTests="900"
timeoutForLargeTests="900">
<testsuite name='Contacts app integration tests'>
<directory>./tests/integration</directory>
</testsuite>
<!-- filters for code coverage -->
<filter>
<whitelist>
<directory suffix=".php">./</directory>
<exclude>
<directory suffix=".php">./l10n</directory>
<directory suffix=".php">./templates</directory>
<directory suffix=".php">./tests</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

22
phpunit.xml Normal file
View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="tests/bootstrap.php"
verbose="true"
colors="true"
timeoutForSmallTests="900"
timeoutForMediumTests="900"
timeoutForLargeTests="900">
<testsuite name='Contacts app tests'>
<directory>./tests/unit</directory>
</testsuite>
<!-- filters for code coverage -->
<filter>
<whitelist>
<directory suffix=".php">./</directory>
<exclude>
<directory suffix=".php">./l10n</directory>
<directory suffix=".php">./templates</directory>
<directory suffix=".php">./tests</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

12
tests/bootstrap.php Normal file
View File

@ -0,0 +1,12 @@
<?php
/**
* Nextcloud - Tasks
*
* 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';

View File

@ -0,0 +1,39 @@
<?php
/**
* Nextcloud - Tasks
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Hendrik Leppelsack <hendrik@leppelsack.de>
* @copyright Hendrik Leppelsack 2015
*/
namespace OCA\Tasks\Controller;
use OCP\AppFramework\Http\TemplateResponse;
use PHPUnit\Framework\TestCase as Base;
class PageControllerTest extends Base {
private $controller;
public function setUp(): void {
$request = $this->getMockBuilder('OCP\IRequest')->getMock();
$this->controller = new PageController(
'tasks',
$request
);
}
public function testIndex() {
$result = $this->controller->index();
$this->assertEquals('main', $result->getTemplateName());
$this->assertEquals('user', $result->getRenderAs());
$this->assertTrue($result instanceof TemplateResponse);
}
}