Skip to content

feat: swap to instrumented __coverage image in dedicated nightly coverage runs#117

Open
gustavolira wants to merge 4 commits into
redhat-developer:mainfrom
gustavolira:feat/nightly-coverage-image-swap
Open

feat: swap to instrumented __coverage image in dedicated nightly coverage runs#117
gustavolira wants to merge 4 commits into
redhat-developer:mainfrom
gustavolira:feat/nightly-coverage-image-swap

Conversation

@gustavolira

Copy link
Copy Markdown
Member

Why

A nightly run can only collect browser coverage if RHDH deploys the instrumented __coverage plugin image. Today the image swap only happens in PR mode (plugin-metadata.ts, when a PR OCI URL is present). Nightly runs deploy the plain released image, so window.__coverage__ is never created and no coverage is collected.

This is the consumer side of the overlay's coverage producer (rhdh-plugin-export-overlays#2645), which builds the bs_X__Y__coverage variant of released images.

What

In the nightly OCI-direct resolution branch (plugins not in default.packages.yaml), for a frontend plugin, swap the image tag to its __coverage variant — the same :(tag):(tag)__coverage rewrite already used in PR mode.

Safety — the functional nightly cannot break

The gating is deliberately conservative:

  • E2E_NIGHTLY_COVERAGE (explicit opt-in), NOT the ambient E2E_COLLECT_COVERAGE. run-e2e.sh defaults E2E_COLLECT_COVERAGE=true, so gating on it would make every functional nightly deploy __coverage images — and since those are built non-fatally by the overlay release publish, a missing one would break the deployment. Requiring the explicit opt-in keeps the functional nightly's resolution byte-identical to today (the env check short-circuits before any fs access).
  • coverage-anchors/ presence — the same rolled-out signal the overlay release publish uses to build the __coverage variant — so a plugin without one is never pointed at a tag that doesn't exist.
  • frontend-plugin role only.

The {{inherit}} branch (DPDY plugins) is untouched — those resolve to the RHDH catalog image, which we can't instrument.

So: the functional nightly (no E2E_NIGHTLY_COVERAGE) behaves exactly as before. Only a dedicated coverage run that sets the flag (and ensures the images exist) gets the swap.

Tests

plugin-metadata.nightly.test.ts adds:

  • opted-in swap produces the __coverage tag, preserving the !path
  • no swap in the functional nightly even with E2E_COLLECT_COVERAGE on
  • no swap when the workspace isn't rolled out (no coverage-anchors/)
  • no swap for non-frontend roles

yarn check (typecheck + lint + prettier) and the full suite pass (86/86).

🤖 Generated with Claude Code

gustavolira and others added 4 commits June 22, 2026 15:42
…rage runs

A nightly run can only collect browser coverage if RHDH deploys the
instrumented __coverage plugin image. Today the image swap only happens
in PR mode (when a PR OCI URL is present); nightly runs deploy the plain
released image, so window.__coverage__ is never created.

Add the swap to the nightly OCI-direct resolution branch (plugins not in
default.packages.yaml): for a frontend plugin, replace the image tag with
its __coverage variant.

Gating is deliberately conservative so the FUNCTIONAL nightly cannot
break:
- E2E_NIGHTLY_COVERAGE (explicit opt-in), NOT the ambient
  E2E_COLLECT_COVERAGE. run-e2e.sh defaults E2E_COLLECT_COVERAGE=true, so
  gating on it would make every functional nightly deploy __coverage
  images — and since those are built non-fatally by the overlay release
  publish, a missing one would break the deployment. Requiring the
  explicit opt-in keeps the functional nightly's resolution byte-identical
  to today (the env check short-circuits before any fs access).
- coverage-anchors/ presence (the same rolled-out signal the overlay
  release publish uses to build the __coverage variant), so a plugin
  without one is never pointed at a tag that does not exist.
- frontend-plugin role only.

The {{inherit}} branch (DPDY plugins) is untouched — those resolve to the
RHDH catalog image, which we cannot instrument.

Adds tests for: opted-in swap, no swap in the functional nightly even
with E2E_COLLECT_COVERAGE on, no swap when not rolled out, no swap for
non-frontend roles.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Review follow-ups on the nightly coverage swap:

- Extract toCoverageImageRef() so the `:(tag)__coverage` rewrite (and the
  greedy-up-to-! regex) lives in one documented place instead of being
  duplicated across PR mode and nightly resolution.
- Hoist the workspace-root resolution to a single workspaceRoot const
  (was computed twice).
- Document the new behavior per the repo convention: a changelog entry,
  an E2E_NIGHTLY_COVERAGE row in the environment-variables reference, and
  a coverage-swap section in plugin-metadata-resolution.

No behavior change; full suite still passes (yarn check + tests green).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a test proving a DPDY plugin resolves to {{inherit}} and is never
swapped to a __coverage tag even with E2E_NIGHTLY_COVERAGE on — the core
safety guarantee, since {{inherit}} points at RHDH's catalog image, which
we can't instrument. Also fix a sentence fragment in the toCoverageImageRef
comment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The PR adds a new feature (E2E_NIGHTLY_COVERAGE swap), so bump the minor
version per the repo's version-check gate. 2.1.0 is published, so move
its changelog section to released and open a new [2.2.0] - Current
section for this change.

Co-Authored-By: Claude Opus 4.8 (1M context) <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