Skip to content

fix(templates): Pin playwright to base image version in uv Dockerfile template#1904

Open
vdusek wants to merge 1 commit into
masterfrom
fix/uv-template-playwright-version-pin
Open

fix(templates): Pin playwright to base image version in uv Dockerfile template#1904
vdusek wants to merge 1 commit into
masterfrom
fix/uv-template-playwright-version-pin

Conversation

@vdusek
Copy link
Copy Markdown
Collaborator

@vdusek vdusek commented May 19, 2026

Summary

The uv package-manager branch of the actor Dockerfile template (src/crawlee/project_template/{{cookiecutter.project_name}}/Dockerfile) doesn't pin Python playwright to the version pre-installed in the Apify base image. When the lockfile resolves to a different playwright version than the base image (currently 1.59.0 vs the base image's 1.60.0 + chromium-1223), the actor tries to launch a Chromium build that /pw-browsers/ doesn't ship and fails with Executable doesn't exist at /pw-browsers/chromium_headless_shell-1217/....

The pip and poetry branches solve this by sed-rewriting playwright==X.Y.Z to whatever playwright --version reports in the image. The uv branch's --no-install-package playwright was supposed to be the equivalent, but the test's pip install crawlee --force-reinstall (and any user step that touches playwright before the uv sync runs) defeats it.

This fix mirrors the pip/poetry intent for uv:

  • Snapshot the base image's playwright --version in the early pip install uv layer, before COPY pyproject.toml uv.lock ./ or any test-injected step can mutate it.
  • After uv sync ... --no-install-package playwright, check if the env's playwright still matches; if it has drifted, force-reinstall with uv pip install --reinstall --no-deps "playwright==<base-version>".
  • Guard the reinstall behind a version check so the common case (no drift) skips the wheel download.

Resolves the 9 failing uv-variant scheduled e2e jobs in run 26082797876 (playwright, adaptive_beautifulsoup, adaptive_parsel × {httpx, curl_impersonate, impit}).

Verified against the live apify/actor-python-playwright:3.13 image:

Scenario Before After
Real user, no drift works, but pip freeze | grep playwright check is brittle guard short-circuits, no extra work
Test injection downgrades playwright to 1.59.0 mismatched chromium → crash reinstall pins to 1.60.0, browsers match

The uv branch previously kept whatever playwright version happened to be in
the env after `uv sync`, which can drift from the version baked into the
Apify base image — so the actor would look for a Chromium build that
`/pw-browsers/` doesn't ship. Snapshot the base image's playwright version
before `COPY`/`uv sync` and pin to it afterwards (mirroring the existing
sed-rewrite the pip and poetry branches use).
@vdusek vdusek added t-tooling Issues with this label are in the ownership of the tooling team. adhoc Ad-hoc unplanned task added during the sprint. labels May 19, 2026
@vdusek vdusek self-assigned this May 19, 2026
@github-actions github-actions Bot added this to the 141st sprint - Tooling team milestone May 19, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.89%. Comparing base (7edfe0d) to head (709d61a).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1904      +/-   ##
==========================================
+ Coverage   92.86%   92.89%   +0.02%     
==========================================
  Files         167      167              
  Lines       11709    11709              
==========================================
+ Hits        10874    10877       +3     
+ Misses        835      832       -3     
Flag Coverage Δ
unit 92.89% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek vdusek changed the title fix: Pin playwright to base image version in uv Dockerfile template fix(templates): Pin playwright to base image version in uv Dockerfile template May 19, 2026
@vdusek vdusek requested a review from janbuchar May 19, 2026 08:48
echo "Playwright $PLAYWRIGHT_BASE_VERSION pre-installed in base image; excluding from uv sync" \
&& uv sync --frozen --no-install-project --no-editable -q --no-dev --inexact --no-install-package playwright \
&& CURRENT_PLAYWRIGHT_VERSION=$(playwright --version 2>/dev/null | cut -d ' ' -f 2) \
&& if [ "$CURRENT_PLAYWRIGHT_VERSION" != "$PLAYWRIGHT_BASE_VERSION" ]; then \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do this check every time, what is the point of the --no-install-package playwright? It looks like a belt-and-suspenders thing to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants