From ba0f1abf7ac3a7f66dc29fe0000fb70405d1a84d Mon Sep 17 00:00:00 2001 From: Jason Irish Date: Sun, 6 Jan 2019 19:58:30 -0600 Subject: [PATCH] migrate to Jenkins CI (#170) * move phpunit logs to Jenkinsfile --- .scrutinizer.yml | 37 -------------- .travis.yml | 34 ------------- Jenkinsfile | 106 +++++++++++++++++++++++++++++++++++++++ composer.json | 7 ++- phpdox.xml | 126 +++++++++++++++++++++++++++++++++++++++++++++++ phpunit.xml.dist | 3 ++ 6 files changed, 241 insertions(+), 72 deletions(-) delete mode 100644 .scrutinizer.yml delete mode 100644 .travis.yml create mode 100644 Jenkinsfile create mode 100644 phpdox.xml diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 16c821b..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,37 +0,0 @@ -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] - -filter: - paths: [tests/*,code/*] diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0565903..0000000 --- a/.travis.yml +++ /dev/null @@ -1,34 +0,0 @@ -language: php - -env: - global: - - COMPOSER_ROOT_VERSION=4.0.x-dev - - CODECOV_TOKEN=4de7cd62-439d-47db-8a7b-6d9aa724b32b - - SCRUT_TOKEN=d0cb5cb06d4d296fe4d849c2bd5008934cbf8afe5d256ef146df32d935a783a6 - -matrix: - include: - - php: 7.0 - env: DB=MYSQL PHPUNIT_TEST=1 PHPCS_TEST=1 - - php: 7.1 - env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1 - - php: 5.6 - env: DB=MYSQL PHPUNIT_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 - -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 - -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 diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..3c59048 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,106 @@ +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 --coverage-clover=build/logs/clover.xml --log-junit=build/logs/junit.xml' + } + } + + /* + stage('Coverage') { + steps { + publishHTML (target: [ + allowMissing: false, + alwaysLinkToLastBuild: false, + keepAll: true, + reportDir: 'build/coverage', + reportFiles: 'index.html', + reportName: "Coverage Report" + ]) + } + } + */ + + stage("Publish Clover") { + steps { + step([$class: 'CloverPublisher', cloverReportDir: 'build/logs', cloverReportFileName: 'clover.xml']) + } + + } + + 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') + recordIssues enabledForFailure: true, tool: pmd(pattern: '**/logs/pmd.xml') + } + } +} \ No newline at end of file diff --git a/composer.json b/composer.json index 210aeb7..655f5ef 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,12 @@ }, "require-dev": { "phpunit/PHPUnit": "^5.7", - "squizlabs/php_codesniffer": "*" + "squizlabs/php_codesniffer": "*", + "phpmd/phpmd": "^2.6", + "sebastian/phpcpd": "^3.0", + "phploc/phploc": "^4.0", + "pdepend/pdepend": "^2.5", + "theseer/phpdox": "^0.11.0" }, "config": { "process-timeout": 600 diff --git a/phpdox.xml b/phpdox.xml new file mode 100644 index 0000000..8e6657b --- /dev/null +++ b/phpdox.xml @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +