Merge pull request #459 from robbieaverill/pulls/3.0/fix-travis

FIX Update Travis configuration and coverage whitelist
This commit is contained in:
Daniel Hensby 2017-07-20 09:48:13 +01:00 committed by GitHub
commit a28861c352
8 changed files with 58 additions and 48 deletions

View File

@ -1,50 +1,39 @@
language: php # See https://github.com/silverstripe/silverstripe-travis-support for setup details
sudo: false sudo: false
addons: language: php
apt:
packages:
- tidy
before_install:
- pip install --user codecov
env: env:
global: global:
# Turn coverage off by default, as it's expensive time wise - COMPOSER_ROOT_VERSION="4.0.x-dev"
- COVERAGE=0
# The path of the module when installed by composer
- MODULE_PATH=blog
matrix: matrix:
include: include:
- php: 5.6 - php: 5.6
env: DB=MYSQL CORE_RELEASE=4 COVERAGE=1 env: DB=MYSQL PHPCS_TEST=1 PHPUNIT_TEST=1
- php: 7.0 - php: 7.0
env: DB=PGSQL CORE_RELEASE=4 env: DB=PGSQL PHPUNIT_TEST=1
- php: 7.1.2 - php: 7.1
env: DB=MYSQL CORE_RELEASE=4 env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1
before_script: before_script:
# Init PHP
- phpenv rehash - phpenv rehash
- composer self-update || true - phpenv config-rm xdebug.ini
- git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support - echo 'memory_limit = 2G' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss --require "silverstripe/comments" --require "silverstripe/widgets"
- cd ~/builds/ss # Install composer dependencies
- mv "$MODULE_PATH/phpunit.xml.dist" . - composer install --prefer-dist
- composer require --prefer-dist --no-update symfony/config:^3.2 silverstripe/framework:4.0.x-dev silverstripe/cms:4.0.x-dev silverstripe/admin:1.0.x-dev silverstripe/assets:1.0.x-dev silverstripe/versioned:1.0.x-dev
- composer update
- if [[ $DB == PGSQL ]]; then composer require silverstripe/postgresql:2.0.x-dev --prefer-dist; fi
#Execute tests with or without coverage
script: script:
# Execute tests with no coverage. This is the fastest option - if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests/; fi
- "if [ \"$COVERAGE\" = \"0\" ]; then vendor/bin/phpunit $MODULE_PATH/tests/; fi" - if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml tests/; fi
- if [[ $PHPCS_TEST ]]; then composer run-script lint; fi
# Execute tests with coverage. Do this for a small
- "if [ \"$COVERAGE\" = \"1\" ]; then vendor/bin/phpunit --coverage-clover=coverage.clover $MODULE_PATH/tests/; fi"
# Upload code coverage when tests pass
after_success: after_success:
- "if [ \"$COVERAGE\" = \"1\" ]; then mv coverage.clover ~/build/$TRAVIS_REPO_SLUG/; fi" - if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi
- cd ~/build/$TRAVIS_REPO_SLUG
- "if [ \"$COVERAGE\" = \"1\" ]; then travis_retry codecov; fi"

View File

@ -10,10 +10,13 @@
"require": { "require": {
"silverstripe/cms": "^4.0", "silverstripe/cms": "^4.0",
"silverstripe/lumberjack": "^2.0", "silverstripe/lumberjack": "^2.0",
"silverstripe/tagfield": "^2.0" "silverstripe/tagfield": "^2.0",
"silverstripe/assets": "^1.0@dev",
"silverstripe/asset-admin": "^1.0@dev"
}, },
"require-dev": { "require-dev": {
"phpunit/PHPUnit": "~4.8" "phpunit/PHPUnit": "^5.7",
"squizlabs/php_codesniffer": "*"
}, },
"extra": { "extra": {
"branch-alias": { "branch-alias": {
@ -37,6 +40,10 @@
"silverstripe/widgets": "Some widgets come with the blog which are compatible with the widgets module.", "silverstripe/widgets": "Some widgets come with the blog which are compatible with the widgets module.",
"silverstripe/comments": "This module adds comments to your blog." "silverstripe/comments": "This module adds comments to your blog."
}, },
"scripts": {
"lint": "vendor/bin/phpcs src/ tests/",
"lint-clean": "vendor/bin/phpcbf src/ tests/"
},
"replace": { "replace": {
"micmania1/silverstripe-blog": "*" "micmania1/silverstripe-blog": "*"
}, },

22
phpcs.xml.dist Normal file
View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>
<!-- base rules are PSR-2 -->
<rule ref="PSR2" >
<!-- Current exclusions -->
<exclude name="PSR1.Methods.CamelCapsMethodName" />
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols" />
<exclude name="PSR2.Classes.PropertyDeclaration" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration" /> <!-- causes php notice while linting -->
<exclude name="PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration.WrongOpenerdefault" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration.TerminatingComment" />
<exclude name="PSR2.Methods.MethodDeclaration.Underscore" />
<exclude name="Squiz.Scope.MethodScope" />
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
<exclude name="Generic.Files.LineLength.TooLong" />
<exclude name="PEAR.Functions.ValidDefaultValue.NotAtEnd" />
</rule>
</ruleset>

View File

@ -1,17 +1,13 @@
<phpunit bootstrap="framework/tests/bootstrap.php" colors="true"> <phpunit bootstrap="cms/tests/bootstrap.php" colors="true">
<testsuite name="blog"> <testsuite name="blog">
<directory>blog/tests</directory> <directory>tests/</directory>
</testsuite> </testsuite>
<listeners>
<listener class="SilverStripe\Dev\TestListener" />
</listeners>
<filter> <filter>
<whitelist addUncoveredFilesFromWhitelist="true"> <whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">blog/src/</directory> <directory suffix=".php">src/</directory>
<exclude> <exclude>
<directory suffix=".php">blog/tests/</directory> <directory suffix=".php">tests/</directory>
</exclude> </exclude>
</whitelist> </whitelist>
</filter> </filter>

View File

@ -6,7 +6,6 @@ use SilverStripe\Blog\Model\BlogPost;
use SilverStripe\Lumberjack\Forms\GridFieldSiteTreeState; use SilverStripe\Lumberjack\Forms\GridFieldSiteTreeState;
use SilverStripe\View\Requirements; use SilverStripe\View\Requirements;
/** /**
* Provides a component to the {@link GridField} which tells the user whether or not a blog post * Provides a component to the {@link GridField} which tells the user whether or not a blog post
* has been published and when. * has been published and when.

View File

@ -221,7 +221,7 @@ class BlogController extends PageController
if ($tag) { if ($tag) {
$this->blogPosts = $tag->BlogPosts(); $this->blogPosts = $tag->BlogPosts();
if($this->isRSS()) { if ($this->isRSS()) {
return $this->rssFeed($this->blogPosts, $tag->getLink()); return $this->rssFeed($this->blogPosts, $tag->getLink());
} else { } else {
return $this->render(); return $this->render();
@ -265,7 +265,7 @@ class BlogController extends PageController
if ($category) { if ($category) {
$this->blogPosts = $category->BlogPosts(); $this->blogPosts = $category->BlogPosts();
if($this->isRSS()) { if ($this->isRSS()) {
return $this->rssFeed($this->blogPosts, $category->getLink()); return $this->rssFeed($this->blogPosts, $category->getLink());
} else { } else {
return $this->render(); return $this->render();

View File

@ -123,5 +123,3 @@ class BlogCategoriesWidget extends Widget
return $query; return $query;
} }
} }

View File

@ -215,5 +215,4 @@ class BlogTagTest extends FunctionalTest
$tag->write(); $tag->write();
$this->assertEquals($tag->URLSegment, "another-test"); $this->assertEquals($tag->URLSegment, "another-test");
} }
} }