diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 78d1f13d118108a7021133f0d4a00785b12e14b0..0b16bd614d78a376a1333c838df0389915485f72 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,63 +3,33 @@ variables: MYSQL_DATABASE: wordpress_tests MYSQL_ROOT_PASSWORD: mysql -before_script: - # Install dependencies - - # update the docker - - apt-get clean - - apt-get -yqq update - - # instll the required packages for the running CI tests - - apt-get -yqqf install zip unzip subversion mysql-client libmysqlclient-dev --fix-missing - - # PHP extensions - - docker-php-ext-enable mbstring mcrypt mysqli pdo_mysql intl gd zip bz2 +cache: + paths: + - $HOME/.composer + - /root/.composer +before_script: # Set up WordPress tests - - bash bin/install-wp-tests.sh wordpress_tests root mysql mysql latest true - - # Install PHPCS and WPCS - - composer global require "squizlabs/php_codesniffer=*" - - composer global require "wp-coding-standards/wpcs" - - phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs - -PHPunit:PHP5.3:MySQL: - image: tetraweb/php:5.3 - services: - - mysql:5.6 - script: - - phpcs - - phpunit + - bash bin/install-wp-tests.sh $MYSQL_DATABASE root $MYSQL_ROOT_PASSWORD mysql latest true -PHPunit:PHP5.6:MySQL: - image: tetraweb/php:5.6 - services: - - mysql:5.6 - script: - - phpcs - - phpunit - -PHPunit:PHP7.0:MySQL: - image: tetraweb/php:7.0 - services: - - mysql:5.6 - script: - - phpcs - - phpunit + # PHPUnit + - | + if [[ $(php -v) =~ "PHP 7." ]]; then + composer global require "phpunit/phpunit=6.1.*" + else + composer global require "phpunit/phpunit=4.8.*" + fi -PHPunit:PHP7.1:MySQL: - image: tetraweb/php:7.1 - services: - - mysql:5.6 - script: - - phpcs - - phpunit + # Install PHPCS and WPCS + - composer global require automattic/vipwpcs + - composer global require phpcompatibility/phpcompatibility-wp + - phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs,$HOME/.composer/vendor/automattic/vipwpcs,$HOME/.composer/vendor/phpcompatibility/php-compatibility,$HOME/.composer/vendor/phpcompatibility/phpcompatibility-paragonie,$HOME/.composer/vendor/phpcompatibility/phpcompatibility-wp PHPunit:PHP7.2:MySQL: - image: tetraweb/php:7.2 + image: containers.ethitter.com:443/docker/images/php:7.2 services: - mysql:5.6 script: - - phpcs - - phpunit + - find . -type "f" -iname "*.php" | xargs -L "1" php -l + - phpcs -n + - phpunit diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index 067d574fe8b5f88f2299e8113e0f9928a3c07f48..489f8c5656b4e66a30011c71dad78110d098b443 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -1,11 +1,12 @@ <?xml version="1.0"?> -<ruleset name="WordPress Coding Standards based custom ruleset for your plugin"> +<ruleset name="View All Posts Pages"> <description>Generally-applicable sniffs for WordPress plugins.</description> <!-- What to scan --> <file>.</file> <exclude-pattern>/vendor/</exclude-pattern> <exclude-pattern>/node_modules/</exclude-pattern> + <exclude-pattern>/tests/*</exclude-pattern> <!-- How to scan --> <!-- Usage instructions: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage --> @@ -18,27 +19,27 @@ <!-- Rules: Check PHP version compatibility --> <!-- https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions --> - <config name="testVersion" value="5.3-"/> + <config name="testVersion" value="7.2-"/> <!-- https://github.com/PHPCompatibility/PHPCompatibilityWP --> <rule ref="PHPCompatibilityWP"/> <!-- Rules: WordPress Coding Standards --> <!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards --> <!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties --> - <config name="minimum_supported_wp_version" value="4.6"/> - <rule ref="WordPress"> - <exclude name="WordPress.VIP"/> - </rule> + <config name="minimum_supported_wp_version" value="3.2.1"/> + <rule ref="WordPress" /> + <rule ref="WordPressVIPMinimum" /> + <rule ref="WordPress-VIP-Go" /> <rule ref="WordPress.NamingConventions.PrefixAllGlobals"> <properties> <!-- Value: replace the function, class, and variable prefixes used. Separate multiple prefixes with a comma. --> - <property name="prefixes" type="array" value="my-plugin"/> + <property name="prefixes" type="array" value="view_all_posts_pages,vapp"/> </properties> </rule> <rule ref="WordPress.WP.I18n"> <properties> <!-- Value: replace the text domain used. --> - <property name="text_domain" type="array" value="my-plugin"/> + <property name="text_domain" type="array" value="view_all_posts_pages"/> </properties> </rule> <rule ref="WordPress.WhiteSpace.ControlStructureSpacing">