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
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test

on:
push:
branches:
- trunk
pull_request:

jobs:
test:
name: Integration tests (wp-env)
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'

- name: Install Node.js dependencies
run: npm install

# Cache the wp-env working directory (~/.wp-env) so that the WordPress
# download and database setup are reused across runs when nothing changes.
- name: Cache wp-env
uses: actions/cache@v4
with:
path: ~/.wp-env
key: wp-env-${{ hashFiles('package.json', '.wp-env.json') }}
restore-keys: |
wp-env-

- name: Start wp-env
run: npx wp-env start

- name: Run tests
run: npm test

- name: Stop wp-env
run: npx wp-env stop
if: always()
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
vendor/
.wp-env/
composer.lock
package-lock.json
7 changes: 7 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"plugins": ["."],
"mappings": {
"wp-cli.yml": "./wp-cli.yml"
},
"testsEnvironment": false
}
22 changes: 22 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "dd32/wpcli-cron-concurrent",
"description": "Runs WordPress cron tasks concurrently via wp-cli.",
"type": "wp-cli-package",
"keywords": ["wp-cli", "cron", "concurrent"],
"license": "MIT",
"require": {
"wp-cli/wp-cli": "^2.0"
},
"autoload": {
"classmap": ["src/"],
"files": ["cron-concurrent.php"]
},
"extra": {
"commands": [
"cron-concurrent",
"cron-concurrent run"
]
},
"minimum-stability": "dev",
"prefer-stable": true
}
31 changes: 31 additions & 0 deletions cron-concurrent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* Plugin Name: WP-CLI Cron Concurrent
* Description: Runs WordPress cron tasks concurrently via wp-cli.
* Version: 1.0.0
* Author: dd32
* License: MIT
*/

/**
* WP-CLI Cron Concurrent – entry point.
*
* Loaded automatically by WP-CLI when this package is installed via Composer,
* or explicitly via `--require` / a `wp-cli.yml` require entry.
* Registers the `wp cron-concurrent` command group.
*
* @package dd32/wpcli-cron-concurrent
*/

if ( ! class_exists( 'WP_CLI' ) ) {
return;
}

// When installed as a Composer package the classmap autoloader already
// handles this file; the direct require is only a safety-net for manual
// --require usage (e.g. inside wp-env test containers).
if ( ! class_exists( 'CronConcurrent' ) ) {
require_once __DIR__ . '/src/CronConcurrent.php';
}

WP_CLI::add_command( 'cron-concurrent', 'CronConcurrent' );
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "wpcli-cron-concurrent",
"description": "Runs WordPress cron tasks concurrently via wp-cli.",
"private": true,
"scripts": {
"env:start": "wp-env start",
"env:stop": "wp-env stop",
"env:destroy": "wp-env destroy",
"test": "bash tests/run-tests.sh"
},
"devDependencies": {
"@wordpress/env": "^11.0.0"
}
}
Loading