Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Testing

on:
pull_request:
branches:
- main
- master
workflow_dispatch:
workflow_call:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
behat:
name: Functional / PHP ${{ matrix.php }}
strategy:
matrix:
php: ['8.2']
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: wp_cli_test
MYSQL_USER: wp_cli_test
MYSQL_PASSWORD: password1
MYSQL_HOST: 127.0.0.1
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
steps:
- name: Check out source code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer

- name: Install composer packages
run: composer install

- name: Run Behat
run: composer behat
env:
WP_CLI_TEST_DBUSER: wp_cli_test
WP_CLI_TEST_DBPASS: password1
WP_CLI_TEST_DBNAME: wp_cli_test
WP_CLI_TEST_DBHOST: 127.0.0.1:${{ job.services.mysql.ports[3306] }}

unit: #-----------------------------------------------------------------------
name: Unit test / PHP ${{ matrix.php }}
strategy:
matrix:
php: [ '8.2' ]
runs-on: ubuntu-latest

steps:
- name: Check out source code
uses: actions/checkout@v4

- name: Set up PHP environment
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php }}'
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
coverage: none
tools: composer,cs2pr

- name: Install Composer dependencies & cache dependencies
uses: ramsey/composer-install@v3
env:
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

- name: Grab PHPUnit version
id: phpunit_version
run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> $GITHUB_OUTPUT

# PHPUnit 10 may fail a test run when the "old" configuration format is used.
# Luckily, there is a build-in migration tool since PHPUnit 9.3.
- name: Migrate PHPUnit configuration for PHPUnit 10+
if: ${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}
continue-on-error: true
run: composer phpunit -- --migrate-configuration

- name: Setup problem matcher to provide annotations for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run PHPUnit
run: composer phpunit
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":1,"defects":[],"times":{"AiCommand\\Tests\\MCP\\Client\\ClientTest::test_runs":0.001}}
83 changes: 0 additions & 83 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
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
"license": "MIT",
"authors": [],
"require": {
"gemini-api-php/client": "^1.7",
"logiscape/mcp-sdk-php": "^1.0",
"symfony/http-client": "^7.2",
"php": "^8.2",
"wp-cli/wp-cli": "^2.12"
},
"require-dev": {
"wp-cli/wp-cli-tests": "^v4.3.6"
"roave/security-advisories": "dev-latest",
"wp-cli/wp-cli-tests": "^v4.3.9"
},
"config": {
"process-timeout": 7200,
Expand Down Expand Up @@ -48,6 +47,7 @@
"behat-rerun": "rerun-behat-tests",
"lint": "run-linter-tests",
"phpcs": "run-phpcs-tests",
"phpcbf": "run-phpcbf-cleanup",
"phpunit": "run-php-unit-tests",
"prepare-tests": "install-package-tests",
"test": [
Expand Down
54 changes: 54 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0"?>
<ruleset name="ai-command">
<description>Custom ruleset for ai-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="8.2-"/>

<!-- 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\AiCommand"/><!-- Namespaces. -->
<element value="ai_command"/><!-- Global variables and such. -->
</property>
</properties>
</rule>

</ruleset>
26 changes: 26 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
bootstrap="vendor/autoload.php"
backupGlobals="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
convertNoticesToExceptions="true"
convertDeprecationsToExceptions="true"
colors="true"
verbose="true">
<testsuites>
<testsuite name="ai-command tests">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>

<coverage processUncoveredFiles="false">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
Loading