-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from jsirish/refactor/tests
update tests - new travis, scrutinizer, jenkinsfile
- Loading branch information
Showing
6 changed files
with
257 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,15 @@ | ||
inherit: true | ||
|
||
#Copied from https://www.adayinthelifeof.nl/2013/11/20/external-code-coverage-with-travis-scrutinizer/ | ||
tools: | ||
external_code_coverage: | ||
timeout: 600 | ||
php_code_sniffer: | ||
config: | ||
standard: PSR2 | ||
php_cs_fixer: | ||
extensions: | ||
# Default: | ||
- php | ||
fixers: [] | ||
enabled: false | ||
filter: | ||
paths: [tests/*,code/*] | ||
excluded_paths: [] | ||
coding_style: | ||
php: | ||
indentation: | ||
general: | ||
use_tabs: false | ||
|
||
checks: | ||
php: | ||
code_rating: true | ||
duplication: true | ||
|
||
build: | ||
nodes: | ||
analysis: | ||
tests: | ||
override: [php-scrutinizer-run] | ||
|
||
checks: | ||
php: | ||
code_rating: true | ||
duplication: true | ||
|
||
filter: | ||
paths: [tests/*,code/*] | ||
paths: [src/*, tests/*] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,39 @@ | ||
language: php | ||
|
||
services: | ||
- mysql | ||
- postgresql | ||
|
||
env: | ||
global: | ||
- COMPOSER_ROOT_VERSION=4.0.x-dev | ||
- CODECOV_TOKEN= | ||
- SCRUT_TOKEN= | ||
- TRAVIS_NODE_VERSION="10" | ||
|
||
matrix: | ||
include: | ||
- php: 5.6 | ||
env: DB=MYSQL RECIPE_VERSION=4.3.x-dev PHPUNIT_TEST=1 | ||
- php: 7.0 | ||
env: DB=PGSQL RECIPE_VERSION=4.3.x-dev PHPUNIT_TEST=1 | ||
- php: 7.1 | ||
env: DB=MYSQL PHPUNIT_TEST=1 | ||
env: DB=MYSQL RECIPE_VERSION=4.3.x-dev PHPUNIT_TEST=1 PHPCS_TEST=1 | ||
- php: 7.2 | ||
env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1 | ||
env: DB=PGSQL RECIPE_VERSION=4.4.x-dev PHPUNIT_TEST=1 | ||
- php: 7.3 | ||
env: DB=MYSQL PHPCS_TEST=1 PHPUNIT_TEST=1 | ||
env: DB=MYSQL RECIPE_VERSION=4.x-dev PHPUNIT_COVERAGE_TEST=1 | ||
|
||
before_script: | ||
# Init PHP | ||
- phpenv rehash | ||
- phpenv config-rm xdebug.ini | ||
- echo 'memory_limit = 2048M' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini | ||
|
||
# Install composer dependencies | ||
- composer require --prefer-dist --no-update silverstripe-themes/simple:~3.2 | ||
- composer update --no-suggest --prefer-dist | ||
- composer validate | ||
- composer require --no-update silverstripe/recipe-cms:"$RECIPE_VERSION" | ||
- if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:2.1.x-dev; fi | ||
- composer install --prefer-source --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile | ||
|
||
script: | ||
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi | ||
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml && wget https://scrutinizer-ci.com/ocular.phar; fi | ||
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src/ tests/; fi | ||
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi | ||
- if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src/ tests/ *.php; fi | ||
|
||
after_success: | ||
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml -t $CODECOV_TOKEN && travis_retry php ocular.phar code-coverage:upload --format=php-clover --access-token=$SCRUT_TOKEN coverage.xml; fi | ||
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml -F php; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
pipeline { | ||
agent any | ||
stages { | ||
|
||
stage('Build') { | ||
steps { | ||
sh 'mkdir silverstripe-cache' | ||
sh 'composer require --prefer-dist --no-update silverstripe-themes/simple:~3.2' | ||
sh 'composer update --no-suggest --prefer-dist' | ||
} | ||
} | ||
|
||
stage('PHPUnit') { | ||
steps { | ||
sh 'vendor/bin/phpunit --log-junit=build/logs/junit.xml --coverage-xml=build/logs/coverage' | ||
} | ||
} | ||
|
||
stage('Checkstyle Report') { | ||
steps { | ||
sh 'vendor/bin/phpcs --report=checkstyle --report-file=build/logs/checkstyle.xml --standard=phpcs.xml.dist --extensions=php,inc --ignore=autoload.php --ignore=vendor/ src/ tests/ || exit 0' | ||
} | ||
} | ||
|
||
stage('Mess Detection Report') { | ||
steps { | ||
sh 'vendor/bin/phpmd src xml codesize,unusedcode,naming --reportfile build/logs/pmd.xml --exclude vendor/ --exclude autoload.php || exit 0' | ||
} | ||
} | ||
|
||
stage('CPD Report') { | ||
steps { | ||
sh 'vendor/bin/phpcpd --log-pmd build/logs/pmd-cpd.xml --exclude vendor src/ tests/ || exit 0' | ||
} | ||
} | ||
|
||
stage('Lines of Code') { | ||
steps { | ||
sh 'vendor/bin/phploc --count-tests --exclude vendor/ --log-csv build/logs/phploc.csv --log-xml build/logs/phploc.xml src/ tests/' | ||
} | ||
} | ||
|
||
stage('Software metrics') { | ||
steps { | ||
sh 'mkdir build/pdepend' | ||
sh 'vendor/bin/pdepend --jdepend-xml=build/logs/jdepend.xml --jdepend-chart=build/pdepend/dependencies.svg --overview-pyramid=build/pdepend/overview-pyramid.svg --ignore=vendor src' | ||
} | ||
} | ||
|
||
stage('Generate documentation') { | ||
steps { | ||
sh 'vendor/bin/phpdox -f phpdox.xml' | ||
} | ||
} | ||
|
||
stage('Publish Documentation') { | ||
steps { | ||
publishHTML (target: [ | ||
allowMissing: false, | ||
alwaysLinkToLastBuild: false, | ||
keepAll: true, | ||
reportDir: 'docs/html', | ||
reportFiles: 'index.html', | ||
reportName: "API" | ||
]) | ||
} | ||
} | ||
|
||
stage('Cleanup') { | ||
steps { | ||
sh 'rm -rf silverstripe-cache' | ||
} | ||
} | ||
} | ||
|
||
post { | ||
always { | ||
junit 'build/logs/*.xml' | ||
recordIssues enabledForFailure: true, tool: checkStyle(pattern: '**/logs/checkstyle.xml') | ||
recordIssues enabledForFailure: true, tool: cpd(pattern: '**/logs/pmd-cpd.xml') | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- This is a skeleton phpDox config file - Check http://phpDox.de for latest version and more info --> | ||
<phpdox xmlns="http://xml.phpdox.net/config" silent="false"> | ||
<!-- @silent: true | false to enable or disable visual output of progress --> | ||
|
||
<!-- Additional bootstrap files to load for additional parsers, enrichers and/or engines --> | ||
<!-- Place as many require nodes as you feel like in this container --> | ||
<!-- syntax: <require file="/path/to/file.php" /> --> | ||
<bootstrap /> | ||
|
||
<!-- A phpDox project to process, you can have multiple projects in one config file --> | ||
<project name="phpdox" source="${basedir}/src" workdir="${basedir}/build/phpdox/xml"> | ||
<!-- @name - The name of the project --> | ||
<!-- @source - The source directory of the application to process --> | ||
<!-- @workdir - The directory to store the xml data files in --> | ||
|
||
<!-- A phpDox config file can define additional variables (properties) per project --> | ||
<!-- <property name="some.name" value="the.value" /> --> | ||
|
||
<!-- Values can make use of previously defined properties --> | ||
<!-- The following are defined by default: | ||
${basedir} Directory the loaded config file is in | ||
${phpDox.home} Directory of the phpDox installation | ||
${phpDox.file} The current config file | ||
${phpDox.version} phpDox' version number | ||
${phpDox.project.name} The value of project/@name if set, otherwise 'unnamed' | ||
${phpDox.project.source} The value of project/@source if set, otherwise '${basedir}/src' | ||
${phpDox.project.workdir} The value of project/@workdir if set, otherwise '${basedir}/build/phpdox/xml' | ||
${phpDox.php.version} The PHP Version of the interpreter in use | ||
--> | ||
|
||
<!-- Additional configuration for the collecting process (parsing of php code, generation of xml data) --> | ||
<collector publiconly="false" backend="parser" encoding="auto"> | ||
<!-- @publiconly - Flag to disable/enable processing of non public methods and members --> | ||
<!-- @backend - The collector backend to use, currently only shipping with 'parser' --> | ||
<!-- @encoding - Charset encoding of source files (overwrite default 'auto' if detection fails) --> | ||
|
||
<!-- <include / exclude filter for filelist generator, mask must follow fnmatch() requirements --> | ||
<!-- Multiple elements can be added to define more than one mask per filter --> | ||
<include mask="*.php" /> | ||
<exclude mask="" /> | ||
|
||
<!-- How to handle inheritance --> | ||
<inheritance resolve="true"> | ||
<!-- @resolve - Flag to enable/disable resolving of inheritance --> | ||
|
||
<!-- You can define multiple (external) dependencies to be included --> | ||
<!-- <dependency path="" --> | ||
<!-- @path - path to a directory containing an index.xml for a dependency project --> | ||
</inheritance> | ||
|
||
</collector> | ||
|
||
<!-- Configuration of generation process --> | ||
<generator output="${basedir}/docs"> | ||
<!-- @output - (Base-)Directory to store output data in --> | ||
|
||
<!-- A generation process consists of one or more build tasks and of (optional) enrich sources --> | ||
|
||
<enrich base="${basedir}/build"> | ||
<!-- @base - (Base-)Directory of datafiles used for enrich process --> | ||
|
||
<!--<source type="...">--> | ||
<!-- @type - the handler for the enrichment --> | ||
<!-- known types by default are: build, checkstyle, git, phpcs, phploc, phpunit, pmd --> | ||
|
||
<!-- every enrichment source can have additional configuration nodes, most probably need a logfile --> | ||
<!-- <file name="path/to/log.xml" /> --> | ||
<!--</source> --> | ||
|
||
<!-- add phploc output --> | ||
<source type="phploc"> | ||
<file name="logs/phploc.xml" /> | ||
</source> | ||
|
||
<!-- git vcs information --> | ||
<source type="git"> | ||
<git binary="/usr/bin/git" /> | ||
<history enabled="true" limit="15" cache="${phpDox.project.workdir}/gitlog.xml" /> | ||
</source> | ||
|
||
<!-- PHP Code Sniffer findings --> | ||
<source type="phpcs"> | ||
<file name="logs/checkstyle.xml" /> | ||
</source> | ||
|
||
<!-- PHPMessDetector --> | ||
<source type="pmd"> | ||
<file name="logs/pmd-cpd.xml" /> | ||
</source> | ||
|
||
<!-- PHPUnit Coverage XML --> | ||
<source type="phpunit"> | ||
<coverage path="logs/coverage" /> | ||
<!-- @path - the directory where the xml code coverage report can be found --> | ||
</source> | ||
<!-- | ||
<source type="phpunit"> | ||
<filter directory="${phpDox.project.source}" /> | ||
</source> | ||
--> | ||
|
||
</enrich> | ||
|
||
<!-- <build engine="..." enabled="true" output="..." /> --> | ||
<!-- @engine - The name of the engine this build task uses, use ./phpDox - -engines to get a list of available engines --> | ||
<!-- @enabled - Flag to enable/disable this engine, default: enabled=true --> | ||
<!-- @output - (optional) Output directory; if relative (no / as first char) it is interpreted as relative to generator/@output --> | ||
|
||
<!-- An engine and thus build node can have additional configuration child nodes, please check the documentation for the engine to find out more --> | ||
|
||
<!-- default engine "html" --> | ||
<build engine="html" enabled="true" output="html"> | ||
<template dir="${phpDox.home}/templates/html" /> | ||
<file extension="html" /> | ||
</build> | ||
|
||
</generator> | ||
</project> | ||
|
||
</phpdox> |