Skip to content

test: guard against Playwright driver version drift - #317

Open
urwashi2597 wants to merge 1 commit into
gosom:mainfrom
urwashi2597:fix/playwright-driver-version-drift-guard
Open

test: guard against Playwright driver version drift#317
urwashi2597 wants to merge 1 commit into
gosom:mainfrom
urwashi2597:fix/playwright-driver-version-drift-guard

Conversation

@urwashi2597

Copy link
Copy Markdown

Summary

Adds a build-time guard for the class of failure reported in #312. This does not fix a live bug — the symptom reported there was already resolved by the scrapemate v1.3.0 bump plus go mod tidy in c21f30f (released as v1.17.1), and the reporter confirmed it. This PR prevents the same failure from silently returning.

Root cause of #312

The Playwright driver is baked into the image at build time, but the version the binary demands at runtime comes from the playwright-go module in go.mod. Two independent sources of truth.

Between 25751bf and 63902df the module graph held two driver modules at once:

Module How Driver demanded
github.com/mxschmitt/playwright-go v0.6100.0 direct 1.61.1
github.com/playwright-community/playwright-go v0.6000.0 indirect, via scrapemate 1.60.0

Both read PLAYWRIGHT_DRIVER_PATH=/opt/ms-playwright-go, but the image ships only the driver installed by the CLI in the Dockerfile (1.61.1). Scraping runs through scrapemate, which called the community module — hence driver exists but version not 1.60.0.

The build succeeded, vet/lint/tidy passed, and the image built fine. The failure only appeared at runtime inside a container. This same shape produced #301 and #302 as well.

Changes

  • playwright_driver_test.go — hermetic tests (no network, no Docker):
    • TestPlaywrightDriverModuleIsUnique — fails if a second playwright-go module enters go.mod.
    • TestPlaywrightDockerfileVersionMatchesGoMod — fails if the Dockerfile's PLAYWRIGHT_GO_VERSION, or the module path it installs the CLI from, drifts from go.mod.
    • TestPlaywrightDriftIsDetected — pins the checks against the Docker/Web UI jobs fail: Playwright driver exists but version is not 1.60.0 #312 dependency state so they cannot decay into always passing.
    • TestPlaywrightModuleParsingIgnoresReplace — covers replace directives.
  • .github/workflows/build.yml — adds a Playwright Driver Consistency step. The workflow currently runs no tests at all, so the guard would otherwise never execute in CI. Scoped to -run '^TestPlaywright' . to keep the 7-minute job fast rather than adding a broad go test ./....

Validation

The tests were compiled and run against the real go.mod and Dockerfile from the broken commit, not only fixtures:

Target Result
Real files @ 63902df FAIL (intended) — names both conflicting modules
Real Dockerfile with ARG bumped to a version absent from go.mod FAIL (intended)
Current main PASS
go.mod requires github.com/mxschmitt/playwright-go v0.6100.0 and
github.com/playwright-community/playwright-go v0.6000.0; expected exactly one.
  • go test -race -timeout 5m ./... — pass, no pre-existing failures
  • make lint — pass
  • go vet ./... — pass
  • gofmt -s -l . — clean
  • go mod tidy — no diff
  • go build ./... — pass

Not done: I did not rebuild the Docker image to reproduce the runtime error end to end. The attribution rests on the dependency history and the playwrightCliVersion constants in each module (v0.6000.01.60.0, v0.6100.01.61.1).

Compatibility

No API or behaviour change. Test and CI only; go.mod and go.sum untouched.

Related issue

Related to #312 (already resolved in v1.17.1; this guards against recurrence).

🤖 Generated with Claude Code

The Playwright driver is baked into the Docker image at build time, while
the version the binary demands at runtime is set by the playwright-go
module in go.mod. These are independent sources of truth: when they
disagree the build still succeeds and the failure only appears once a job
runs inside a container, as

  could not install driver: driver exists but version not <x> in : /opt/ms-playwright-go

In gosom#312 the module graph held two playwright-go modules at once
(mxschmitt v0.6100.0, requiring driver 1.61.1, and playwright-community
v0.6000.0, requiring 1.60.0, pulled in indirectly via scrapemate) while
both read PLAYWRIGHT_DRIVER_PATH and the image shipped only one driver.
That state was resolved in c21f30f, but nothing prevents it recurring.

Add hermetic tests that fail the build when a second playwright-go module
enters go.mod, or when the Dockerfile's PLAYWRIGHT_GO_VERSION or CLI
module path drifts from go.mod. Wire them into CI, which previously ran
no tests at all.

Verified by running the compiled tests against the go.mod and Dockerfile
from 63902df, where they fail as intended, and against main, where they
pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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