Skip to content

feat(TU-47260): add turbo-cache and per-package coverage PR comment to frontend-pr-workflow - #271

Draft
sh-waqar wants to merge 1 commit into
fix/reusable-workflow-secrets-and-runner-defaultsfrom
feat/turbo-cache-coverage-comment
Draft

sh-waqar wants to merge 1 commit into
fix/reusable-workflow-secrets-and-runner-defaultsfrom
feat/turbo-cache-coverage-comment

Conversation

@sh-waqar

Copy link
Copy Markdown

Stacked on #270, which is the base branch. GitHub retargets this PR to main when #270 merges.

Three opt-in inputs for frontend-pr-workflow. The defaults keep today's behaviour.

Input What it does
turbo-cache: true Turbo remote cache backed by the GitHub Actions cache (rharkor/caching-for-turbo, pinned by SHA), in the build and unit-test jobs. Unchanged packages replay their cached outputs, including coverage/, instead of re-running.
coverage-path Replaces the hardcoded coverage/ upload path. Accepts newline-separated globs for monorepos, e.g. packages/*/coverage.
coverage-report: off | always | on-failure Sticky PR comment with one row per coverage-summary.json. on-failure creates the comment only when unit tests fail, then keeps it updated so a fix shows ✅.

Why

  • Nothing shared replaced SonarCloud after it was removed from the shared workflows (PLT-3524), so teams have been adding their own:
    • admin-home adds a job of its own that downloads this workflow's coverage-${run_id} artifact and posts it with MishaKav/jest-coverage-comment@main, on every PR.
    • in-app-notifications (TU-46981) posts lcov.info with romeovs/lcov-reporter-action, only when coverage falls below its threshold.
    • Both could move to coverage-report: always and on-failure respectively.
  • Coverage didn't work for monorepos. The coverage path was fixed to a root coverage/, so per-package coverage in a monorepo was never uploaded.
  • Turbo monorepos started every run with an empty cache.

Design notes

  • Commenting happens in its own coverage-comment job with pull-requests: write. The workflow-level permissions (id-token, contents) narrow every job's token, and unit-tests shouldn't need more. This follows the existing deep-purple job.
  • Reporting never fails the build. Thresholds stay in the test tool's own config (Vitest or Jest).
  • The comment rows are labelled with each package's directory, e.g. packages/hooks.
  • A single-app repo keeps the default coverage/ and gets a one-row table.

Verified on frontend-packages #32 (pnpm + Turbo, 2 packages and 1 app)

Run What changed Result
1 first run cache miss for every task; entries saved; comment posted
2 only pr.yml FULL TURBO: lint and build 3/3 cached, test:coverage 2/2 cached (178 ms, vs about 8 s when it ran)
3 one package's src only @typeform/hooks missed on lint, build and test; every task for the other packages replayed

Local check: the comment logic was run against every combination of mode × passed/failed × existing comment.

One question for reviewers: is it OK to run rharkor/caching-for-turbo inside the shared workflow? It's pinned by SHA and opt-in. The first-party alternative is actions/cache on .turbo/cache, which is simpler but never prunes old entries.

🤖 Generated with Claude Code

https://claude.ai/code/session_019tUHRKTe2YrU4YwTbKzXPH

…o frontend-pr-workflow

All opt-in; defaults keep today's behaviour.

- turbo-cache: Turbo remote cache backed by the GitHub Actions cache
  (rharkor/caching-for-turbo, pinned by SHA) in the build and unit-test jobs.
  Unchanged packages replay their outputs (e.g. coverage/) instead of re-running.
- coverage-path: configurable coverage upload path (was hardcoded coverage/),
  newline-separated globs for monorepos, e.g. packages/*/coverage.
- coverage-report: off | always | on-failure. unit-tests builds a sticky comment
  with one row per coverage-summary.json; a separate coverage-comment job posts
  it, so only that job gets pull-requests: write (the workflow-level permissions
  narrow every other job's token). on-failure creates the comment only when unit
  tests fail and keeps an existing one updated, so a fix flips it to passing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019tUHRKTe2YrU4YwTbKzXPH
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