Skip to content

Fast Track: mock webapp dist in backend/coverage guardrail - #1767

Merged
JonasWurst merged 11 commits into
mainfrom
jonas-lig-10262-fast-track-rollout
Jul 27, 2026
Merged

Fast Track: mock webapp dist in backend/coverage guardrail#1767
JonasWurst merged 11 commits into
mainfrom
jonas-lig-10262-fast-track-rollout

Conversation

@JonasWurst

@JonasWurst JonasWurst commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What

The backend/coverage guardrail runs pytest directly, whose conftest.py imports the full app. The app's webapp route (api/routes/webapp.py:18-19) raises a RuntimeError at import time unless the built frontend dir dist_lightly_studio_view_app exists.

The Fast Track guardrails CI never builds the frontend, so on backend PRs the guardrail crashed with an ImportError before collecting any tests — surfacing as Guardrail threw: ... instead of a real pass/fail verdict.

Observed on PR #1753: #1753 (comment)

Fix

Add an idempotent ensureWebappDist() helper, called at the start of runTests, that creates the dist dir + an empty index.html before invoking pytest — mirroring the Makefile's mock-webapp-dist target already used for migration checks. It:

  • fixes both CI and local guardrail runs (the fix lives inside Fast Track, not in the workflow YAML),
  • never overwrites an existing index.html, so a real build on a dev machine is preserved,
  • leaves app code untouched — webapp.py's import-time guard remains a valid production check.

The mock is a per-run throwaway: the dir is gitignored and not cached, so every CI run recreates and discards it; it doesn't leak into other jobs.

Testing

  • New unit tests for ensureWebappDist (creates dir + index when missing; does not overwrite an existing index).
  • Existing runTests tests updated for the added existsSync call.
  • npm run static-checks and full npm test (204 tests) pass.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved backend validation workflows by ensuring the required web application build artifact is generated before backend guardrails and tests run, preventing import-time failures.

The backend/coverage guardrail runs pytest directly, whose conftest imports
the full app. The app's webapp route raises at import time unless the built
frontend dir (dist_lightly_studio_view_app) exists. The guardrails CI never
builds the frontend, so backend PRs crashed the guardrail with an ImportError
instead of producing a verdict.

Mock the dist (empty dir + index.html) before invoking pytest, mirroring the
Makefile's mock-webapp-dist target. The helper is idempotent and never
overwrites an existing index.html, so local dev builds are preserved.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JonasWurst
JonasWurst requested a review from a team as a code owner July 24, 2026 12:20
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c6793978-4746-42ed-89c6-577ec6deeb6e

📥 Commits

Reviewing files that changed from the base of the PR and between 7b50ca3 and 659e81a.

📒 Files selected for processing (1)
  • .github/workflows/fast_track_guardrails.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/fast_track_guardrails.yml

📝 Walkthrough

Walkthrough

The Fast Track Guardrails workflow conditionally builds the lightly_studio_view webapp artifact when backend changes are detected, making the frontend distribution available to backend guardrail imports.

Changes

Backend guardrail preparation

Layer / File(s) Summary
Conditional webapp build
.github/workflows/fast_track_guardrails.yml
Adds a backend-only workflow step that runs make build-lightly_studio_view from lightly_studio before backend guardrails execute.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

Suggested reviewers: ikondrat, lightly-fast-track-bot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding a Fast Track guardrail fix for the webapp dist.
Description check ✅ Passed It includes the required change summary and testing details, but the changelog section is omitted.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jonas-lig-10262-fast-track-rollout

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lightly-fast-track-bot

lightly-fast-track-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

✅  Fast Track: all required checks passed — auto-approved.

Guardrail Result Message
dummy Always passes.
frontend/complexity 0 file(s) checked.
backend/complexity 0 file(s) checked.
backend/coverage 0 file(s) checked.
diff-size PR adds 7 line(s) (limit: 215).
frontend/coverage 0 file(s) checked.

View the guardrail run

To run the guardrails locally, from fast_track/ run make install once, then make run-guardrails (or GUARDRAILS=<name1>,<name2> make run-guardrails for some guardrails).

Reflects 0e9449e.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 42f7a64a0d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread fast_track/src/guardrails/backend/coverage.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@fast_track/src/guardrails/backend/coverage.ts`:
- Around line 147-153: Update ensureWebappDist() to create index.html atomically
with writeFileSync using the exclusive-create flag ('wx'), rather than checking
with existsSync before writing. Catch and ignore only EEXIST errors so
concurrent or pre-existing files remain untouched, while propagating other
filesystem errors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9e93c5c7-3019-4aa3-8cbd-ca2e30b2a574

📥 Commits

Reviewing files that changed from the base of the PR and between 5acb559 and 42f7a64.

📒 Files selected for processing (2)
  • fast_track/src/guardrails/backend/coverage.test.ts
  • fast_track/src/guardrails/backend/coverage.ts

Comment thread fast_track/src/guardrails/backend/coverage.ts Outdated
@lightly-fast-track-bot
lightly-fast-track-bot Bot dismissed their stale review July 24, 2026 12:24

Superseded by a newer Fast Track approval.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lightly_studio/src/lightly_studio/dataset/embedding_manager.py`:
- Line 3: Remove the temporary validation comment marked “revert me” at the top
of the module, leaving the surrounding implementation unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3bbe8831-767c-47ed-8790-ab51c9ee9568

📥 Commits

Reviewing files that changed from the base of the PR and between 42f7a64 and 0712b04.

📒 Files selected for processing (1)
  • lightly_studio/src/lightly_studio/dataset/embedding_manager.py

Comment thread lightly_studio/src/lightly_studio/dataset/embedding_manager.py Outdated
@lightly-fast-track-bot
lightly-fast-track-bot Bot dismissed their stale review July 24, 2026 12:28

Superseded by a newer Fast Track approval.

@JonasWurst

Copy link
Copy Markdown
Contributor Author

Validated the fix in real CI by temporarily adding a backend change (since this PR only touches fast_track/, backend/coverage doesn't otherwise run here). The guardrail ran pytest cleanly and produced a real verdict instead of crashing on the missing dist_lightly_studio_view_app:

===== guardrail: backend/coverage =====
===== end: backend/coverage =====
Verdict: pass (6 guardrail(s))
  [pass] backend/coverage: 1 file(s) checked, all above 80%.

Successful run: https://github.com/lightly-ai/lightly-studio/actions/runs/30092838147

This is the same guardrail that previously threw on #1753 (#1753 (comment)). The temporary backend change has been reverted, so the PR diff contains only the fast_track/ fix.

- Create index.html with the exclusive-create flag ('wx') so a real build
  written concurrently is never truncated (CodeRabbit).
- ensureWebappDist now returns a cleanup that removes only what it created;
  runTests calls it in a finally so a local guardrail run in an unbuilt
  checkout doesn't leave an empty dist that masks the app's "did you forget
  to build the webapp?" error (Codex).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lightly-fast-track-bot
lightly-fast-track-bot Bot dismissed their stale review July 24, 2026 12:36

Superseded by a newer Fast Track approval.

@lightly-fast-track-bot
lightly-fast-track-bot Bot dismissed their stale review July 24, 2026 12:45

Superseded by a newer Fast Track approval.

@lightly-fast-track-bot
lightly-fast-track-bot Bot dismissed their stale review July 24, 2026 12:48

Superseded by a newer Fast Track approval.

@JonasWurst

Copy link
Copy Markdown
Contributor Author

/review

JonasWurst and others added 2 commits July 24, 2026 15:20
Per team discussion, build the real webapp in the guardrails CI for backend PRs
rather than mocking the dist inside backend/coverage. The app's webapp route
raises at import time unless dist_lightly_studio_view_app exists, so any backend
guardrail that imports the app (backend/coverage runs pytest, whose conftest
imports the full app) previously crashed.

build-lightly_studio_view exports the schema/version, builds the Svelte app, and
copies the dist into the backend package — the same real build test_and_release
produces. This is a shared, reusable setup for any backend guardrail, so it lives
in the workflow rather than in one guardrail's code.

Reverts the TS mock (ensureWebappDist) added earlier on this branch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lightly-fast-track-bot
lightly-fast-track-bot Bot dismissed their stale review July 24, 2026 13:25

Superseded by a newer Fast Track approval.

@lightly-fast-track-bot
lightly-fast-track-bot Bot dismissed their stale review July 24, 2026 13:40

Superseded by a newer Fast Track approval.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/fast_track_guardrails.yml:
- Around line 103-106: Update the “Build webapp for backend guardrails” workflow
step so frontend dependencies are installed before make
build-lightly_studio_view runs, including backend-only and backend-plus-frontend
executions. Move or reuse the existing npm ci setup with a condition covering
every backend build, while preserving the current frontend dependency behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d245633d-6ead-47dc-808f-42f9d4593c3d

📥 Commits

Reviewing files that changed from the base of the PR and between 0712b04 and 7b50ca3.

📒 Files selected for processing (1)
  • .github/workflows/fast_track_guardrails.yml

Comment thread .github/workflows/fast_track_guardrails.yml
Comment thread .github/workflows/fast_track_guardrails.yml Outdated
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lightly-fast-track-bot
lightly-fast-track-bot Bot dismissed their stale review July 27, 2026 06:17

Superseded by a newer Fast Track approval.

@JonasWurst
JonasWurst enabled auto-merge July 27, 2026 06:25
@JonasWurst
JonasWurst added this pull request to the merge queue Jul 27, 2026
Merged via the queue into main with commit dec2109 Jul 27, 2026
21 checks passed
@JonasWurst
JonasWurst deleted the jonas-lig-10262-fast-track-rollout branch July 27, 2026 11:28
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.

2 participants