Skip to content

fix(frontend-pr-analysis): detect vitest version for coverage reporter flag#219

Merged
bedatty merged 5 commits intodevelopfrom
fix/vitest3-coverage-reporter-flag
Apr 14, 2026
Merged

fix(frontend-pr-analysis): detect vitest version for coverage reporter flag#219
bedatty merged 5 commits intodevelopfrom
fix/vitest3-coverage-reporter-flag

Conversation

@bedatty
Copy link
Copy Markdown
Contributor

@bedatty bedatty commented Apr 14, 2026

Lerian

GitHub Actions Shared Workflows


Description

Vitest 3 removed the --coverageReporters CLI flag, causing the frontend-pr-analysis workflow to fail with Unknown option --coverageReporters for any repository that upgrades to Vitest 3+.

This PR detects the installed Vitest major version at runtime and selects the appropriate CLI syntax:

  • Vitest 3+: --coverage.reporter=X (dot notation)
  • Vitest 2 / Jest / other: --coverageReporters=X (original syntax)

If Vitest is not installed (e.g., project uses Jest), the detection safely falls back to the original flags.

Type of Change

  • fix: Bug fix in a workflow (incorrect behavior, broken step, wrong condition)

Breaking Changes

None.

Testing

  • YAML syntax validated locally
  • Triggered a real workflow run on a caller repository using @develop or the beta tag
  • Verified all existing inputs still work with default values
  • Confirmed no secrets or tokens are printed in logs
  • Checked that unrelated workflows are not affected

Caller repo / workflow run: https://github.com/LerianStudio/lerian-map/pull/144

Related Issues

Closes #215

Summary by CodeRabbit

  • Chores

    • CI workflows pinned to fixed action versions for more reproducible runs.
    • Safer handling and quoting of CI variables and outputs; improved PR diff and file-change detection logic.
    • Consolidated CI output writes into grouped blocks for more reliable logging.
  • Tests

    • Test workflow detects Vitest major version and builds appropriate coverage flags dynamically.
    • Coverage reporting and summary generation now use injected env vars and unified output handling.

…r flag compatibility

Vitest 3 removed --coverageReporters CLI flag. Detect the installed
Vitest major version at runtime and use --coverage.reporter (dot
notation) for v3+, keeping --coverageReporters for Jest and Vitest 2.

Closes #215
@bedatty bedatty requested a review from a team as a code owner April 14, 2026 18:24
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 20e08a2f-ed19-45da-b60c-70e4e2bc666e

📥 Commits

Reviewing files that changed from the base of the PR and between 7abd646 and 21a8667.

📒 Files selected for processing (1)
  • .github/workflows/frontend-pr-analysis.yml

Walkthrough

Detects Vitest major version at runtime to select compatible coverage CLI flags; pins several GitHub Actions to specific commit SHAs; tightens Git quoting and ref handling for PR diffs; and consolidates writes to GITHUB_OUTPUT and GITHUB_STEP_SUMMARY into grouped append blocks.

Changes

Cohort / File(s) Summary
Workflow: frontend PR analysis
​.github/workflows/frontend-pr-analysis.yml
Pinned action refs to exact commit SHAs; moved GitHub context values into step env and tightened git fetch/git diff quoting and control flow (uses if PREV_COMMIT=$(...); then); added Vitest major-version detection (vitest/package.json) and builds COVERAGE_FLAGS array using --coverage.reporter=... for Vitest ≥3 or --coverageReporters=... for older versions, passed to yarn/pnpm/npm test invocations; consolidated and quoted writes to "$GITHUB_OUTPUT" and "$GITHUB_STEP_SUMMARY"; introduced step env vars (APP_NAME, COV_*, COV_THRESHOLD) and updated coverage threshold check to use COVERAGE/THRESHOLD envs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning In addition to the Vitest version detection fix (in scope), the PR pins GitHub Actions to specific commit SHAs, refactors step control flow, and restructures GitHub output handling—changes not mentioned in issue #215 objectives. Clarify whether the action pinning and refactoring are necessary for the Vitest fix or should be split into separate PRs to maintain scope focus.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change: detecting Vitest version to select appropriate coverage reporter flags for Vitest 3+ compatibility.
Description check ✅ Passed The description covers the bug, the fix approach, the type of change (fix), breaking changes (none), and testing validation; all required sections are completed.
Linked Issues check ✅ Passed The PR directly addresses issue #215 by detecting Vitest major version at runtime and conditionally applying the correct coverage reporter CLI syntax, preventing failures in Vitest 3+ environments.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/vitest3-coverage-reporter-flag

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

@lerian-studio lerian-studio added size/XS PR changes < 50 lines workflow Changes to one or more reusable workflow files typescript Changes to TypeScript or Frontend workflows labels Apr 14, 2026
@lerian-studio
Copy link
Copy Markdown

lerian-studio commented Apr 14, 2026

🔍 Lint Analysis

Check Files Scanned Status
YAML Lint 1 file(s) ✅ success
Action Lint 1 file(s) ✅ success
Pinned Actions 1 file(s) ✅ success
Markdown Link Check no changes ⏭️ skipped
Spelling Check 1 file(s) ✅ success
Shell Check 1 file(s) ✅ success
README Check 1 file(s) ✅ success
Composite Schema no changes ⏭️ skipped

🔍 View full scan logs

@lerian-studio
Copy link
Copy Markdown

lerian-studio commented Apr 14, 2026

🛡️ CodeQL Analysis Results

Languages analyzed: actions

✅ No security issues found.


🔍 View full scan logs | 🛡️ Security tab

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Warning

CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.

Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.

👉 Steps to fix this

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/frontend-pr-analysis.yml:
- Around line 369-380: The workflow currently sets Vitest-specific
COVERAGE_FLAGS based only on VITEST_MAJOR and then invokes the package manager
test command (see VITEST_MAJOR, COVERAGE_FLAGS and the case that runs
yarn|pnpm|npm test), which breaks when the repository's "test" script uses Jest
or another runner; change the logic to first detect the actual test runner used
by the repository (e.g., inspect the test script or installed devDependencies to
distinguish Vitest vs Jest) and only assign Vitest reporter flags to
COVERAGE_FLAGS when Vitest is actually used; for Jest or unknown runners do not
inject Vitest reporter flags (use plain --coverage or no extra flags), and
remove the invalid fallback flag name (--coverageReporters) so that the case
block that runs yarn test / pnpm test / npm test passes only flags appropriate
to the detected runner.
🪄 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: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b2e34d77-fc83-40f8-bc59-773132bc5cf6

📥 Commits

Reviewing files that changed from the base of the PR and between 8439c02 and 33bcc8c.

📒 Files selected for processing (1)
  • .github/workflows/frontend-pr-analysis.yml

Comment thread .github/workflows/frontend-pr-analysis.yml Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
.github/workflows/frontend-pr-analysis.yml (1)

369-380: ⚠️ Potential issue | 🟠 Major

Gate coverage reporter args by actual runner, not by resolved Vitest package.

Line 369 detects only whether vitest is resolvable, but Lines 371-380 always inject Vitest-style/Jest-style reporter flags into a generic test script. In monorepos with hoisted Vitest and a Jest test script, this can pass --coverage.reporter=* to Jest and fail CI. That is a breaking behavior for external callers.

Suggested fix
+          TEST_SCRIPT=$(node -e "try{const p=require('./package.json');process.stdout.write((p.scripts&&p.scripts.test)||'')}catch{process.stdout.write('')}" 2>/dev/null)
           VITEST_MAJOR=$(node -e "try{console.log(require('vitest/package.json').version.split('.')[0])}catch{console.log('0')}" 2>/dev/null)

-          if [[ "$VITEST_MAJOR" -ge 3 ]]; then
-            COVERAGE_FLAGS=(--coverage.reporter=text --coverage.reporter=json-summary --coverage.reporter=lcov)
-          else
-            COVERAGE_FLAGS=(--coverageReporters=text --coverageReporters=json-summary --coverageReporters=lcov)
-          fi
+          COVERAGE_FLAGS=()
+          if [[ "$TEST_SCRIPT" == *vitest* ]]; then
+            if [[ "$VITEST_MAJOR" -ge 3 ]]; then
+              COVERAGE_FLAGS=(--coverage.reporter=text --coverage.reporter=json-summary --coverage.reporter=lcov)
+            else
+              COVERAGE_FLAGS=(--coverageReporters=text --coverageReporters=json-summary --coverageReporters=lcov)
+            fi
+          elif [[ "$TEST_SCRIPT" == *jest* ]]; then
+            COVERAGE_FLAGS=(--coverageReporters=text --coverageReporters=json-summary --coverageReporters=lcov)
+          fi
Using official docs, confirm runner-specific support for coverage reporter CLI flags:
1) Vitest v2/v3: `--coverage.reporter` vs `--coverageReporters`
2) Jest (current): `--coverage.reporter` vs `--coverageReporters`
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/frontend-pr-analysis.yml around lines 369 - 380, The
current logic sets COVERAGE_FLAGS based solely on whether Vitest is resolvable
(VITEST_MAJOR) causing Vitest-style flags to be passed to whatever the repo's
"test" script runs; instead determine the actual test runner by inspecting the
package's test script (package.json "scripts.test") or by checking for an
explicit "jest" or "vitest" invocation in that script, then set COVERAGE_FLAGS
accordingly (use Vitest flags (--coverage.reporter / --coverageReporters) only
if the script invokes "vitest" and use Jest flags (the appropriate Jest coverage
CLI form) only if the script invokes "jest"); modify the logic around
VITEST_MAJOR and COVERAGE_FLAGS and branch before the case for
inputs.package_manager so the package_manager switch simply runs the test
command with the already-chosen, runner-appropriate COVERAGE_FLAGS.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In @.github/workflows/frontend-pr-analysis.yml:
- Around line 369-380: The current logic sets COVERAGE_FLAGS based solely on
whether Vitest is resolvable (VITEST_MAJOR) causing Vitest-style flags to be
passed to whatever the repo's "test" script runs; instead determine the actual
test runner by inspecting the package's test script (package.json
"scripts.test") or by checking for an explicit "jest" or "vitest" invocation in
that script, then set COVERAGE_FLAGS accordingly (use Vitest flags
(--coverage.reporter / --coverageReporters) only if the script invokes "vitest"
and use Jest flags (the appropriate Jest coverage CLI form) only if the script
invokes "jest"); modify the logic around VITEST_MAJOR and COVERAGE_FLAGS and
branch before the case for inputs.package_manager so the package_manager switch
simply runs the test command with the already-chosen, runner-appropriate
COVERAGE_FLAGS.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Run ID: bb2ac9c5-3149-4442-9bf1-7ddad587d7a1

📥 Commits

Reviewing files that changed from the base of the PR and between 33bcc8c and 89fe756.

📒 Files selected for processing (1)
  • .github/workflows/frontend-pr-analysis.yml

- Pin all external actions by SHA (checkout, setup-node, upload-artifact,
  download-artifact, github-script)
- Quote $GITHUB_OUTPUT to satisfy SC2086
- Replace $? check with direct exit code test to satisfy SC2181
- Quote $BASE_SHA, $HEAD_SHA, $PREV_COMMIT variables
@lerian-studio lerian-studio added size/S PR changes 50–199 lines and removed size/XS PR changes < 50 lines labels Apr 14, 2026
Comment thread .github/workflows/frontend-pr-analysis.yml Fixed
- Group GITHUB_OUTPUT writes with { } >> to satisfy SC2129
- Quote $GITHUB_STEP_SUMMARY to satisfy SC2086
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Warning

CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.

Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.

👉 Steps to fix this

Actionable comments posted: 2

♻️ Duplicate comments (1)
.github/workflows/frontend-pr-analysis.yml (1)

366-379: ⚠️ Potential issue | 🟠 Major

Make coverage flags runner-aware; current Vitest detection can apply wrong CLI flags.

Line 368 keys behavior off installed Vitest, not the actual test runner command. In mixed setups, this can pass Vitest-only flags to Jest/other runners (or vice versa). Keep Vitest flags only when the test script is Vitest; otherwise avoid injecting reporter flags unless runner support is explicit.

Suggested fix
-          # Vitest 3+ removed --coverageReporters CLI flag (use --coverage.reporter instead)
-          # Jest and Vitest 2 still support --coverageReporters
-          VITEST_MAJOR=$(node -e "try{console.log(require('vitest/package.json').version.split('.')[0])}catch{console.log('0')}" 2>/dev/null)
-
-          if [[ "$VITEST_MAJOR" -ge 3 ]]; then
-            COVERAGE_FLAGS=(--coverage.reporter=text --coverage.reporter=json-summary --coverage.reporter=lcov)
-          else
-            COVERAGE_FLAGS=(--coverageReporters=text --coverageReporters=json-summary --coverageReporters=lcov)
-          fi
+          TEST_SCRIPT=$(node -e "try{const s=require('./package.json').scripts?.test||'';process.stdout.write(s)}catch{process.stdout.write('')}" 2>/dev/null)
+          VITEST_MAJOR=$(node -e "try{console.log(require('vitest/package.json').version.split('.')[0])}catch{console.log('0')}" 2>/dev/null)
+          COVERAGE_FLAGS=()
+
+          if [[ "$TEST_SCRIPT" == *vitest* ]] && [[ "$VITEST_MAJOR" -ge 1 ]]; then
+            COVERAGE_FLAGS=(--coverage.reporter=text --coverage.reporter=json-summary --coverage.reporter=lcov)
+          elif [[ "$TEST_SCRIPT" == *jest* ]]; then
+            COVERAGE_FLAGS=(--coverageReporters=text --coverageReporters=json-summary --coverageReporters=lcov)
+          fi
For current official docs: (1) In Vitest v2 and v3, which CLI flag is supported for coverage reporters: `--coverage.reporter` or `--coverageReporters`? (2) In Jest 30, is `coverageReporters` supported via CLI args (camelCase config passthrough), and what syntax is documented?
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/frontend-pr-analysis.yml around lines 366 - 379, The
script currently sets COVERAGE_FLAGS based on the presence/version of installed
Vitest (VITEST_MAJOR) which can misapply Vitest-only CLI flags to other test
runners; update the logic to detect the actual test runner invoked by inspecting
the test script command in package.json (e.g., read the "scripts.test" value)
and only select Vitest-style reporters (--coverage.reporter) when that script
contains "vitest", otherwise select runner-appropriate flags (or leave REPORTERS
empty) for Jest/others; adjust the variables (e.g., VITEST_MAJOR,
COVERAGE_FLAGS) and the case block that runs yarn/pnpm/npm test so it forwards
the correct flags only when the detected test runner matches (and preserve
correct argument quoting/precedence for npm -- vs yarn/pnpm).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/frontend-pr-analysis.yml:
- Line 116: The fallback git diff invocation that interpolates `${{
github.base_ref }}` directly is vulnerable to ref injection and parsing errors;
map the base ref through an env variable (e.g., BASE_REF) in the workflow `env:`
section, validate/sanitize it (allow only safe characters like [A-Za-z0-9._/-]
or reject otherwise) and then use the quoted variable in the FILES assignment
(replace occurrences of `origin/${{ github.base_ref }}` with
`origin/"$BASE_REF"`), ensuring the variable is always quoted when passed to
`git diff --name-only` so `$BASE_REF` cannot break the shell or git arguments.
- Around line 422-431: The repeated echo appends to "$GITHUB_OUTPUT" (using
COVERAGE, STATEMENTS, BRANCHES, FUNCTIONS) trigger shellcheck SC2129; replace
the multiple lines that each do echo "... >> \"$GITHUB_OUTPUT\"" with a single
grouped redirection or here-doc so all four outputs are written in one >>
operation (e.g., group the four echo/printf lines inside { ...; } >>
"$GITHUB_OUTPUT" or use a single cat <<EOF >> "$GITHUB_OUTPUT" block) and apply
the same change to the else branch that writes zeros.

---

Duplicate comments:
In @.github/workflows/frontend-pr-analysis.yml:
- Around line 366-379: The script currently sets COVERAGE_FLAGS based on the
presence/version of installed Vitest (VITEST_MAJOR) which can misapply
Vitest-only CLI flags to other test runners; update the logic to detect the
actual test runner invoked by inspecting the test script command in package.json
(e.g., read the "scripts.test" value) and only select Vitest-style reporters
(--coverage.reporter) when that script contains "vitest", otherwise select
runner-appropriate flags (or leave REPORTERS empty) for Jest/others; adjust the
variables (e.g., VITEST_MAJOR, COVERAGE_FLAGS) and the case block that runs
yarn/pnpm/npm test so it forwards the correct flags only when the detected test
runner matches (and preserve correct argument quoting/precedence for npm -- vs
yarn/pnpm).
🪄 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: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 91895350-73c8-4e32-9185-1de6b0147244

📥 Commits

Reviewing files that changed from the base of the PR and between 89fe756 and f7cfa90.

📒 Files selected for processing (1)
  • .github/workflows/frontend-pr-analysis.yml

Comment thread .github/workflows/frontend-pr-analysis.yml Outdated
Comment thread .github/workflows/frontend-pr-analysis.yml Outdated
Comment thread .github/workflows/frontend-pr-analysis.yml Fixed
Comment thread .github/workflows/frontend-pr-analysis.yml Fixed
Comment thread .github/workflows/frontend-pr-analysis.yml Fixed
Comment thread .github/workflows/frontend-pr-analysis.yml Fixed
Comment thread .github/workflows/frontend-pr-analysis.yml Fixed
Comment thread .github/workflows/frontend-pr-analysis.yml Fixed
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (2)
.github/workflows/frontend-pr-analysis.yml (2)

116-116: ⚠️ Potential issue | 🟠 Major

Harden fallback diff ref handling at Line 116.

origin/${{ github.base_ref }}...HEAD is still interpolated directly in shell. Map it through env, validate it as a branch name, and quote it before use.

Suggested fix
       - name: Get changed files
         id: changed
         shell: bash
+        env:
+          BASE_REF: ${{ github.base_ref }}
         run: |
           if [[ "${{ github.event_name }}" == "pull_request" ]]; then
             BASE_SHA="${{ github.event.pull_request.base.sha }}"
             HEAD_SHA="${{ github.event.pull_request.head.sha }}"
             git fetch origin "$BASE_SHA" --depth=1 2>/dev/null || true
-            FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" 2>/dev/null || git diff --name-only origin/${{ github.base_ref }}...HEAD)
+            if ! git check-ref-format --branch "$BASE_REF" >/dev/null 2>&1; then
+              echo "::error::Invalid base ref: $BASE_REF"
+              exit 1
+            fi
+            FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA" 2>/dev/null || git diff --name-only "origin/${BASE_REF}...HEAD")

As per coding guidelines, "Validate branch names and label names before using in shell commands; always quote variables and map through env:."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/frontend-pr-analysis.yml at line 116, The FILES assignment
uses an unquoted interpolated ref origin/${{ github.base_ref }}...HEAD directly
in the shell; change it to read the base ref through an environment variable
(e.g., export BASE_REF="${{ github.base_ref }}" via env:), validate/sanitize
BASE_REF against a safe branch-name regex (allow only [A-Za-z0-9._/-] and
reject/exit if invalid or empty), assign a fallback variable like
FALLBACK_REF="origin/$BASE_REF...HEAD" and then use the quoted variable in the
git diff command (git diff --name-only "$BASE_SHA" "$HEAD_SHA" 2>/dev/null ||
git diff --name-only "$FALLBACK_REF"...HEAD) so the ref is validated and always
quoted when used; update references to BASE_SHA, HEAD_SHA, BASE_REF, and FILES
accordingly.

366-379: ⚠️ Potential issue | 🟠 Major

Do not infer runner solely from installed Vitest version (Lines 366-379).

Current logic can select Vitest v3 flags even when the test script actually runs Jest/another runner in mixed-tool repos. Detect the test runner first (from package.json script), then apply Vitest-specific flags only when Vitest is the executed runner.

Suggested fix
-          VITEST_MAJOR=$(node -e "try{console.log(require('vitest/package.json').version.split('.')[0])}catch{console.log('0')}" 2>/dev/null)
+          TEST_SCRIPT=$(node -e "try{const p=require('./package.json');process.stdout.write((p.scripts&&p.scripts.test)||'')}catch{process.stdout.write('')}" 2>/dev/null)
+          VITEST_MAJOR=$(node -e "try{console.log(require('vitest/package.json').version.split('.')[0])}catch{console.log('0')}" 2>/dev/null)

-          if [[ "$VITEST_MAJOR" -ge 3 ]]; then
+          if [[ "$TEST_SCRIPT" == *vitest* ]] && [[ "$VITEST_MAJOR" -ge 3 ]]; then
             COVERAGE_FLAGS=(--coverage.reporter=text --coverage.reporter=json-summary --coverage.reporter=lcov)
           else
             COVERAGE_FLAGS=(--coverageReporters=text --coverageReporters=json-summary --coverageReporters=lcov)
           fi
As of the latest docs, which CLI flags are valid for setting coverage reporters in:
1) Vitest v2
2) Vitest v3+
3) Jest
Please include official docs links for each.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/frontend-pr-analysis.yml around lines 366 - 379, The
workflow currently infers Vitest flags from VITEST_MAJOR alone; instead, read
the repository's test script and detect the actual test runner before setting
COVERAGE_FLAGS: inspect package.json's "scripts"."test" (or the
npm_package_scripts_test env) for tokens like "vitest" (and fallback to jest)
and only assign Vitest-specific flags when the test script actually invokes
vitest; otherwise keep Jest/pnpm/yarn-compatible flags. Update the logic around
VITEST_MAJOR and COVERAGE_FLAGS to first set a RUNNER variable (e.g., detect
"vitest" vs "jest") using the package.json test script, then conditionally
populate COVERAGE_FLAGS based on RUNNER and VITEST_MAJOR, and leave the case for
inputs.package_manager and the test invocation unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In @.github/workflows/frontend-pr-analysis.yml:
- Line 116: The FILES assignment uses an unquoted interpolated ref origin/${{
github.base_ref }}...HEAD directly in the shell; change it to read the base ref
through an environment variable (e.g., export BASE_REF="${{ github.base_ref }}"
via env:), validate/sanitize BASE_REF against a safe branch-name regex (allow
only [A-Za-z0-9._/-] and reject/exit if invalid or empty), assign a fallback
variable like FALLBACK_REF="origin/$BASE_REF...HEAD" and then use the quoted
variable in the git diff command (git diff --name-only "$BASE_SHA" "$HEAD_SHA"
2>/dev/null || git diff --name-only "$FALLBACK_REF"...HEAD) so the ref is
validated and always quoted when used; update references to BASE_SHA, HEAD_SHA,
BASE_REF, and FILES accordingly.
- Around line 366-379: The workflow currently infers Vitest flags from
VITEST_MAJOR alone; instead, read the repository's test script and detect the
actual test runner before setting COVERAGE_FLAGS: inspect package.json's
"scripts"."test" (or the npm_package_scripts_test env) for tokens like "vitest"
(and fallback to jest) and only assign Vitest-specific flags when the test
script actually invokes vitest; otherwise keep Jest/pnpm/yarn-compatible flags.
Update the logic around VITEST_MAJOR and COVERAGE_FLAGS to first set a RUNNER
variable (e.g., detect "vitest" vs "jest") using the package.json test script,
then conditionally populate COVERAGE_FLAGS based on RUNNER and VITEST_MAJOR, and
leave the case for inputs.package_manager and the test invocation unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6b4d4aaf-a598-432a-aab2-2183ac6ad114

📥 Commits

Reviewing files that changed from the base of the PR and between f7cfa90 and 7abd646.

📒 Files selected for processing (1)
  • .github/workflows/frontend-pr-analysis.yml

…ions to env vars

Move ${{ }} expressions out of run: blocks into env: mappings to prevent
potential code injection via user-controlled inputs (github.base_ref,
matrix.app.name, coverage outputs, inputs.coverage_threshold).

Resolves all 7 CodeQL code-injection/medium findings.
@bedatty bedatty merged commit f5cc607 into develop Apr 14, 2026
17 checks passed
@github-actions github-actions bot deleted the fix/vitest3-coverage-reporter-flag branch April 14, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S PR changes 50–199 lines typescript Changes to TypeScript or Frontend workflows workflow Changes to one or more reusable workflow files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants