-
Notifications
You must be signed in to change notification settings - Fork 1
Enhancement #6: As a QA engineer, I want the plugin versions to be automatically handled so that I can easily run tests on a selected version #312
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
base: develop
Are you sure you want to change the base?
Conversation
- Add plugin.config.sample.ts for version configuration - Add plugin-manager.ts utility for automatic plugin download/build - Add plugin-manager-cli.ts for manual plugin management - Support version numbers, GitHub branches/tags, and direct URLs Closes #6
- Auto-check and download/build missing plugins in BeforeAll hook - Tests now automatically setup required plugin versions - No manual intervention needed
- Add plugin:setup - Setup all configured versions - Add plugin:list - List plugin files status - Add plugin:clean - Remove all plugin files - Add plugin:validate - Check required files exist - Add open-report script for convenience
- Ignore plugin.config.ts (user-specific configuration) - Ignore .tmp-plugin-build (temporary build directory)
- Remove manual plugin download/rename instructions - Add automatic plugin management section - Reference plugin.config.sample.ts for configuration examples - List CLI commands for optional manual management
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces automated plugin version management for E2E testing, eliminating manual setup of WP Rocket plugin zip files. The implementation adds a configuration-driven plugin manager that can download from releases, build from GitHub branches/tags, or fetch from direct URLs. The system integrates into the test lifecycle to automatically validate and setup required plugin versions before running tests.
Key Changes
- New plugin manager utility that automates downloading/building plugin versions based on configuration
- CLI commands for managing plugin versions (
plugin:setup,plugin:list,plugin:clean,plugin:validate) - Automatic plugin validation and setup integrated into test hooks to ensure required files are present before tests run
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
utils/plugin-manager.ts |
Core plugin manager implementing download, GitHub build, validation, and cleanup functionality |
plugin-manager-cli.ts |
CLI interface providing commands to manage plugin versions with help documentation |
config/plugin.config.sample.ts |
Sample configuration file with interface definitions and usage examples for version configuration |
src/support/hooks.ts |
Integration of automatic plugin validation and setup into BeforeAll test hook |
package.json |
Addition of npm scripts for plugin management commands |
README.md |
Documentation updates describing the new automated plugin management workflow |
.gitignore |
Added entries to ignore plugin config file and temporary build directory |
Comments suppressed due to low confidence (1)
utils/plugin-manager.ts:171
- Unused variable pluginDirName.
const pluginDirName = name;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add explicit return types to main() and printHelp() functions - Fix lexical declaration in case block by adding braces - Improve error handling with proper TypeScript type checking
Security enhancements: - Add path traversal protection for downloadFile function - Add version format validation for downloadFromReleases - Add command injection prevention with sanitizeShellInput - Fix GitHub token exposure (use git credential helper) - Add redirect location validation Code quality improvements: - Fix race condition in error handler (use try-catch) - Remove unused pluginDirName variable - Fix force parameter usage (use parameter instead of global) - Update CLI flag documentation (--force vs --force-plugin-rebuild) - Add graceful handling for missing config file - Improve error handling with proper TypeScript types
- Add note about pre-release versions and alternative approaches - Change default newRelease to stable version (3.20.2) - Remove unused forceRebuild export (now handled internally) - Update CLI flag documentation to match actual implementation
|
All feedback has been addressed: Security fixes in 7dedcb8:
Code quality fixes:
All ESLint errors are now resolved as well. |
jeawhanlee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work on this Sir 🙌
Would it also be possible to enhance this to accept arguments of plugin versions directly from the CLI that way we might not need to modify the config file all the time for each test run or maybe this doesn't make sense.
CC @wp-media/qa-team Do you see any usefulness in this suggestion?
|
To make things a bit more automated, Would it make sense to have an endpoint we can connect to that would always return the latest version and the previous stable version of WPR, that way, we'll eliminate configs CC @wp-media/qa-team @wordpressfan |
jeawhanlee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving this PR with need for some enhancement mentioned here
- Create version-override module with support for multiple input formats - Support CLI arguments (--previous-stable, --new-release, --specific-version) - Support environment variables (PREVIOUS_STABLE, NEW_RELEASE, SPECIFIC_VERSION) - Support npm config style arguments - Add version format validation and display helpers
- Update plugin manager to accept version overrides - Apply runtime overrides to base configuration - Display active overrides when detected - Add version labels for better logging - Auto-trigger download/build for overridden versions
- Parse version overrides before test execution - Pass overrides to plugin setup process - Seamlessly integrate with existing validation flow
- Document all CLI argument formats and options - Add examples for common testing scenarios - Include environment variable usage - Document supported version formats - Provide real-world usage examples
CLI Version OverrideI've implemented the feedback from @jeawhanlee about accepting plugin version arguments directly from the CLI without needing to modify the config file each time. What's NewCLI Override Support - You can now override plugin versions at runtime using multiple methods:
Supported FormatsAll the same formats from
Implementation DetailsNew Files:
Modified Files:
Example Use CasesTest a specific version without config changes: npm run test:e2e --wpr=3.16.4.1Test a branch against previous stable: npm run test:e2e --wpr=branch:feature/new-optimizationOverride both versions for comparison testing: npm run test:e2e --wpr=branch:develop --previous=3.16.3The config file still serves as the default, but CLI arguments take precedence when provided. This makes it easy to run quick tests without editing configuration files! |
|
- Add three-tier priority system for plugin version selection: 1. CLI overrides (highest priority) - always clean and re-download 2. Config file (medium priority) - clean and re-download from config 3. Existing plugins (lowest priority) - use files already in folder - Make config file optional - no longer fails if missing - Add hasPluginConfigFile() to check config existence - Update hooks.ts to handle all three cases with clear logging - Validate plugin files and provide helpful error messages Benefits: - QA can use existing plugin files without re-downloading - Developers can quickly override versions via CLI - Config-based workflow still works as expected - Clear priority system prevents confusion
Priority-Based Plugin Version ManagementI've implemented a more flexible and QA-friendly approach to plugin version management based on team feedback. The system now uses a three-tier priority system that makes it easier to work with different testing scenarios. How It WorksThe plugin manager now follows a clear priority order: 1️⃣ CLI Overrides (Highest Priority)
# Quick test with specific versions
npm run test:e2e -- --new-release=3.16.4 --previous-stable=3.16.3
# Test a branch
npm run test:e2e -- --new-release=branch:develop
# Mix different formats
npm run test:smoke -- --new-release=tag:3.16.4-beta5 --previous-stable=3.16.32️⃣ Config File (Medium Priority)
# Uses versions from config/plugin.config.ts
npm run test:e2e3️⃣ Existing Plugins (Lowest Priority - NEW!)
# Manually place plugin files in plugin/ folder
ls plugin/
# previous_stable.zip new_release.zip wp-rocket_3.10.9.zip
# Run tests without re-downloading
npm run test:e2eWhy This Is BetterFor QA:
For CI/CD:
Changes MadeModified files:
Commit: e429aa6 Testing Examples# Scenario 1: Use existing files (no config)
rm config/plugin.config.ts # Remove config
npm run test:e2e # Uses existing plugin files
# Scenario 2: Use config file
cp config/plugin.config.sample.ts config/plugin.config.ts
npm run test:e2e # Cleans and re-downloads from config
# Scenario 3: Override via CLI
npm run test:e2e -- --new-release=branch:feature/new-optimization
# Cleans and downloads the branch version |
Update: Removed
|
- Remove specificVersion field from PluginVersionConfig interface - Remove specificVersion from VersionOverrides interface - Remove specificVersion file mapping from PLUGIN_FILES - Remove specificVersion processing in setupPluginVersions - Update all examples in sample config file - Cleanup validatePluginFiles, listPluginFiles and cleanPluginFiles
477d96d to
87ace3a
Compare
- Change download source from wp-rocket.me to GitHub releases archive
- Use GitHub's automatic source archive generation (archive/refs/tags/v{version}.zip)
- Requires GITHUB_TOKEN for private repository access
- Update documentation to reflect GitHub as download source
- Add 'v' prefix to version tags when fetching from GitHub
This ensures plugin downloads remain private to the organization
while allowing automated version management for E2E tests.
Update: Plugin Downloads Now Use GitHub ReleasesCommit: 7b66bc4 ChangesThe plugin version management now downloads plugin versions from GitHub releases instead of wp-rocket.me, keeping downloads private to the organization. What Changed:
Configuration Required:export const pluginConfig: PluginVersionConfig = {
previousStable: '3.20.1',
newRelease: '3.20.2',
repository: {
owner: 'wp-media',
name: 'wp-rocket',
token: process.env.GITHUB_TOKEN // Required for downloads
}
};Why This Change?
Supported Version Formats:
All automated methods now require proper GitHub authentication, ensuring plugin files remain secure. |
- Downloads are now extracted to temp directory - Runs composer install --no-dev --no-scripts to install dependencies - Skips post-install scripts that require dev dependencies (Mozart) - Manually runs composer dump-autoload for optimized autoloading - Checks for npm dependencies and runs build scripts if present - Creates final plugin zip with all built dependencies included This ensures version downloads have vendor/ directory and built assets, making them ready for use in E2E tests without missing dependencies.
Update: Automatic Build Process for Version DownloadsCommit: c03ebad IssueGitHub's source archives contain only raw source code without built dependencies:
SolutionVersion downloads now automatically build the plugin after downloading:
Result
|
Add inline eslint-disable comments for HTTP header property names that use standard capitalization (User-Agent, Authorization).
|
To be honest, I don't know how I feel about compiling the plugin on e2e, we might need to brainstorm on this. |
|
@jeawhanlee I kinda agree, but we can't download it from wp-rocket.me as it's subject to authentification. |
Description
Fixes #6
Eliminates manual plugin version management for E2E tests. QA engineers can now configure versions in
plugin.config.tsand the framework automatically downloads/builds required files. Supports version numbers, GitHub branches/tags, and direct URLs. Tests auto-check and download missing plugins before running. Fully backward compatible, existing workflows continue to work unchanged.Type of change
Detailed scenario
What was tested
All new
npmcommandsHow to test
config/plugin.config.sample.tstoconfig/plugin.config.tsnpm run plugin:setupto download/build configured plugin versionsnpm run plugin:list- should show 3 plugin filesnpm run test:e2eto verify automatic plugin setup in testsnpm run plugin:setup -- --forceTechnical description
Documentation
This pull request introduces automated management of WP Rocket plugin versions for E2E testing, eliminating the need for manual setup of plugin zip files. It adds a configuration-driven plugin manager that can automatically download, build, validate, and clean required plugin versions, along with CLI commands and documentation updates to support this workflow.
Automated Plugin Version Management
utils/plugin-manager.ts) that automatically downloads or builds required WP Rocket plugin versions based on a configuration file, replacing the previous manual process. The manager supports fetching by version, GitHub branch/tag, or direct URL, and provides functions for setup, validation, listing, and cleaning plugin files.plugin-manager-cli.ts) with commands to set up, list, clean, and validate plugin versions, integrated into npm scripts for easy use (plugin:setup,plugin:list,plugin:clean,plugin:validate). [1] [2]Configuration and Documentation
config/plugin.config.sample.ts) for specifying which plugin versions to use, with support for version numbers, GitHub branches/tags, or URLs. Users copy and edit this file to control test versions.README.mdto document the new automated plugin management workflow, configuration steps, and available CLI commands, replacing the old manual instructions. [1] [2]Integration with Test Lifecycle
src/support/hooks.ts) to automatically validate and set up plugin versions before running tests, ensuring all required plugin files are present and up-to-date. [1] [2]Mandatory Checklist
Code validation
Code style
Unticked items justification
No test for this