fix: allow CI to pass for fork PRs#1593
Conversation
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.
📝 WalkthroughWalkthroughTwo 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
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 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 |
There was a problem hiding this comment.
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).
Summary
SONAR_TOKEN, no workaround)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
Summary by CodeRabbit