Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codecov: set fail_ci_if_error to false iff the PR is made from a fork #920

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,24 @@ jobs:
- uses: codecov/codecov-action@v4
with:
file: lcov.info
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# This is a public repo.
# We are using v4 of the codecov-action.
# If the PR is from a fork, then Codecov allows us to use
# tokenless Codecov uploads (because the repo is public).
# If the PR is not from a fork, then Codecov does not allow
# us to use tokenless Codecov uploads, and thus we must use
# the `CODECOV_TOKEN` token.
# Tokenless Codecov uploads are prone to random failures,
# due to Codecov's servers hitting GitHub rate limits.
# Therefore:
# 1. If this CI run is not a PR run, we set `fail_ci_if_error` to `true`.
# 2. If this CI run is a PR run and the PR is not from a fork, we set `fail_ci_if_error` to `true`.
# 3. If this CI run is a PR run and the PR is from a fork, we set `fail_ci_if_error` to `false`.
fail_ci_if_error: ${{ (github.event_name != 'pull_request') || (github.repository == github.event.pull_request.head.repo.full_name) }}
# `${{ secrets.CODECOV_TOKEN }}` will be empty if the PR is from a fork,
# because GitHub does not make secrets available if the PR is from a fork
# and the base repo is public.
token: ${{ secrets.CODECOV_TOKEN }}
docs:
permissions:
contents: write
Expand Down
Loading