Skip to content

feat: launch the ADR browser when Playwright expects another build - #662

Closed
viseshrp wants to merge 5 commits into
mainfrom
feat/browser-pdf-build-fallback
Closed

viseshrp wants to merge 5 commits into
mainfrom
feat/browser-pdf-build-fallback

Conversation

@viseshrp

@viseshrp viseshrp commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Browser PDF keeps working when the ADR installation ships a different browser build than this release's Playwright expects.

Behavior

  • Builds match: normal launch, unchanged.
  • Builds differ: launch ADR's browser by path and log a warning; raise ADRException if it's missing.
  • Expected build unknown: use ADR's browser if present (warning); otherwise log a warning and launch normally.

The browser-PDF guides describe this without Playwright internals.

Validation

  • Same renderer, tests and docs as fix!: security updates and drop Python 3.10 on stable/27.1 #645 (stable/27.1), where the full CI run passed.
  • main still pins Playwright 1.60.0, which matches ADR 27.1, so the normal path is unchanged.
  • Locally: pre-commit, uv lock --locked, smoke test, and a direct check of all five launch cases.

Work item: to be added

🤖 Generated with Claude Code

viseshrp and others added 5 commits November 2, 2026 11:41
Playwright only launches the Chromium build that matches its own version,
so a pydynamicreporting release whose Playwright pin differs from the build
an ADR installation ships cannot export browser PDFs.

Browser PDF now reads the build Playwright expects from its documented
BrowserType.executable_path (the chromium-<build> directory) and compares
it with the build named in ADR's browser metadata:

- Same build: normal launch, as before.
- Different build: launch ADR's headless shell by path and log a warning.
  If that executable is missing, raise ADRException.
- Unknown expected build: launch ADR's headless shell if it is present,
  with a warning; otherwise log a warning and use the normal launch.

The browser-PDF guides describe this in user terms, without Playwright
internals, and the CHANGELOG has an entry.

Carried over from PR #645 (stable/27.1), where the same renderer, tests and
docs passed the full CI run. main still pins Playwright 1.60.0, which
matches the build ADR 27.1 ships, so the normal launch path is unchanged.

Verified here with pre-commit (all hooks pass except add-license-headers,
which cannot create symlinks on this Windows host and runs in CI),
uv lock --locked, tests/smoketest.py, and a direct run of the launch-option
function for all five cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ADR Docker image moved from ghcr.io/ansys-internal/adr_dev to
ghcr.io/snps-ansys-internal/adr_dev:latest. CI's pull of the old image is
refused ("denied"), so every Testing job stops before running tests.

Point the CI pull script, the default DOCKER_REPO_URL and
DOCKER_DEV_REPO_URL constants (which the tests and the Service default
use), and the two compatibility tests at the new image. The CHANGELOG
notes the new default.

Verified with pre-commit (all hooks pass except add-license-headers, which
cannot create symlinks on this Windows host and runs in CI) and the two
updated tests in tests/test_compatibility.py. Pulling the new image is
verified by CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ADR Docker image moved to ghcr.io/snps-ansys-internal, which belongs
to the EMU enterprise. This repository's GITHUB_TOKEN cannot read packages
there, so the pull fails with "manifest unknown".

Log in to ghcr.io with the new ADR_GHCR_USERNAME and ADR_GHCR_TOKEN
repository secrets (an EMU account token with read:packages) instead.
tests.yml is a reusable workflow, so it declares both secrets and its
callers, ci_cd.yml and nightly.yml, pass them in.

Dependabot and fork PRs don't receive repository secrets, so their Testing
jobs can't pull the image.

Verified with pre-commit, including the GitHub workflow validator (all
hooks pass except add-license-headers, which cannot create symlinks on this
Windows host and runs in CI). The pull itself is verified by CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ADR Docker image location only matters to this repository's CI, not
to users, so it doesn't belong in the CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The snps-ansys-internal EMU org has an IP allow list that blocks
GitHub-hosted runners, so CI could not pull the ADR image from there even
with a valid EMU token. The image is now copied to ghcr.io/ansys/adr_dev.

Point the CI pull script, DOCKER_REPO_URL, DOCKER_DEV_REPO_URL and the two
compatibility tests at ghcr.io/ansys/adr_dev:latest, and log in with the
repository's GITHUB_TOKEN again. This reverts the ADR_GHCR_USERNAME and
ADR_GHCR_TOKEN secrets in tests.yml, ci_cd.yml and nightly.yml.

Verified with pre-commit, including the GitHub workflow validator (all
hooks pass except add-license-headers, which cannot create symlinks on this
Windows host and runs in CI), and the two updated tests in
tests/test_compatibility.py. The pull itself is verified by CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@viseshrp

viseshrp commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

Closing in favour of #665, which includes this change and goes further.

Compared file by file against #665 (c51cc809c):

Behaviour in this PR In #665
Matching browser build → Playwright's normal launch ✅
Different build, packaged executable present → launch it by path and warn ✅
Different build, packaged executable missing → "browser build … is incomplete" ADRException ✅ raised before any launch, which also avoids leaked Playwright temp folders
Docker image move (pull_adr_image.sh, constants.py, test_compatibility.py) ✅ identical
doc/source/serverless/browser_pdf.rst, doc/source/userguide/browser_pdf.rst ✅ identical
CHANGELOG ✅ covered by #665's rc4 and Unreleased entries
Expected build unknown, packaged executable present → launch it by path ❌ #665 lets Playwright's lookup pick inside the installation's playwright-browsers folder. Tracked in #667.
Expected build unknown, packaged executable missing → Playwright's lookup Different: #665 raises the "incomplete" error before launching.
Expected build read from chromium.executable_path Different: #665 reads Playwright's browsers.json for the headless-shell revision directly.

#665 also adds handling for leftover browser folders in the ADR installation, and has been tested end to end against ADR 27.1 (1248) and 27.2 (1223).

@viseshrp viseshrp closed this Nov 5, 2026
viseshrp added a commit that referenced this pull request Nov 5, 2026
Ports #645 (merged into `stable/27.1`) to `main`.

Addresses
https://ado.internal.synopsys.com/tfs/ANSYS_development/Portfolio/_workitems/edit/1534172
Also
https://ado.internal.synopsys.com/tfs/ANSYS_Development/Portfolio/_workitems/edit/1536094,
https://ado.internal.synopsys.com/tfs/ANSYS_Development/Portfolio/_workitems/edit/1536102
and
https://ado.internal.synopsys.com/tfs/ANSYS_Development/Portfolio/_workitems/edit/1536105

## Changes

- **Breaking:** drop Python 3.10. `requires-python` is now `>=3.11,
<3.15`. 3.10 is end-of-life, has no eMudhra fix, and current
Pillow/Django don't support it.
- **Security:**
- djangorestframework 3.18 (cap `<3.19.0`): CVE-2026-114136,
CVE-2026-114137.
- Playwright 1.64.1: its bundled Node.js distrusts the eMudhra
intermediates.
- Pillow 13.0.0 (lockfile). Pillow 13 can't save `I`-mode images as PNG,
so `png_compatible_image` converts them to `I;16` first (same output as
before).
- CI: `pypa/gh-action-pypi-publish` v1.14.3; Security Scan runs on
`stable/**`.
- certifi is not pinned. ADR guarantees certifi ≥ 2026.10.19 in its own
environment; `SECURITY.md` tells users who manage their own environment
to update it.
- **Browser PDF:** if the ADR installation ships a different browser
build than Playwright expects, launch the installation's browser by path
and log a warning. This compares build names; no launch has to fail
first, and a launch failure is never retried or interpreted. A build
without its executable raises `ADRException` before any launch. It never
uses another browser.
- **Browser PDF, extra builds:** the export uses the build named in the
installation's browser metadata and ignores other builds in the folder
(for example after copying a newer ADR package over an older one), with
a warning. The metadata entry must be a plain folder name.
- **Docker image:** the default image moves from
`ghcr.io/ansys-internal/adr_dev` to `ghcr.io/ansys/adr_dev:latest`
(`constants.py`, `scripts/pull_adr_image.sh`,
`tests/test_compatibility.py`), because the built-in token can no longer
pull from `ansys-internal`. This changes the default image for
Docker-mode users.
- **Minimum versions:** runtime floors match ADR 26.1's bundled
versions. statsmodels needs 0.14.5+. `constraints/v261.txt` is
unchanged, so 26.1-profile installs keep Django 4.2 and DRF 3.15.

## Differences from #645

- The browser-PDF logic has moved on from #645 (build-name comparison
instead of retrying a failed launch; metadata-named build).
- The README link to the TLS guidance points at `main` instead of
`stable/27.1`.
- `uv.lock` is regenerated on `main` and refreshed with `uv lock
--upgrade`, so it no longer matches `stable/27.1` exactly. Notably
`python-dateutil` is locked at 4.0.0.
- Django 5.2.18 and `ansys/actions` v11.1.3 are already on `main`.

## Validation

`uv lock --locked`, pre-commit, smoke test and wheel build pass. The
browser-PDF renderer and browser-binary tests pass (169) against a local
ADR 27.1 install. Full ADR/Docker tests run in CI. The manual ADR 26.1
workflow runs were not repeated for this port.

Browser PDF was also checked end to end against a local ADR 27.2
install, which ships Chromium 1223 while this release expects 1248: the
`local_tests` browser-PDF scripts produced 8 correct PDFs (serverless
and service mode, portrait and landscape, rendered by Chromium 148), and
real-browser launch checks covered a leftover 1248 folder next to 1223,
a missing executable (no launch, no leaked temp folders) and a
non-browser executable. The PDFs were produced on `b3cc226bc` and the
launch checks on `c51cc809c`; later commits do not change the path an
older installation takes.

## Related

- Supersedes #662, which is closed.
- Follow-up #667: always launch the metadata-named browser by path.
Until then, if Playwright's expected build cannot be read and the
installation ships a different build, the normal launch fails and is not
retried.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant