Merge pull request #61 from DanielSiepmann/feature/gitlab-ci

Feature/gitlab ci
This commit is contained in:
Daniel Siepmann 2017-04-11 12:25:14 +02:00 committed by GitHub
commit a13d25f0ae
12 changed files with 140 additions and 12 deletions

50
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,50 @@
before_script:
- apk add --no-cache make wget git
- make install-composer
- make install
- mkdir -p result
stages:
- test
lint:coding-guideline:
image: php:7.0-alpine
stage: test
script:
- ./vendor/bin/phpcs -s -n
- ./vendor/bin/phpcs -s -n > result/phpcs-summary.txt
artifacts:
when: on_failure
paths:
- result
lint:php-mass-detection:
image: php:7.0-alpine
stage: test
script:
- ./vendor/bin/phpmd src text phpmd.xml > result/phpmd.txt
- ./vendor/bin/phpmd src html phpmd.xml > result/phpmd.html
artifacts:
when: on_failure
paths:
- result
test:5.6:
image: php:5.6-alpine
stage: test
script:
- ./vendor/bin/phpunit
test:7.0:
image: php:7.0-alpine
stage: test
script:
- ./vendor/bin/phpunit
test:latest:
image: php:7-alpine
stage: test
script:
- ./vendor/bin/phpunit
# Further stages, and jobs e.g. linting, cgl, etc.

View file

@ -4,7 +4,7 @@ DEFAULT_STANDARD = Typo3Update
CUSTOM_STANDARDS = $(abspath ./src/Standards/) CUSTOM_STANDARDS = $(abspath ./src/Standards/)
install: install:
composer install composer install --optimize-autoloader --no-interaction --no-ansi
$(BIN_PHPCS) --config-set installed_paths $(CUSTOM_STANDARDS) $(BIN_PHPCS) --config-set installed_paths $(CUSTOM_STANDARDS)
$(BIN_PHPCS) -i | grep Typo3Update $(BIN_PHPCS) -i | grep Typo3Update
$(BIN_PHPCS) --config-set default_standard $(DEFAULT_STANDARD) $(BIN_PHPCS) --config-set default_standard $(DEFAULT_STANDARD)
@ -14,3 +14,13 @@ test-search:
$(BIN_PHPCS) -p --colors -s PROJECT_PATH $(BIN_PHPCS) -p --colors -s PROJECT_PATH
test-fix: test-fix:
$(BIN_PHPCBF) -p --colors -s PROJECT_PATH $(BIN_PHPCBF) -p --colors -s PROJECT_PATH
# For CI:
install-composer:
wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === file_get_contents('installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php'); unlink('installer.sig');"
chmod ugo+x composer.phar
mv composer.phar /usr/local/bin/composer

View file

@ -2,6 +2,13 @@
"name": "siepmann/typo3_update", "name": "siepmann/typo3_update",
"description": "Auto migrate PHP Source of extensions to be compatible.", "description": "Auto migrate PHP Source of extensions to be compatible.",
"type": "project", "type": "project",
"license": "GPL-2.0+",
"authors": [
{
"name": "Daniel Siepmann",
"email": "coding@daniel-siepmann.de"
}
],
"autoload-dev": { "autoload-dev": {
"psr-4": { "psr-4": {
"Typo3Update\\Tests\\": "tests/" "Typo3Update\\Tests\\": "tests/"
@ -20,15 +27,10 @@
"squizlabs/php_codesniffer": "2.8.*", "squizlabs/php_codesniffer": "2.8.*",
"symfony/yaml": "3.2.*" "symfony/yaml": "3.2.*"
}, },
"license": "GPL-2.0+",
"authors": [
{
"name": "Daniel Siepmann",
"email": "coding@daniel-siepmann.de"
}
],
"require-dev": { "require-dev": {
"phpunit/phpunit": "^5.7", "phpunit/phpunit": "5.7.*",
"symfony/finder": "^3.2" "symfony/finder": "3.2.*",
"phpmd/phpmd": "2.6.*",
"pdepend/pdepend": "2.5.*"
} }
} }

22
phpcs.xml.dist Normal file
View file

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<ruleset name="PHP_CodeSniffer">
<description>The coding standard for this Project</description>
<rule ref="PSR2"/>
<file>./src</file>
<file>./tests</file>
<exclude-pattern>*/Fixtures/*</exclude-pattern>
<!-- Excludes for PHPCS Code Style -->
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>*Sniff.php$</exclude-pattern>
<exclude-pattern>*/Tokenizers/*</exclude-pattern>
</rule>
<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
<exclude-pattern>*Sniff.php$</exclude-pattern>
<exclude-pattern>*/Tokenizers/*</exclude-pattern>
</rule>
<rule ref="Squiz.Classes.ValidClassName.NotCamelCaps">
<exclude-pattern>*Sniff.php$</exclude-pattern>
<exclude-pattern>*/Tokenizers/*</exclude-pattern>
</rule>
</ruleset>

27
phpmd.xml Normal file
View file

@ -0,0 +1,27 @@
<?xml version="1.0"?>
<ruleset name="My first PHPMD rule set"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="
http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
My custom rule set that checks my code...
</description>
<rule ref="rulesets/cleancode.xml">
<exclude name="StaticAccess" />
</rule>
<rule ref="rulesets/codesize.xml">
</rule>
<rule ref="rulesets/controversial.xml">
<exclude name="CamelCaseClassName" />
</rule>
<rule ref="rulesets/design.xml">
</rule>
<rule ref="rulesets/naming.xml">
</rule>
<rule ref="rulesets/unusedcode.xml">
</rule>
</ruleset>

View file

@ -65,6 +65,8 @@ class PHP_CodeSniffer_Tokenizers_TYPOSCRIPT
* @param string $eolChar The EOL character to use for splitting strings. * @param string $eolChar The EOL character to use for splitting strings.
* *
* @return void * @return void
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter) We need to match the signature.
*/ */
public function processAdditional(&$tokens, $eolChar) public function processAdditional(&$tokens, $eolChar)
{ {

View file

@ -82,6 +82,8 @@ abstract class AbstractClassnameChecker implements PhpCsSniff
* the token was found. * the token was found.
* *
* @return void * @return void
*
* @SuppressWarnings(PHPMD.ElseExpression) This is for performance reason.
*/ */
public function process(PhpCsFile $phpcsFile, $stackPtr) public function process(PhpCsFile $phpcsFile, $stackPtr)
{ {
@ -217,6 +219,8 @@ abstract class AbstractClassnameChecker implements PhpCsSniff
* @param int $classnamePosition * @param int $classnamePosition
* @param string $classname * @param string $classname
* @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out. * @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out.
*
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/ */
protected function replaceLegacyClassname( protected function replaceLegacyClassname(
PhpCsFile $phpcsFile, PhpCsFile $phpcsFile,
@ -243,6 +247,8 @@ abstract class AbstractClassnameChecker implements PhpCsSniff
* @param string $originalClassname * @param string $originalClassname
* @param PhpCsFile $phpcsFile * @param PhpCsFile $phpcsFile
* @return string * @return string
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter) We need to match the signature.
*/ */
protected function getTokenForReplacement($newClassname, $originalClassname, PhpCsFile $phpcsFile) protected function getTokenForReplacement($newClassname, $originalClassname, PhpCsFile $phpcsFile)
{ {

View file

@ -48,6 +48,9 @@ final class Mapping
private function __clone() private function __clone()
{ {
} }
/**
* @SuppressWarnings(PHPMD.UnusedPrivateMethod) We just want to implement singleton pattern.
*/
private function __wakeup() private function __wakeup()
{ {
} }

View file

@ -95,6 +95,8 @@ class Typo3Update_Sniffs_LegacyClassnames_MissingNamespaceSniff extends Abstract
* @param int $classnamePosition * @param int $classnamePosition
* @param string $classname * @param string $classname
* @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out. * @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out.
*
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/ */
protected function replaceLegacyClassname( protected function replaceLegacyClassname(
PhpCsFile $phpcsFile, PhpCsFile $phpcsFile,

View file

@ -46,6 +46,8 @@ class Typo3Update_Sniffs_LegacyClassnames_UseSniff extends AbstractClassnameChec
* @param int $classnamePosition * @param int $classnamePosition
* @param string $classname * @param string $classname
* @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out. * @param bool $forceEmptyPrefix Defines whether '\\' prefix should be checked or always be left out.
*
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/ */
protected function replaceLegacyClassname( protected function replaceLegacyClassname(
PhpCsFile $phpcsFile, PhpCsFile $phpcsFile,

View file

@ -29,8 +29,9 @@ use Typo3Update\Sniffs\Options;
/** /**
* Contains common functionality for removed code like constants or functions. * Contains common functionality for removed code like constants or functions.
* *
* Removed parts are configured using YAML-Files, for examples see src/Standards/Typo3Update/Configuration/Removed/Constants/7.0.yaml * Removed parts are configured using YAML-Files, for examples see
* Also check out the configuration options in Readme.rst. * src/Standards/Typo3Update/Configuration/Removed/Constants/7.0.yaml Also
* check out the configuration options in Readme.rst.
*/ */
abstract class AbstractGenericUsage implements PhpCsSniff abstract class AbstractGenericUsage implements PhpCsSniff
{ {

View file

@ -115,6 +115,7 @@ class SniffsTest extends TestCase
protected function executeSniff(\SplFileInfo $folder, array $arguments = []) protected function executeSniff(\SplFileInfo $folder, array $arguments = [])
{ {
$internalArguments = array_merge_recursive([ $internalArguments = array_merge_recursive([
'standard' => 'Typo3Update',
'runtime-set' => [ 'runtime-set' => [
'mappingFile' => __DIR__ . DIRECTORY_SEPARATOR 'mappingFile' => __DIR__ . DIRECTORY_SEPARATOR
. 'Fixtures' . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR