Add Playwright Chromium path verification tooling#1795
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
Co-authored-by: yingbull <8680161+yingbull@users.noreply.github.com>
…ation Co-authored-by: yingbull <8680161+yingbull@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull request overview
This PR adds verification tooling to ensure the Playwright Chromium executable path in .mcp.json stays aligned with the Playwright version installed in the devcontainer. This addresses feedback from #1792 about potential version misalignment.
Changes:
- Added automated verification script that validates Dockerfile Playwright version matches
.mcp.jsonexecutable path - Created comprehensive documentation for Playwright configuration, version-to-revision mapping, and troubleshooting steps
- Added quick reference section to devcontainer README with verification instructions
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
.devcontainer/scripts/verify-playwright-path.sh |
Bash script that extracts Playwright version from Dockerfile, finds installed Chromium revision, and validates against .mcp.json configuration |
.devcontainer/PLAYWRIGHT_SETUP.md |
Detailed documentation on Chromium path structure, manual verification steps, and version-to-revision mapping table |
.devcontainer/README.md |
Quick reference section for running the verification script with links to detailed documentation |
| fi | ||
|
|
||
| # Extract the current executable path from .mcp.json | ||
| CURRENT_PATH=$(grep -oP '"--executable-path",\s*"\K[^"]+' "$MCP_JSON" || echo "") |
There was a problem hiding this comment.
The grep pattern '"--executable-path",\s*"\K[^"]+' uses PCRE syntax with \K (keep) operator and \s* for whitespace. However, this assumes the JSON is formatted with the executable path immediately following the "--executable-path" key. If the JSON structure changes or is reformatted, this could break. Consider using jq to parse the JSON properly instead of grep for more robust extraction.
| CURRENT_PATH=$(grep -oP '"--executable-path",\s*"\K[^"]+' "$MCP_JSON" || echo "") | |
| CURRENT_PATH=$(jq -r '.. | arrays? | select(length >= 2 and .[0] == "--executable-path") | .[1]' "$MCP_JSON" 2>/dev/null || echo "") |
| ```bash | ||
| # For Playwright 1.56.0 | ||
| curl -s https://raw.githubusercontent.com/microsoft/playwright/v1.56.0/packages/playwright-core/browsers.json | grep -A 3 '"name": "chromium"' | ||
| ``` |
There was a problem hiding this comment.
The curl command example shows checking the browsers.json file from the GitHub repository, but there's no error handling shown. Users following this documentation should be informed that this requires internet connectivity and may fail. Consider adding a note about potential failures or showing the command with error handling.
| echo "📁 Installed Chromium directories:" | ||
| ls -d /root/.cache/ms-playwright/chromium-* 2>/dev/null || echo " None found" | ||
|
|
||
| # Get the latest installed Chromium revision |
There was a problem hiding this comment.
The numeric sorting command sort -t- -k2 -n is correct for sorting chromium revision numbers. However, consider adding a comment explaining this sorting logic since it's a critical part of finding the latest revision. The -t- sets the delimiter to hyphen, -k2 selects the second field (the revision number), and -n does numeric sorting.
| # Get the latest installed Chromium revision | |
| # Get the latest installed Chromium revision | |
| # We sort directories like "chromium-123456" numerically by the revision part: | |
| # -t- : use '-' as the field delimiter (e.g., "chromium-123456" -> fields: chromium | 123456) | |
| # -k2 : sort by the second field (the numeric revision) | |
| # -n : perform numeric sort so higher revisions are ordered last |
| | 1.57.0 | 1200 | 143.0.7499.4 | | ||
|
|
There was a problem hiding this comment.
The version mapping table shows Playwright 1.57.0 → Chromium revision 1200, but this should be verified against the actual Playwright release. The documentation encourages users to check browsers.json for verification, which is good. Consider adding a note that this table should be updated when new Playwright versions are installed in the Dockerfile.
| | 1.57.0 | 1200 | 143.0.7499.4 | | |
| **Important**: Keep this table in sync with the Playwright version specified in `.devcontainer/development/Dockerfile`. When you bump the Playwright version in the Dockerfile, add or update rows here using the corresponding `browsers.json` from that Playwright release. |
| @@ -0,0 +1,94 @@ | |||
| #!/bin/bash | |||
There was a problem hiding this comment.
The script's shebang line is missing a space between #!/bin/bash. While this works in most cases, the canonical form should be #!/bin/bash (with a space).
| #!/bin/bash | |
| #! /bin/bash |
| fi | ||
|
|
||
| # Get Playwright version from Dockerfile | ||
| PLAYWRIGHT_VERSION=$(grep -oP 'playwright@\K[0-9.]+' /workspace/.devcontainer/development/Dockerfile || echo "unknown") |
There was a problem hiding this comment.
The grep pattern uses -oP (PCRE) but doesn't escape the period in the version pattern. While this works, it would be more precise to use [0-9.]+ or better yet, [0-9]+\.[0-9]+\.[0-9]+ to match semantic versioning format. The current pattern could theoretically match invalid version strings.
| PLAYWRIGHT_VERSION=$(grep -oP 'playwright@\K[0-9.]+' /workspace/.devcontainer/development/Dockerfile || echo "unknown") | |
| PLAYWRIGHT_VERSION=$(grep -oP 'playwright@\K[0-9]+\.[0-9]+\.[0-9]+' /workspace/.devcontainer/development/Dockerfile || echo "unknown") |
| echo " ${EXPECTED_PATH}" | ||
| echo | ||
| echo "Or use jq to update it programmatically:" | ||
| echo " jq '.mcpServers.playwright.args |= map(if . == \"--executable-path\" then . else if . == \"${CURRENT_PATH}\" then \"${EXPECTED_PATH}\" else . end end)' ${MCP_JSON} > ${MCP_JSON}.tmp && mv ${MCP_JSON}.tmp ${MCP_JSON}" |
There was a problem hiding this comment.
The jq command suggestion on line 89 has a potential issue - it uses double quotes for the outer string which means the variables ${CURRENT_PATH} and ${EXPECTED_PATH} will be expanded by the shell before being passed to jq, but they're also inside the jq string which could cause issues. The suggestion should use single quotes for the jq expression and construct the replacement properly, or provide a clearer example that avoids nested quote issues.
| echo " jq '.mcpServers.playwright.args |= map(if . == \"--executable-path\" then . else if . == \"${CURRENT_PATH}\" then \"${EXPECTED_PATH}\" else . end end)' ${MCP_JSON} > ${MCP_JSON}.tmp && mv ${MCP_JSON}.tmp ${MCP_JSON}" | |
| echo " jq --arg old \"${CURRENT_PATH}\" --arg new \"${EXPECTED_PATH}\" '.mcpServers.playwright.args |= map(if . == \"--executable-path\" then . else if . == \$old then \$new else . end end)' ${MCP_JSON} > ${MCP_JSON}.tmp && mv ${MCP_JSON}.tmp ${MCP_JSON}" |
Reviewer questioned whether
.mcp.jsonChromium path aligned with Playwright 1.56.0. Investigation confirmed current path is correct (revision 1194, not 1200+), but tooling was needed to prevent future misalignment.Added verification infrastructure:
.devcontainer/PLAYWRIGHT_SETUP.md: Documents Chromium path structure, version-to-revision mapping, and verification steps.devcontainer/scripts/verify-playwright-path.sh: Automated checker that validates Dockerfile Playwright version matches.mcp.jsonexecutable path.devcontainer/README.md: Quick reference section for running verificationVerification script capabilities:
Script uses numeric sorting for reliable revision comparison and suggests
jq-based fixes for path mismatches.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Summary by cubic
Updated the legacy CI test workflow and devcontainer so Playwright tests run reliably in CI and locally. Addresses feedback in #1792 and adds docs and a verify script for the MCP Chromium path.
Written for commit a817a20. Summary will update on new commits.