Skip to content

Commit

Permalink
[ci] Add travis config, add codeception tests
Browse files Browse the repository at this point in the history
+ Initial travis integration
+ Run tests using docker
+ Initial Codeception tests (dummy) hurtom#10
+ Add codecov config
+ Codacy coverage upload
+ Code Climate coverage upload
  • Loading branch information
yukoff committed Jul 25, 2017
1 parent e3c9780 commit ef61bb4
Show file tree
Hide file tree
Showing 27 changed files with 363 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
coverage:
notify:
gitter:
default:
url: secret:kvLT+qHSbVOxA0G+9zqmoJEcsjpbzbS56X1gw0gJDtVBxHjjsvisBWfxQH/OlqPd03Ulqv6CNPSvhtuzhAKA72VzDBor/1w/AVuktCmNdepejXJKl+xcpvnU8/bD4fa8
threshold: 1%
only_pulls: false
branches: null
flags: null
paths: null
2 changes: 2 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage_clover: tests/_output/clover.xml
json_path: tests/_output/coveralls-upload.json
66 changes: 66 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
sudo: required

language: php

services:
- docker

php:
- 7.1

env:
global:
- DOCKER_COMPOSE_VERSION=1.14.0
# Codacy
# Code Climate
matrix:
- COMPOSER_FLAGS="--prefer-lowest"
- COMPOSER_FLAGS=""

notifications:
webhooks:
urls:
- secure: "Y1c9BAQwPLcz1ux2yxzyeFkNblIJuwSnwrnBSEwL4stIn+d4OktoJ0mxir+L9fzVhOkzOX1qRQr9cV8H37SENiI5WEmfTyQQ775TIXwUjGEgI7Rl9sUN7Cl12/tsA6TQDPxy+R9JeHzjZUwp/56K3hZi8TdK/mNQCcrFAabAdZZYaJTx5Uzm4vkWi20/uDDF0tTh4V79MUfAQ+OoMi7VO7BgQuR38cZEfD59i/A9dN2/Su1VVeeQd2Rw1j4S8rcvGaYb7Yhm51gMtPVNnA1LjwXxVPZ+/z8w8v3a1FAzwp+/+jDKVIY5+XEC96HeOwVXLbPscubJ6T5dqDjJ17SDgcNNYOg6WH6kfiJi3Ec7tMjeCJ/Ujsm8X6H2A0B7+n2Q1+Kd1jVtbGNwbdUVoxY7vp52839OzA1+qIcKLFVREGub81b/XAfJ1HJz6dYcJnX5VCIJ9PN5hiitAhrbWVLzdQhZ4ujiJxwIFiC+HQETq0TNqf2IgGkc135ihOR7H0fzvXIijq0eDhWfqERmUc4NLZRGp82ikWHq8tF8e2ipfjOulTPx6qcCrXHMiHkFe7F02cqVSqtJxRKu2Rhg6+IJ3Wsz73jx1GOqrk8+MKpkwY67yuN3qwGC11wOtv+CbP8O67iNxYZ4pKhRMuNwcibCTRzj5XpQveBoMQiRu8AkmeA="
# on_* options: [always|never|change] default: always
on_success: change
on_failure: always
on_start: never

before_install:
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
- docker-compose --version

before_script:
- test $(grep -q memory_limit docker/php.ini) || echo 'memory_limit=-1' >> docker/php.ini
- docker-compose pull
- docker-compose up -d
- docker-compose exec -T toloka chown -R 33:33 /var/www
- docker-compose exec -T toloka chmod -R a+w /var/www/html/tests/_output
- travis_retry docker-compose exec -T toloka composer self-update
- travis_retry docker-compose exec -T -u 33 toloka composer update --no-interaction --prefer-dist ${COMPOSER_FLAGS}

script:
- docker-compose exec -T -u 33 toloka composer test:unit:clover

after_script:
### Codacy
- vendor/bin/codacycoverage clover tests/_output/clover.xml
### Scrutinizer
#- vendor/bin/ocular code-coverage:upload --format=php-clover tests/_output/clover.xml
### Coveralls
- vendor/bin/coveralls -v -x tests/_output/clover.xml
### Code Climate
- if [ $TRAVIS_PULL_REQUEST = 'false' ]; then vendor/bin/test-reporter --coverage-report=tests/_output/clover.xml; fi
### stop docker at the end
- docker-compose stop

after_success:
- bash <(curl -s https://codecov.io/bash)

addons:
hosts:
- toloka.dev
- toloka.local
12 changes: 12 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
coverage:
enabled: true
extensions:
enabled:
- Codeception\Extension\RunFailed
2 changes: 2 additions & 0 deletions common.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
define('TIMESTART', utime());
define('TIMENOW', time());

@include __DIR__.'/c3.php';

if (empty($_SERVER['REMOTE_ADDR'])) {
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
}
Expand Down
35 changes: 34 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,44 @@
"symfony/dotenv": "^3.3",
"symfony/var-dumper": "^3.3"
},
"require-dev": {
"codacy/coverage": "dev-master",
"codeclimate/php-test-reporter": "dev-master",
"phpunit/phpunit": "^5.0",
"satooshi/php-coveralls" : "^1.0",
"sebastian/phpcpd": "^2.0",
"scrutinizer/ocular": "^1.3",
"squizlabs/php_codesniffer": "^2.7|^3.0",
"codeception/codeception": "^2.3",
"codeception/c3": "^2.0"
},
"autoload": {
"psr-4": {
"TorrentPier\\": "src/"
}
},
"minimum-stability": "stable",
"prefer-stable": true
"prefer-stable": true,
"scripts": {
"test": [
"echo 'NOTE: Instead of running <composer test:lint> linting should be done with StyleCI'",
"composer test:unit",
"composer test:cpd"
],
"test:lint": [
"vendor/bin/phpcs --colors --report-full --standard=PSR2 src tests"
],
"test:unit": [
"vendor/bin/codecept run --steps --coverage --coverage-text"
],
"test:unit:html": [
"vendor/bin/codecept run --steps --coverage --coverage-html"
],
"test:unit:clover": [
"vendor/bin/codecept run --steps --coverage --coverage-xml=clover.xml"
],
"test:cpd": [
"vendor/bin/phpcpd --exclude=vendor --exclude=internal_data ."
]
}
}
Empty file added tests/_data/.gitkeep
Empty file.
2 changes: 2 additions & 0 deletions tests/_output/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
Empty file added tests/_support/.gitkeep
Empty file.
26 changes: 26 additions & 0 deletions tests/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php


/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;

/**
* Define custom actions here
*/
}
26 changes: 26 additions & 0 deletions tests/_support/ApiTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php


/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class ApiTester extends \Codeception\Actor
{
use _generated\ApiTesterActions;

/**
* Define custom actions here
*/
}
26 changes: 26 additions & 0 deletions tests/_support/FunctionalTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php


/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;

/**
* Define custom actions here
*/
}
9 changes: 9 additions & 0 deletions tests/_support/Helper/Acceptance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
namespace Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Acceptance extends \Codeception\Module
{
}
9 changes: 9 additions & 0 deletions tests/_support/Helper/Api.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
namespace Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Api extends \Codeception\Module
{
}
9 changes: 9 additions & 0 deletions tests/_support/Helper/Functional.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
namespace Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Functional extends \Codeception\Module
{
}
9 changes: 9 additions & 0 deletions tests/_support/Helper/Unit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
namespace Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Unit extends \Codeception\Module
{
}
26 changes: 26 additions & 0 deletions tests/_support/UnitTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php


/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;

/**
* Define custom actions here
*/
}
2 changes: 2 additions & 0 deletions tests/_support/_generated/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
12 changes: 12 additions & 0 deletions tests/acceptance.suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.

actor: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: http://toloka.dev
- \Helper\Acceptance
20 changes: 20 additions & 0 deletions tests/acceptance/FirstCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php


class FirstCest
{
public function _before(AcceptanceTester $I)
{
}

public function _after(AcceptanceTester $I)
{
}

// tests
public function frontpageWorks(AcceptanceTester $I)
{
$I->amOnPage('/');
$I->see('Домашня');
}
}
7 changes: 7 additions & 0 deletions tests/api.suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
actor: ApiTester
modules:
enabled:
- REST:
url: http://toloka.dev/api/v1/
depends: PhpBrowser
part: Json
10 changes: 10 additions & 0 deletions tests/api/ApiCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
class ApiCest
{
public function tryApi(ApiTester $I)
{
$I->sendGET('/');
$I->seeResponseCodeIs(200);
//$I->seeResponseIsJson();
}
}
12 changes: 12 additions & 0 deletions tests/functional.suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Codeception Test Suite Configuration
#
# Suite for functional tests
# Emulate web requests and make application process them
# Include one of framework modules (Symfony2, Yii2, Laravel5) to use it
# Remove this suite if you don't use frameworks

actor: FunctionalTester
modules:
enabled:
# add a framework module here
- \Helper\Functional
Empty file added tests/functional/.gitkeep
Empty file.
9 changes: 9 additions & 0 deletions tests/unit.suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Codeception Test Suite Configuration
#
# Suite for unit or integration tests.

actor: UnitTester
modules:
enabled:
- Asserts
- \Helper\Unit
Empty file added tests/unit/.gitkeep
Empty file.
Loading

0 comments on commit ef61bb4

Please sign in to comment.