Skip to content

Commit

Permalink
Merge branch 'release/4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
enricobattocchi committed Nov 18, 2021
2 parents 91ae849 + 0b5a7db commit 95ce770
Show file tree
Hide file tree
Showing 83 changed files with 2,134 additions and 4,023 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ tests/cli/vendor
############
## Composer
############
composer.lock
/vendor/

/js/dist/
Expand All @@ -47,3 +48,5 @@ tests/cli/vendor
.phpcs.xml
phpcs.xml
.cache/phpcs.cache
phpunit.xml
.phpunit.result.cache
136 changes: 99 additions & 37 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@

<file>.</file>

<!-- Always exclude all files in version management related directories. -->
<exclude-pattern>*/.git/*</exclude-pattern>
<exclude-pattern>*/.wordpress-svn/*</exclude-pattern>

<!-- Exclude the build tool and dependency related directories. -->
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/node_modules/*</exclude-pattern>

<!-- Only check PHP files. -->
<arg name="extensions" value="php"/>

Expand All @@ -40,25 +32,29 @@

<!--
#############################################################################
USE THE WordPress + PHPCompatibilityWP RULESETS
USE THE YoastCS RULESET
#############################################################################
-->

<!-- Include the WordPress standard. -->
<rule ref="WordPress">
<!-- No need for this sniff as every Yoast travis script includes linting all files. -->
<exclude name="Generic.PHP.Syntax"/>

<!-- WPCS demands long arrays. YoastCS demands short arrays. -->
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
<rule ref="Yoast">
<properties>
<!-- Set the custom test class list for all sniffs which use it in one go.
Ref: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#custom-unit-test-classes
-->
<property name="custom_test_class_whitelist" type="array">
<element value="Yoast\WP\Duplicate_Post\Tests\TestCase"/>
</property>

<!-- Demanding Yoda conditions is stupid. -->
<exclude name="WordPress.PHP.YodaConditions"/>
</rule>
<!-- Provide the plugin specific prefixes for all naming related sniffs. -->
<property name="prefixes" type="array">
<element value="Yoast\WP\Duplicate_Post"/>
<element value="duplicate_post"/>
<element value="dp_"/>
</property>
</properties>

<config name="testVersion" value="5.5-"/>
<rule ref="PHPCompatibilityWP">
<include-pattern>*\.php$</include-pattern>
<!-- This plugin is not dependent on YoastSEO, so the replacement function will not be available. -->
<exclude name="Yoast.Yoast.AlternativeFunctions.json_encode_wp_json_encode"/>
</rule>


Expand All @@ -68,8 +64,7 @@
#############################################################################
-->

<config name="minimum_supported_wp_version" value="3.6"/>

<!-- Verify that all gettext calls use the correct text domain. -->
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
Expand All @@ -79,26 +74,93 @@
</properties>
</rule>

<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<rule ref="Yoast.NamingConventions.NamespaceName">
<properties>
<property name="prefixes" type="array">
<element value="Yoast\WP\Duplicate_Post"/>
<element value="duplicate_post"/>
<element value="dp_"/>
<!-- Indicate which directories should be treated as project root directories for
path-to-namespace translations. -->
<property name="src_directory" type="array">
<element value="src"/>
</property>
</properties>
</rule>

<rule ref="WordPress.Arrays.MultipleStatementAlignment">
<type>error</type>
<rule ref="Yoast.Files.FileName">
<properties>
<!-- No need to adjust alignment of large arrays when the item with the largest key is removed. -->
<property name="exact" value="false"/>
<!-- Don't align multi-line items if ALL items in the array are multi-line. -->
<property name="alignMultilineItems" value="!=100"/>
<!-- Array Assignment operator should always be on the same line as the array key. -->
<property name="ignoreNewlines" value="false"/>
<!-- Don't trigger on the main file as renaming it would deactivate the plugin. -->
<property name="excluded_files_strict_check" type="array">
<element value="duplicate-post.php"/>
</property>

<!-- Remove the following prefixes from the names of object structures. -->
<property name="oo_prefixes" type="array">
<element value="duplicate_post"/>
</property>
</properties>
</rule>


<!--
#############################################################################
SELECTIVE EXCLUSIONS
Exclude specific files for specific sniffs and/or exclude sub-groups in sniffs.
#############################################################################
-->

<!-- TEST CODE -->

<!-- Valid usage: For testing purposes, some non-prefixed globals are being created, which is fine. -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound">
<exclude-pattern>/tests/*\.php$</exclude-pattern>
</rule>

<!-- Test code does not go into production, so security is not an issue. -->
<rule ref="WordPress.Security">
<exclude-pattern>/tests/*</exclude-pattern>
</rule>

<!-- These tests are not run within the context of a WP install, so overwritting globals is fine. -->
<rule ref="WordPress.WP.GlobalVariablesOverride">
<exclude-pattern>/tests/*</exclude-pattern>
</rule>


<!--
#############################################################################
TEMPORARY ADJUSTMENTS
Adjustments which should be removed once the associated issue has been resolved.
#############################################################################
-->

<!-- Temporary exclude due to a bug in YoastCS.
The bug has already been fixed and this exclude can be removed once YoastCS 2.2.0
has been released. -->
<rule ref="Yoast.Files.FileName.InvalidClassFileName">
<exclude-pattern>/src/duplicate-post\.php$</exclude-pattern>
</rule>

<!-- The renaming of the hooks to use the namespace-like prefix is
a breaking change and will be planned in to be actioned
at a future date. -->
<rule ref="Yoast.NamingConventions.ValidHookName.WrongPrefix">
<exclude-pattern>/(admin|common)-functions\.php$</exclude-pattern>
<exclude-pattern>/src/(permissions-helper|post-(duplicator|republisher))\.php$</exclude-pattern>
<exclude-pattern>/src/ui/link-builder\.php$</exclude-pattern>
</rule>

<!-- Technical debt: nonce verification should be added to cover
all relevant uses of superglobals. This will be addressed
by the team at a future date. -->
<rule ref="WordPress.Security.NonceVerification.Missing">
<exclude-pattern>/src/handlers/save-post-handler\.php$</exclude-pattern>
</rule>
<rule ref="WordPress.Security.NonceVerification.Recommended">
<exclude-pattern>/compat/gutenberg-functions\.php$</exclude-pattern>
<exclude-pattern>/src/post-republisher\.php$</exclude-pattern>
<exclude-pattern>/src/admin/options-page\.php$</exclude-pattern>
<exclude-pattern>/src/ui/bulk-actions\.php$</exclude-pattern>
<exclude-pattern>/src/ui/classic-editor\.php$</exclude-pattern>
<exclude-pattern>/src/watchers/(bulk|link)-actions-watcher\.php$</exclude-pattern>
<exclude-pattern>/src/watchers/republished-post-watcher\.php$</exclude-pattern>
</rule>

</ruleset>
59 changes: 49 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
os: linux
language: php

branches:
only:
- master
- trunk
- develop
- /^release\/*/
- /^hotfix\/\d+\.\d+(\.\d+)?(-\S*)?$/
Expand All @@ -13,42 +15,79 @@ branches:
cache:
directories:
- .cache
- $HOME/.composer/cache

php:
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- "nightly"

matrix:
env:
- PHPUNIT=1

jobs:
fast_finish: true
include:
# Arbitrary PHP version to run the sniffs against.
- php: '5.6'
env: LINT=1 PHPUNIT=1
- php: '7.4'
env: SNIFF=1 PHPUNIT=1
- php: '8.0'
env: LINT=1 PHPUNIT=1
- stage: 🚀 deployment
name: "Deploy to Yoast-dist"
php: 7.2
install:
- yarn global add grunt-cli
- yarn install
before_script: skip
script:
- |
if [[ ! -z "$TRAVIS_TAG" ]]; then
grunt set-version -new-version=$TRAVIS_TAG
grunt update-version
fi
- grunt artifact
if: ( tag IS present OR branch =~ /^feature\// OR branch =~ /^release\// OR branch =~ /^hotfix\// OR branch = trunk OR branch = develop ) AND type != pull_request
before_install:
- nvm install lts/*
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH=$HOME/.yarn/bin:$PATH
- openssl aes-256-cbc -K $encrypted_d1beccaa5494_key -iv $encrypted_d1beccaa5494_iv -in config/travis/deploy_keys/id_rsa_yoast_dist.enc -out config/travis/deploy_keys/id_rsa_yoast_dist -d
- chmod 600 config/travis/deploy_keys/id_rsa_yoast_dist
- eval $(ssh-agent -s)
- ssh-add config/travis/deploy_keys/id_rsa_yoast_dist

allow_failures:
- php: "nightly"
# If the commit was tagged, create an artifact and push it to the distribution github
deploy:
skip_cleanup: true
provider: script
script: bash config/travis/deploy_to_dist.sh ${TRAVIS_TAG:-$TRAVIS_BRANCH} duplicate-post
on:
repo: $TRAVIS_REPO_SLUG
all_branches: true

before_install:
- if [[ "$SNIFF" == "1" || "$PHPUNIT" == "1" ]]; then composer install; fi
- if [[ "$COVERAGE" != "1" ]]; then phpenv config-rm xdebug.ini || echo 'No xdebug config.'; fi
- travis_retry composer install

before_script:
- export -f travis_fold
- export -f travis_time_start
- export -f travis_time_finish

script:
- find -L . ./compat/ ./src/ \( -path ./vendor -o -path ./node_modules \) -prune -o -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l
- if [[ "$LINT" == "1" ]]; then composer lint; fi
- if [[ "$SNIFF" == "1" ]]; then composer check-cs; fi
- if [[ "$SNIFF" == "1" ]]; then composer check-vip; fi
# PHP Unit Tests
- |
if [[ "$PHPUNIT" == "1" ]]; then
travis_fold start "PHP.tests" && travis_time_start
composer test
travis_time_finish && travis_fold end "PHP.tests"
fi
# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
- if [[ $TRAVIS_PHP_VERSION == "5.6" ]]; then composer validate --no-check-all; fi
Loading

0 comments on commit 95ce770

Please sign in to comment.