Skip to content

fix(plugin-e2e): remove uuid and semver runtime dependencies#2650

Open
sunker wants to merge 7 commits into
mainfrom
plugin-e2e/remove-uuid-and-semver-deps
Open

fix(plugin-e2e): remove uuid and semver runtime dependencies#2650
sunker wants to merge 7 commits into
mainfrom
plugin-e2e/remove-uuid-and-semver-deps

Conversation

@sunker
Copy link
Copy Markdown
Contributor

@sunker sunker commented May 25, 2026

What this PR does / why we need it:

Inlines a two deps used in @grafana/plugin-e2e to reduce the likelihood of supply chain attacks reaching consumers. uuid is replaced with crypto.randomUUID() and semver is replaced with a tiny version utility at src/utils/version.ts. Also exports the new gte, lt, lte, gt, eq and satisfies helpers so plugin authors can use them without pulling in semver themselves.

Which issue(s) this PR fixes:

Fixes #2647

Special notes for your reviewer:

@sunker sunker added the patch Increment the patch version when merged label May 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 25, 2026

Hello! 👋 This repository uses Auto for releasing packages using PR labels.

✨ This PR can be merged but will not trigger a new release. To trigger a new release add the release label before merging.
NOTE: When merging a PR with the release label please avoid merging another PR. For further information see here.

sunker added 4 commits May 25, 2026 10:43
Previous `npm install` on macOS regenerated the lockfile and dropped the
encoding and iconv-lite@0.6.3 entries (optional deps of minipass-fetch)
that npm ci on Linux expects to be present. Restored those entries from
main, kept only the intended uuid and @types/uuid removals.
The previous build-numbered threshold `13.1.0-25389005429` relied on
semver pre-release semantics (release > pre-release) to ensure final
13.1.0 took the textbox path. The new inline version utility treats
dash-suffixed builds as newer than the base release, which inverts that
relationship. Tighten the threshold to plain `13.1.0` so the textbox path
applies to all 13.1.0 builds and onward.
Previously the utility treated a dash-suffixed build identifier as a 4th
component that made the version newer than the base release. That broke
existing call sites like the slider threshold in PanelEditOptionsGroup,
which were written assuming standard semver semantics where any
pre-release sorts below the matching release (`1.2.3-X` < `1.2.3`).

Reimplemented `parseVer` to track pre-release identifiers as a list and
follow semver section 11 precedence rules:
- Releases outrank any pre-release of the same MAJOR.MINOR.PATCH.
- Numeric pre-release identifiers compare numerically; non-numeric ones
  compare lexicographically; numeric < non-numeric.
- A longer set of identifiers outranks a shorter prefix-equal set.
- Build metadata after `+` is ignored.

Reverted the threshold in PanelEditOptionsGroup back to
`13.1.0-25389005429` since the original semantics are restored, and
updated the tests to assert the new pre-release precedence behavior.
@sunker sunker marked this pull request as ready for review May 25, 2026 11:33
Copilot AI review requested due to automatic review settings May 25, 2026 11:33
@sunker sunker requested review from a team as code owners May 25, 2026 11:33
@sunker sunker requested review from academo, eledobleefe, jackw, oshirohugo and xnyo and removed request for a team May 25, 2026 11:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces the runtime dependency surface of @grafana/plugin-e2e by removing uuid and semver, replacing them with built-in APIs and a small in-repo version comparison utility. It also exposes the new version helpers from the package entrypoint so plugin authors can reuse them without adding semver.

Changes:

  • Added src/utils/version.ts with gte, gt, lte, lt, eq, and satisfies, plus unit tests.
  • Replaced semver usage across plugin-e2e page models/components/fixtures with the new helpers.
  • Replaced uuidv4() with crypto.randomUUID() and removed semver/uuid (and @types/uuid) from packages/plugin-e2e/package.json and the lockfile; updated docs to use the exported helpers.

Reviewed changes

Copilot reviewed 24 out of 25 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/plugin-e2e/src/utils/version.ts Introduces inlined semver-like comparison and range checking helpers.
packages/plugin-e2e/src/utils/version.test.ts Adds vitest coverage for version parsing/comparison and satisfies().
packages/plugin-e2e/src/models/pages/VariableEditPage.ts Switches Grafana version branching from semver to local gte/lt.
packages/plugin-e2e/src/models/pages/PanelEditPage.ts Switches version checks from semver to local helpers.
packages/plugin-e2e/src/models/pages/ExplorePage.ts Switches version checks from semver to local lt.
packages/plugin-e2e/src/models/pages/DashboardPage.ts Switches version checks from semver to local helpers.
packages/plugin-e2e/src/models/pages/AnnotationPage.ts Switches version checks from semver to local gte.
packages/plugin-e2e/src/models/pages/AnnotationEditPage.ts Switches version checks from semver to local helpers.
packages/plugin-e2e/src/models/pages/AlertRuleEditPage.ts Switches version checks from semver to local helpers.
packages/plugin-e2e/src/models/components/TimeRange.ts Switches version checks from semver to local gte.
packages/plugin-e2e/src/models/components/Switch.ts Switches version checks from semver to local helpers.
packages/plugin-e2e/src/models/components/RadioGroup.ts Switches version checks from semver to local gte.
packages/plugin-e2e/src/models/components/PanelEditOptionsGroup.ts Switches version checks from semver to local helpers.
packages/plugin-e2e/src/models/components/Panel.ts Switches version checks from semver to local lt.
packages/plugin-e2e/src/models/components/DataSourcePicker.ts Switches version checks from semver to local lt.
packages/plugin-e2e/src/models/components/ColorPicker.ts Switches version checks from semver to local gte.
packages/plugin-e2e/src/index.ts Exports the new version helpers from the public package API.
packages/plugin-e2e/src/fixtures/page.ts Switches version checks from semver to local gte.
packages/plugin-e2e/src/fixtures/commands/gotoAlertRuleEditPage.ts Switches version checks from semver to local lt.
packages/plugin-e2e/src/fixtures/commands/createDataSource.ts Replaces uuid with crypto.randomUUID() for datasource naming.
packages/plugin-e2e/src/fixtures/alertRuleEditPage.ts Switches version checks from semver to local lt.
packages/plugin-e2e/package.json Removes semver, uuid, and @types/uuid dependencies.
package-lock.json Removes uuid and @types/uuid entries for plugin-e2e.
docusaurus/docs/e2e-test-a-plugin/test-a-data-source-plugin/annotation-queries.md Updates example to use gte exported by @grafana/plugin-e2e.
docusaurus/docs/e2e-test-a-plugin/feature-toggles.md Removes semver import from documentation snippet.

Comment thread packages/plugin-e2e/src/utils/version.ts
@sunker sunker requested a review from mckn May 25, 2026 13:46
@tolzhabayev tolzhabayev moved this from 📬 Triage to 🔬 In review in Grafana Catalog Team May 26, 2026
gcomApiClient.js used `uuid.v4()` for an x-request-id header but relied
on transitive resolution from plugin-e2e to find the package. Now that
plugin-e2e no longer ships uuid, the website build fails to resolve it.
Switch to the built-in crypto.randomUUID() (available in all evergreen
browsers since 2022).
@github-actions
Copy link
Copy Markdown
Contributor

Playwright test results

Image Name Version Result Report
grafana-enterprise nightly
grafana-enterprise dev-preview-react19
grafana-enterprise 13.0.1
grafana-enterprise 12.1.10
grafana-enterprise 11.0.11
grafana-enterprise 9.3.16
grafana-enterprise 8.5.27
Troubleshooting

404 when clicking on View report

By default, the deploy-report-pages Action deploys reports to the gh-pages branch. However, you need to take an extra step to ensure that GitHub Pages can build and serve the site from this branch. To do so:

  1. Go to the Settings tab of your repository.
  2. In the left-hand sidebar, click on Pages.
  3. Under Source, select Deploy from a branch, then choose the gh-pages branch.

This action needs to be completed manually in order for your GitHub Pages site to be built and accessible from the gh-pages branch. Once configured, GitHub will automatically build and serve the site whenever new reports are deployed.

Copy link
Copy Markdown
Collaborator

@mckn mckn left a comment

Choose a reason for hiding this comment

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

LGTM!

@jackw jackw changed the title Plugin E2E: Remove uuid and semver runtime dependencies fix(plugin-e2e): remove uuid and semver runtime dependencies May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged

Projects

Status: 🔬 In review

Development

Successfully merging this pull request may close these issues.

Plugin E2E: Reduce runtime dependencies

4 participants