Release 2.5.0 - #254
Release 2.5.0#254
Conversation
- Add a profile-gated `playwright` service using mcr.microsoft.com/playwright - Read the image tag from the target's @playwright/test version - Make `slic playwright install` a no-op, the image contains the browser - Allow SLIC_PLAYWRIGHT_VERSION and SLIC_PLAYWRIGHT_IMAGE overrides
slic starts each service by name, and docker compose enables a service's profile when it is named, so `slic up` started the `playwright` service.
- Read the version from node_modules/@playwright/test/package.json - The declared range can install a newer patch than the image tag - Works with any package manager, no lockfile parsing needed
- Read the version from the target's package.json again - Error when it is a range, since a range can install a version the image does not match - Error when @playwright/test is not a dependency - Works before the project's dependencies are installed
The value comes from the project's package.json, so it could otherwise write terminal escape sequences into the error message.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (12)
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 WalkthroughWalkthroughThe CLI adds remote browser support for Playwright tests. It runs tests in the Slic service, connects browser fixtures to a temporary Playwright server, and adds process and Docker Compose argument-vector helpers. Documentation describes setup and migration considerations. ChangesPlaywright execution
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~50 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant PlaywrightCommand
participant SlicService
participant BrowserServer
PlaywrightCommand->>SlicService: Check installed Playwright CLI version
PlaywrightCommand->>BrowserServer: Start temporary browser server
PlaywrightCommand->>BrowserServer: Poll health status
PlaywrightCommand->>SlicService: Run tests with browser WebSocket endpoint
PlaywrightCommand->>BrowserServer: Remove browser container after test run
Merge Risk: ⚪ Minimal · up to No confirmed issue currently blocks merging. Release testing should still exercise browser startup and readiness. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
https://github.com/stellarwp/learndash-core/pull/3340 is approved. I'll merge the LearnDash PR once we have this one tagged and released :)
Release testing
This is a release PR for 2.5.0, prepared from #253.
CLI_VERSIONis set to2.5.0; pushing this branch triggers the Slic and WordPress image builds with that tag. Wait for both image workflows to finish before testing consuming projects againstrelease/2.5.0.Warning
Playwright suites may require changes before upgrading. This release changes browser installation and execution behavior; use the migration instructions below before testing existing suites.
The release date remains TBD. No Git tag or GitHub Release has been published, and #252 and #253 remain open while this release is evaluated.
Main Changes
The main reason for this change is to remove the browser installation step from CI without losing the PHP tooling that existing Playwright suites depend on.
PR #252 addresses browser installation by moving the entire Playwright test runner into Microsoft's image. That works for suites that only interact with WordPress through HTTP, but some of our projects also run WP-CLI commands directly from their tests:
db.reset()anddb.loadDump('blocks')intest.beforeAll(). These executewp db reset --yesandwp db import. Test setup, database helper.Those commands run wherever the Playwright test process runs. Microsoft's image provides the browsers and their dependencies, but not Slic's PHP, WP-CLI, or Composer environment.
This implementation keeps the tests and setup hooks inside
slic, and runs the browsers through a separate Playwright server using Microsoft's image. This release branch includes the implementation from #253, including its Docker-context fix. It targetsmainfor release testing. #252 and #253 remain open until that testing is complete.Compared with current Slic and #252
main)sliccontainersliccontainerslicslic playwright installrunsplaywright install chromium --with-depsinsideslicpackage.json^1.60.0SLIC_PLAYWRIGHT_VERSIONchromium.launch()callsslic, after browser installationEach test invocation gets its own browser container. Slic waits for it to become ready, supplies Playwright's native
PW_TEST_CONNECT_WS_ENDPOINT, and removes the container afterward.Fixes and other changes
WP_URL, while Slic exposesWORDPRESS_URLalongside database connection details and Slic context variables. Keeping test execution inside Slic preserves that environment without duplicating it in the browser service.node_modules/.bin/playwright --versionsupports dependency ranges and avoids selecting an image from a manifest that no longer matchesnode_modules.slic playwright installand supported forms such asslic playwright install chromium --with-depsskip installation successfully. Unsupported browser channels and installation options produce an error.docs/playwright.md, with fixture examples, setup migration guidance, and download handling.The new Docker and process helpers are loaded from the root bootstrap. Existing command-string helpers retain their current behavior.
Faster container readiness checks
Removed
start_periodfrom the Playwright, Selenium, Redis, WordPress, and MariaDB health checks. Each service now uses its existing one-second interval from startup, avoiding Docker's default five-second startup polling interval. The checks themselves, timeouts, and retry counts are unchanged. Startup failures now count toward the retry limit immediately.This requires no new configuration or newer Docker/Compose features. Selenium still starts for existing suites. These changes are in
slic-stack.yml, so checking out the updated branch applies them without rebuilding images.LearnDash CI confirmed shorter startup waits:
slic useoperation, before and after the Selenium/Redis and WordPress/MariaDB adjustmentsThese are observations across successive runs, not controlled benchmarks. Redis and MariaDB start together, so their savings do not add together. The
slic usemeasurement includes image pulls and initial container startup; Slic prints “services restarted” even on this fresh CI stack.Sources: before health-check changes, Playwright adjustment, Selenium/Redis adjustments, all adjustments.
The latest run passed all three setup/infrastructure tests. Compared with the preceding run, WordPress and MariaDB readiness waits decreased by about four seconds combined. The whole job dropped from 4m22s to 3m42s, but asset building also dropped from 103s to 72s, so the full improvement cannot be attributed to these changes.
Developer experience
Projects continue declaring Playwright in
package.json. For example:{ "devDependencies": { "@playwright/test": "^1.60.0" } }Commit the dependency lockfile and install normally:
If the installed CLI reports
1.60.0, Slic selectsmcr.microsoft.com/playwright:v1.60.0. There is no second version to maintain in Slic configuration and no browser installation command to run.Tests using Playwright's fixtures connect automatically. PHP and WP-CLI hooks remain local to Slic:
Changes needed in existing suites
LearnDash Core's original setup launches Chromium directly in
tests/playwright/global-setup.ts. There are two ways to prepare that setup for this change.Minimal fix: adapt the existing global setup.
Warning
This is the smallest change to get existing setup code working, but it keeps manual browser connection and cleanup logic. Prefer the fixture-based setup project shown below when you can make that migration. This follows Playwright’s recommended setup-project approach, which supports built-in fixtures and automatic browser management.
If the project needs a smaller migration first, keep its current configuration and
global-setup.ts. Replace:with:
Keep the existing warmup, login, storage-state, and
finallycleanup code. Slic supplies the endpoint automatically; the fallback supports running outside Slic with locally installed browsers.Warning
Direct
chromium.launch(),firefox.launch(), andwebkit.launch()calls bypass the automatic remote connection. Use built-in fixtures where possible, or explicitly connect in existing setup code.Recommended: move authentication into a Playwright setup project.
Use the built-in
pagefixture so Playwright manages the browser connection and cleanup.1. Preserve the existing WordPress warmup helper.
Move
warmUpWordPress()and its threeWARMUP_*constants fromtests/playwright/global-setup.tsinto:Keep its implementation unchanged, but export the function:
This preserves LearnDash's protection against WordPress cold starts.
2. Create
tests/playwright/auth.setup.ts.Use Playwright's built-in
pagefixture alongside the existingWPAdminandADMIN_AUTH_FILEhelpers:The
pagefixture connects to Slic's remote browser automatically. Playwright also closes its page and context afterward, so this file needs nochromium.launch(), explicit endpoint handling, or manual browser cleanup.3. Update
playwright.config.ts.Remove the existing registration:
Replace the
projectsarray with:Keep the rest of LearnDash's configuration, including its existing
testDir,baseURL, worker count, and artifact settings.The setup project inherits
tests/playwrightas its test directory and runsauth.setup.ts. Theinfraproject waits for successful authentication before running its tests.4. Remove the old global setup file and keep the existing authenticated fixture.
Once the warmup helper has been moved, delete
tests/playwright/global-setup.ts.LearnDash's existing
adminPagefixture already readsADMIN_AUTH_FILEand uses Playwright's built-inbrowserfixture. Its implementation and the tests consuming it can remain unchanged. Update its comments to refer to the setup project instead of global setup.Developers can continue running:
Playwright runs the
setupdependency first, writes the administrator's authentication state, and then runs the infrastructure tests. Avoid--no-deps, which skips that setup.This follows Playwright's recommended setup-project approach, including fixture management and setup results in reports and traces.
LearnDash has implemented the fixture-based migration in PR #3340. Its setup/infrastructure tests have passed against this release branch; this does not validate its full suite.
Other compatibility checks:
http://wordpress.testfor WordPress. Browser requests tolocalhostnow address the browser container.download.saveAs()instead ofdownload.path()for downloads.How Playwright version detection works
The project controls its Playwright version through its npm dependency and lockfile. Slic uses the version actually installed in
node_modules.When a developer runs
slic playwright test:slicservice is running. The project's dependencies must already be installed.node_modules/.bin/playwright --versioninside Slic, from the project directory.Version 1.60.0selectsmcr.microsoft.com/playwright:v1.60.0. An explicitSLIC_PLAYWRIGHT_IMAGEoverrides this selection and must contain matching browsers.PW_TEST_CONNECT_WS_ENDPOINTso Playwright's built-in fixtures connect to that server.flowchart TD A["package.json declares a Playwright dependency"] --> B["npm ci installs the version recorded in the lockfile"] B --> C["Developer runs slic playwright test"] C --> D["Ensure slic is running"] D --> E["Read the project's installed Playwright CLI version"] E --> F{"Valid stable version?"} F -->|No| G["Stop with an actionable error"] F -->|Yes| H["Select matching Microsoft image or configured image override"] H --> I["Start browser server and wait for readiness"] I --> J["Run tests and PHP hooks inside slic"] J <-->|"Playwright WebSocket connection"| K["Browsers in the Microsoft container"] J --> L["Remove browser container and return test status"]For example,
package.jsonmight allow^1.60.0, while the lockfile installs1.60.1. Slic reads1.60.1from the installed CLI and selects that image. Developers can keep normal dependency ranges without maintaining a separate Slic version setting.Help, version, report, and
test --listcommands skip browser-server startup.Testing
During development, isolated Docker smoke checks exercised remote Chromium alongside PHP/WP-CLI hooks, screenshots, traces, videos, uploads, downloads, failure statuses, concurrent runs against an already-started stack, and cancellation.
Temporary checks also cover argument preservation, environment inheritance, large output, version selection, and orchestration. The strengthened cancellation check verifies that child processes stop before test cleanup; disabling shutdown termination correctly makes it fail in both output modes. These temporary tests are not included in this PR.
LearnDash's setup/infrastructure tests passed against
release/2.5.0, including the latest health-check changes in9ff64ed. The CI observations are recorded above.Fresh-container checks also passed for Selenium and Redis. MariaDB and WordPress checks used an empty database and fresh WordPress directory, with PHP 7.4 and 8.3, and verified a database query and an HTTP response after readiness. Compose configuration validation passed. Temporary verification scripts are not included in this PR.
Full LearnDash and TEC suites, including existing Codeception browser suites, still need release validation. Controlled cold and warm CI comparisons remain outstanding; a first run still needs to pull the browser image.
Summary by CodeRabbit
slic playwright installno longer installs browsers; browser dependencies are provided separately.