Skip to content

fix: allow CI to pass for fork PRs#1593

Open
MuncleUscles wants to merge 1 commit into
mainfrom
fix/ci-fork-pr-compatibility
Open

fix: allow CI to pass for fork PRs#1593
MuncleUscles wants to merge 1 commit into
mainfrom
fix/ci-fork-pr-compatibility

Conversation

@MuncleUscles
Copy link
Copy Markdown
Member

@MuncleUscles MuncleUscles commented Apr 9, 2026

Summary

  • Make Codecov token optional and upload non-blocking for fork PRs (no access to repo secrets)
  • Skip SonarCloud scan for fork PRs (requires SONAR_TOKEN, no workaround)
  • Internal PRs and pushes to main are unaffected

Context

All 5 recent external PRs from contributors show CI failures despite tests passing, because post-test steps (Codecov, SonarCloud) require repo secrets that forks don't have access to.

Test plan

  • Verify internal PR still runs Codecov + SonarCloud
  • Verify fork PR CI passes when tests pass

Summary by CodeRabbit

  • Chores
    • Made codecov token optional for workflow calls, allowing callers to skip code coverage uploads if needed
    • Updated codecov step to not fail CI when coverage upload encounters errors
    • Added security check to SonarCloud scan, restricting execution to pull requests from the same repository and push events

Fork PRs don't have access to repo secrets, causing Codecov and
SonarCloud steps to fail even when tests pass. Make Codecov upload
non-blocking and skip SonarCloud for fork PRs.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 9, 2026

📝 Walkthrough

Walkthrough

Two GitHub Actions workflows were modified to adjust CI/CD behavior: one makes the Codecov token optional and prevents CI failure on coverage upload errors, while the other adds a conditional check to the SonarCloud scan step, restricting it to same-repository pull requests and push events.

Changes

Cohort / File(s) Summary
Frontend Unit Tests Workflow
.github/workflows/frontend-unit-tests.yml
Made codecov_token secret optional (required: false) and set Codecov action fail_ci_if_error to false, allowing workflows to complete without blocking on coverage upload failures.
PR Unit Tests Workflow
.github/workflows/unit-tests-pr.yml
Added conditional guard to SonarCloud Scan step to execute only when the PR originates from the same repository or on push events, improving security by preventing external fork scans.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A rabbit hops through workflows bright,
Codecov tokens now not quite so tight,
SonarCloud guards the foreign forks away,
CI flows smoother, hip-hip-hooray! 🚀

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description includes a clear summary of changes, context explaining the problem, and a test plan, but omits several required template sections like 'What', 'Why', 'Testing done', 'Decisions made', and the Checks checklist. Fill in the template sections 'What', 'Why', and 'Testing done' with concrete details about the workflow changes and how they were validated.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: allow CI to pass for fork PRs' directly summarizes the main change—enabling CI to succeed for fork pull requests despite missing repository secrets.
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/ci-fork-pr-compatibility

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 and usage tips.

Copy link
Copy Markdown
Contributor

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

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-unit-tests.yml:
- Line 35: Replace the unconditional setting fail_ci_if_error: false with a
conditional expression that only disables Codecov failures for forked PRs; e.g.
set fail_ci_if_error to an expression like ${{ github.event.pull_request &&
github.event.pull_request.head.repo.full_name != github.repository }} so the
unique flag fail_ci_if_error is false only for fork PRs and remains blocking for
internal runs (keep the rest of the workflow 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: c0d9ac96-e9f9-43d9-b9ed-f2b919ba4ede

📥 Commits

Reviewing files that changed from the base of the PR and between cd554a6 and 364ee0b.

📒 Files selected for processing (2)
  • .github/workflows/frontend-unit-tests.yml
  • .github/workflows/unit-tests-pr.yml

verbose: true
token: ${{ secrets.codecov_token }}
fail_ci_if_error: true
fail_ci_if_error: false
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.

⚠️ Potential issue | 🟠 Major

Codecov is now non-blocking for internal runs too.

Line 35 disables CI failure on Codecov upload errors for all runs of this reusable workflow, not just fork PRs. That changes internal PR/main push behavior instead of keeping it unchanged.

Suggested scoped fix (fork PRs non-blocking, internal stays blocking)
diff --git a/.github/workflows/frontend-unit-tests.yml b/.github/workflows/frontend-unit-tests.yml
@@
 on:
   workflow_call:
+    inputs:
+      codecov_fail_ci_if_error:
+        required: false
+        type: boolean
+        default: true
     secrets:
       codecov_token:
         required: false
@@
       - name: Upload coverage reports to Codecov
         uses: codecov/codecov-action@v5.5.2
         with:
           verbose: true
           token: ${{ secrets.codecov_token }}
-          fail_ci_if_error: false
+          fail_ci_if_error: ${{ inputs.codecov_fail_ci_if_error }}
           directory: frontend/coverage
diff --git a/.github/workflows/unit-tests-pr.yml b/.github/workflows/unit-tests-pr.yml
@@
   frontend-unit-tests:
     if: (github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]')
     name: Unit Tests
     uses: ./.github/workflows/frontend-unit-tests.yml
+    with:
+      codecov_fail_ci_if_error: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) }}
     secrets:
       codecov_token: ${{ secrets.CODECOV_TOKEN }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/frontend-unit-tests.yml at line 35, Replace the
unconditional setting fail_ci_if_error: false with a conditional expression that
only disables Codecov failures for forked PRs; e.g. set fail_ci_if_error to an
expression like ${{ github.event.pull_request &&
github.event.pull_request.head.repo.full_name != github.repository }} so the
unique flag fail_ci_if_error is false only for fork PRs and remains blocking for
internal runs (keep the rest of the workflow unchanged).

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