test: guard against Playwright driver version drift - #317
Open
urwashi2597 wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 tidyinc21f30f(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-gomodule ingo.mod. Two independent sources of truth.Between
25751bfand63902dfthe module graph held two driver modules at once:github.com/mxschmitt/playwright-go v0.6100.0github.com/playwright-community/playwright-go v0.6000.0Both 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 — hencedriver 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 secondplaywright-gomodule entersgo.mod.TestPlaywrightDockerfileVersionMatchesGoMod— fails if the Dockerfile'sPLAYWRIGHT_GO_VERSION, or the module path it installs the CLI from, drifts fromgo.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— coversreplacedirectives..github/workflows/build.yml— adds aPlaywright Driver Consistencystep. 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 broadgo test ./....Validation
The tests were compiled and run against the real
go.modandDockerfilefrom the broken commit, not only fixtures:63902dfDockerfilewith ARG bumped to a version absent fromgo.modmaingo test -race -timeout 5m ./...— pass, no pre-existing failuresmake lint— passgo vet ./...— passgofmt -s -l .— cleango mod tidy— no diffgo build ./...— passNot 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
playwrightCliVersionconstants in each module (v0.6000.0→1.60.0,v0.6100.0→1.61.1).Compatibility
No API or behaviour change. Test and CI only;
go.modandgo.sumuntouched.Related issue
Related to #312 (already resolved in v1.17.1; this guards against recurrence).
🤖 Generated with Claude Code