Skip to content

Commit

Permalink
Use GitHub actions instead of Travis (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbachhuber authored Jul 21, 2023
1 parent f08602c commit d4ac210
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 125 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Code Quality Checks

on:
pull_request:
push:
branches:
- main
- master

jobs:
code-quality:
uses: wp-cli/.github/.github/workflows/reusable-code-quality.yml@main
14 changes: 14 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Testing

on:
pull_request:
push:
branches:
- main
- master
schedule:
- cron: "17 1 * * *" # Run every day on a seemly random time.

jobs:
test:
uses: wp-cli/.github/.github/workflows/reusable-testing.yml@main
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ vendor/
*.swp
*.txt
*.log
composer.lock
composer.lock
64 changes: 0 additions & 64 deletions .travis.yml

This file was deleted.

7 changes: 7 additions & 0 deletions behat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
default:
suites:
default:
contexts:
- WP_CLI\Tests\Context\FeatureContext
paths:
- features
36 changes: 20 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,36 @@
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": { "": "src/" },
"files": [ "php-compat-command.php" ]
"psr-4": {
"": "src/"
},
"files": [
"php-compat-command.php"
]
},
"require": {
"wp-cli/wp-cli": "^2",
"wimg/php-compatibility": "^8.0",
"phpcompatibility/php-compatibility": "^9.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || ^0.5 || ^0.6.2 || ^0.7.1 || ^1.0.0"
},
"require-dev": {
"behat/behat": "~2.5",
"wp-cli/wp-cli-tests": "^2",
"wp-cli/wp-cli-tests": "^3",
"wp-cli/core-command": "^2",
"wp-cli/extension-command": "^2"
},
"scripts": {
"lint": "run-linter-tests",
"phpcs": "run-phpcs-tests",
"phpunit": "run-php-unit-tests",
"behat": "run-behat-tests",
"prepare-tests": "install-package-tests",
"test": [
"@lint",
"@phpcs",
"@phpunit",
"@behat"
]
"behat": "run-behat-tests",
"behat-rerun": "rerun-behat-tests",
"lint": "run-linter-tests",
"phpcs": "run-phpcs-tests",
"phpunit": "run-php-unit-tests",
"prepare-tests": "install-package-tests",
"test": [
"@lint",
"@phpcs",
"@phpunit",
"@behat"
]
},
"extra": {
"commands": [
Expand Down
94 changes: 50 additions & 44 deletions features/php-compat.feature
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
Feature: Check PHP compatibility

@broken-trunk @require-wp-4.0
Scenario: Check compatibility of a default WP install
Given a WP install

When I run `wp php-compat --fields=name,type,compat --format=csv`
Then STDOUT should be CSV containing:
| name | type | compat |
| wordpress | core | success |
| akismet | plugin | success |
| name | type | compat |
| wordpress | core | success |
| akismet | plugin | success |

@broken-trunk @require-wp-4.0
Scenario: Check compatibility of a default WP install with cache enabled
Given a WP install
And I run `wp plugin uninstall akismet`
And I run `wp plugin install one-time-login`
And I run `mkdir php-compat-cache`
And I run `wp plugin update --all`

When I run `wp php-compat-cache plugin akismet php-compat-cache --prior_versions=1`
When I run `wp php-compat-cache plugin one-time-login php-compat-cache --prior_versions=1`
Then STDOUT should contain:
"""
Success:
"""

When I run `WP_CLI_PHP_COMPAT_CACHE=php-compat-cache wp php-compat --fields=name,type,compat,time`
Then STDOUT should be a table containing rows:
| name | type | compat | time |
| wordpress | core | success | cached |
| akismet | plugin | success | cached |
| name | type | compat | time |
| wordpress | core | success | cached |
| one-time-login | plugin | success | cached |

@broken
Scenario: Check compatibility of Co-Authors Plus for specific PHP versions
Given a WP install
# Version 3.2.2 has a known PHP 5.2 incompatibility
Expand All @@ -44,34 +49,35 @@ Feature: Check PHP compatibility

When I run `wp php-compat --fields=name,type,compat`
Then STDOUT should be a table containing rows:
| name | type | compat |
| co-authors-plus | plugin | success |
| name | type | compat |
| co-authors-plus | plugin | success |

When I run `WP_CLI_PHP_COMPAT_CACHE=php-compat-cache wp php-compat --fields=name,type,compat,time`
Then STDOUT should be a table containing rows:
| name | type | compat | time |
| co-authors-plus | plugin | success | cached |
| name | type | compat | time |
| co-authors-plus | plugin | success | cached |

When I run `wp php-compat --fields=name,type,compat --php_version=5.2`
Then STDOUT should be a table containing rows:
| name | type | compat |
| co-authors-plus | plugin | failure |
| name | type | compat |
| co-authors-plus | plugin | failure |

When I run `WP_CLI_PHP_COMPAT_CACHE=php-compat-cache wp php-compat --fields=name,type,compat,time --php_version=5.2`
Then STDOUT should be a table containing rows:
| name | type | compat | time |
| co-authors-plus | plugin | failure | cached |
| name | type | compat | time |
| co-authors-plus | plugin | failure | cached |

When I run `WP_CLI_PHP_COMPAT_CACHE=php-compat-cache wp php-compat --fields=name,type,compat,time --php_version=5.2-`
Then STDOUT should be a table containing rows:
| name | type | compat | time |
| co-authors-plus | plugin | failure | cached |
| name | type | compat | time |
| co-authors-plus | plugin | failure | cached |

When I run `WP_CLI_PHP_COMPAT_CACHE=php-compat-cache wp php-compat --fields=name,type,compat,time --php_version=5.3-`
Then STDOUT should be a table containing rows:
| name | type | compat | time |
| co-authors-plus | plugin | success | cached |
| name | type | compat | time |
| co-authors-plus | plugin | success | cached |

@broken
Scenario: Plugin formally supports PHP 7 in a newer version
Given a WP install
And a php-compat-cache/plugins-php7-compat.txt file:
Expand All @@ -83,8 +89,8 @@ Feature: Check PHP compatibility

When I run `WP_CLI_PHP_COMPAT_CACHE=php-compat-cache wp php-compat --fields=name,type,compat,time`
Then STDOUT should be a table containing rows:
| name | type | compat | time |
| woocommerce | plugin | with-update | cached |
| name | type | compat | time |
| woocommerce | plugin | with-update | cached |

When I run `wp plugin update woocommerce`
Then STDOUT should contain:
Expand All @@ -94,26 +100,26 @@ Feature: Check PHP compatibility

When I run `WP_CLI_PHP_COMPAT_CACHE=php-compat-cache wp php-compat --fields=name,type,compat`
Then STDOUT should be a table containing rows:
| name | type | compat |
| woocommerce | plugin | success |

Scenario: Invalid php_version argument specified
Given a WP install

When I try `wp php-compat --php_version=5`
Then STDERR should be:
"""
Error: php_version must match ^[\d]\.[\d]-?$
"""

When I try `wp php-compat --php_version=5-`
Then STDERR should be:
"""
Error: php_version must match ^[\d]\.[\d]-?$
"""

When I try `wp php-compat --php_version=5.6-7.0`
Then STDERR should be:
"""
Error: php_version must match ^[\d]\.[\d]-?$
"""
| name | type | compat |
| woocommerce | plugin | success |

Scenario: Invalid php_version argument specified
Given a WP install

When I try `wp php-compat --php_version=5`
Then STDERR should be:
"""
Error: php_version must match ^[\d]\.[\d]-?$
"""

When I try `wp php-compat --php_version=5-`
Then STDERR should be:
"""
Error: php_version must match ^[\d]\.[\d]-?$
"""

When I try `wp php-compat --php_version=5.6-7.0`
Then STDERR should be:
"""
Error: php_version must match ^[\d]\.[\d]-?$
"""
66 changes: 66 additions & 0 deletions phpcs.dist.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0"?>
<ruleset name="WP-CLI-cache">
<description>Custom ruleset for WP-CLI cache-command</description>

<!--
#############################################################################
COMMAND LINE ARGUMENTS
For help understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
For help using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage
#############################################################################
-->

<!-- What to scan. -->
<file>.</file>

<!-- Show progress. -->
<arg value="p"/>

<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./"/>

<!-- Check up to 8 files simultaneously. -->
<arg name="parallel" value="8"/>

<!--
#############################################################################
USE THE WP_CLI_CS RULESET
#############################################################################
-->

<rule ref="WP_CLI_CS"/>

<!--
#############################################################################
PROJECT SPECIFIC CONFIGURATION FOR SNIFFS
#############################################################################
-->

<!-- For help understanding the `testVersion` configuration setting:
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="5.6-"/>

<!-- Make this sniff slightly less finicky. The WP Core default is 40. -->
<rule ref="Generic.Formatting.MultipleStatementAlignment">
<properties>
<property name="maxPadding" value="20"/>
</properties>
</rule>

<!-- Verify that everything in the global namespace is either namespaced or prefixed.
See: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#naming-conventions-prefix-everything-in-the-global-namespace -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<property name="prefixes" type="array">
<element value="WP_CLI\Cache"/><!-- Namespaces. -->
<element value="wpcli_cache"/><!-- Global variables and such. -->
</property>
</properties>
</rule>

<!-- Exclude existing classes from the prefix rule as it would break BC to prefix them now. -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound">
<exclude-pattern>*/src/(Cache|Transient)_Command\.php$</exclude-pattern>
</rule>

</ruleset>

0 comments on commit d4ac210

Please sign in to comment.