Skip to content

feat(ci): diagram-scoped e2e test selection#7619

Merged
knsv merged 15 commits into
developfrom
chore/7593_run-scoped-e2e-tests
Apr 21, 2026
Merged

feat(ci): diagram-scoped e2e test selection#7619
knsv merged 15 commits into
developfrom
chore/7593_run-scoped-e2e-tests

Conversation

@pbrolin47
Copy link
Copy Markdown
Collaborator

@pbrolin47 pbrolin47 commented Apr 13, 2026

Summary

Resolves #7593

  • Adds scripts/e2e-diagram-scope.mjs — a pure Node.js ESM detection engine that reads changed file paths and emits only the matching Cypress --spec pattern (or an empty string to trigger the full suite)
  • Adds scripts/run-e2e-scoped.ts — local dev runner that diffs HEAD vs a base ref and spawns Cypress with the scoped spec list
  • Adds scripts/e2e-diagram-scope.spec.ts — 14 unit tests covering all classification paths (single diagram, shared code, unknown diagram, multi-diagram, cross-cutting specs)
  • Adds 4 new pnpm scripts: e2e:scope, e2e:scope:harness, e2e:scope:run, e2e:scope:detect
  • Adds a detect-scope CI job that runs in parallel with cache (no critical-path penalty), uses a dynamic matrix ([1] when scoped, [1,2,3,4,5] for the full suite), and passes the spec: filter to cypress-io/github-action
  • Diagram-specific rendering tests are moved into subfolders

Classification

  • Change type: CI/tooling
  • Breaking change: No — feature flag (E2E_SCOPE_BY_DIAGRAM) defaults to false; existing behavior is fully preserved until the flag is enabled
  • Shared code touched: No diagram source code changed

How to enable

Set a repository variable in GitHub → Settings → Secrets and variables → Actions → Variables:

E2E_SCOPE_BY_DIAGRAM = true

When enabled, a PR that only touches (e.g.) packages/mermaid/src/diagrams/flowchart/ will run only cypress/integration/rendering/flowchart/flowchart*.spec.* in a single container instead of the full 5-container suite.

Any change to shared code (rendering-util/, themes/, config, diagram-api/, parser/, etc.) falls back automatically to the full suite.

Verification

  • Unit tests added (scripts/e2e-diagram-scope.spec.ts) — run with vitest run scripts/e2e-diagram-scope
  • comp-review-changes: passed (0 blockers)
  • Breaking change: No — opt-in only, full suite is the default
  • Lint: run pnpm lint locally
  • Full e2e: N/A for CI-only change; existing suite validates once merged to develop

Note for testing locally:
In your local repo, do changes locally. Then you can issue command
git status --short | awk '{print $2}' | node scripts/e2e-diagram-scope.mjs

If an empty string is will result in the full e2e-suite will be run in CI, otherwise specific diagram folders will be returned

For testing locally together with cypress, you can use the steps below:

# For hardcoded local testing, use echo with newlines
SPEC=$(echo "packages/mermaid/src/diagrams/state/stateDiagram.ts" | node scripts/e2e-diagram-scope.mjs)

# Multiple files
SPEC=$(printf "packages/mermaid/src/diagrams/state/foo.ts\npackages/mermaid/src/diagrams/flowchart/bar.ts" | node scripts/e2e-diagram-scope.mjs)

echo "Running spec: ${SPEC:-'(full suite)'}"
pnpm cypress --spec "$SPEC"

🤖 Generated with Claude Code

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 13, 2026

⚠️ No Changeset found

Latest commit: ab1ce31

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 13, 2026

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit ab1ce31
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/69e72f419e59c500088b2409
😎 Deploy Preview https://deploy-preview-7619--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added Type: Other Not an enhancement or a bug Sponsored by MermaidChart labels Apr 13, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 13, 2026

Open in StackBlitz

@mermaid-js/examples

npm i https://pkg.pr.new/@mermaid-js/examples@7619

mermaid

npm i https://pkg.pr.new/mermaid@7619

@mermaid-js/layout-elk

npm i https://pkg.pr.new/@mermaid-js/layout-elk@7619

@mermaid-js/layout-tidy-tree

npm i https://pkg.pr.new/@mermaid-js/layout-tidy-tree@7619

@mermaid-js/mermaid-zenuml

npm i https://pkg.pr.new/@mermaid-js/mermaid-zenuml@7619

@mermaid-js/parser

npm i https://pkg.pr.new/@mermaid-js/parser@7619

@mermaid-js/tiny

npm i https://pkg.pr.new/@mermaid-js/tiny@7619

commit: ab1ce31

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 0.53476% with 186 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.31%. Comparing base (530124c) to head (ab1ce31).
⚠️ Report is 21 commits behind head on develop.

Files with missing lines Patch % Lines
scripts/e2e-diagram-scope.mjs 0.00% 166 Missing ⚠️
scripts/run-e2e-scoped.ts 4.76% 20 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #7619      +/-   ##
==========================================
- Coverage     3.32%   3.31%   -0.01%     
==========================================
  Files          537     540       +3     
  Lines        56477   56675     +198     
  Branches       822     824       +2     
==========================================
+ Hits          1879    1880       +1     
- Misses       54598   54795     +197     
Flag Coverage Δ
unit 3.31% <0.53%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
scripts/run-e2e-scoped.ts 4.76% <4.76%> (ø)
scripts/e2e-diagram-scope.mjs 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

🚀 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.

@argos-ci
Copy link
Copy Markdown

argos-ci Bot commented Apr 13, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) 👍 Changes approved 1 changed Apr 21, 2026, 8:17 AM

Copy link
Copy Markdown
Collaborator

@knsv knsv left a comment

Choose a reason for hiding this comment

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

One change we should think about. We could do that in a separate PR but that one should not wait too long.

Comment thread scripts/e2e-diagram-scope.mjs Outdated
@knsv
Copy link
Copy Markdown
Collaborator

knsv commented Apr 13, 2026

Also check the linting

pbrolin47 and others added 13 commits April 15, 2026 09:16
Move all diagram-specific Cypress specs from the flat
cypress/integration/rendering/ directory into per-diagram subfolders
(e.g. cypress/integration/rendering/flowchart/).

The detection script now uses filesystem discovery instead of a
hardcoded DIAGRAM_SPEC_MAP: it checks whether
cypress/integration/rendering/<diagram-name>/ exists and returns
a glob pattern (cypress/integration/rendering/<name>/**) as the
--spec argument. Adding a new spec to a subfolder requires zero
config changes.

Cross-cutting specs (theme, conf-and-directives, shapes, etc.) remain
at the root of cypress/integration/rendering/ and continue to trigger
the full suite.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ntion

Any spec file at the root of cypress/integration/rendering/ is treated
as cross-cutting (full suite). Any spec in a subfolder is scoped to that
subfolder. No explicit list to maintain — the directory position is the
convention.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@pbrolin47 pbrolin47 marked this pull request as ready for review April 21, 2026 08:29
@knsv knsv added this pull request to the merge queue Apr 21, 2026
Merged via the queue into develop with commit 5969033 Apr 21, 2026
31 checks passed
@knsv knsv deleted the chore/7593_run-scoped-e2e-tests branch April 21, 2026 08:50
@mermaid-bot
Copy link
Copy Markdown

mermaid-bot Bot commented Apr 21, 2026

@pbrolin47, Thank you for the contribution!
You are now eligible for a year of Premium account on MermaidChart.
Sign up with your GitHub account to activate.

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

Labels

Sponsored by MermaidChart Type: Other Not an enhancement or a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decrease the number of e2e-tests that run for each PR.

2 participants