-
Notifications
You must be signed in to change notification settings - Fork 0
Add wp cron-concurrent command for parallel cron execution #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
efd7696
Initial plan
Copilot 871c9bc
Add plugin source files (composer.json, entry point, command class)
Copilot 514b2df
Remove composer; set up wp-env test environment
Copilot 83fc8bd
Add GitHub Actions CI, restore composer.json, gitignore lock files, f…
Copilot bb8cd10
Fix CI: use npm install instead of npm ci, remove lock-file cache
Copilot 822e46c
Restrict push trigger to trunk branch only
Copilot 9c533ca
Add testsEnvironment: false to .wp-env.json to suppress warnings
Copilot 4cf4904
Add WordPress plugin header to cron-concurrent.php
Copilot 61bca80
Fix CI: use cli container and fix grep option parsing in tests
dd32 2efc5c0
Fix tests to use --filter for isolation from WordPress default crons
dd32 08bfdb3
Fix race condition in test by serializing hook execution
dd32 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| node_modules/ | ||
| vendor/ | ||
| .wp-env/ | ||
| composer.lock | ||
| package-lock.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "plugins": ["."], | ||
| "mappings": { | ||
| "wp-cli.yml": "./wp-cli.yml" | ||
| }, | ||
| "testsEnvironment": false | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.