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

Solution for codecov rate limits #1846

Merged
merged 2 commits into from
Feb 4, 2024

Conversation

adamjstewart
Copy link
Collaborator

@adamjstewart adamjstewart commented Feb 4, 2024

Solution for codecov/feedback#126

Alternative to #1845

Problem

The GitHub API has a strict rate limit. For PRs originating from https://github.com/microsoft/torchgeo, we use our own upload token. However, PRs originating from forks do not have access to repository secrets, and must instead use the same generic Codecov token as every other repository. The popularity of Codecov means that this generic token frequently exceeds the rate limit, resulting in the type of intermittent errors reported in codecov/codecov-action#903. This error is usually tolerable since most of our test coverage is redundant, but the minimum tests hit a different code path. If the minimum tests encounter this issue, the total coverage of the PR will decrease, through no fault of the PR contributor. This causes much confusion, and requires an "expert" (me) to re-run the minimum tests from the beginning until the upload succeeds.

Solution

One solution is to use two different workflows:

  1. on.pull_request: upload coverage.xml as an artifact after each individual test
  2. on.workflow_run: download all coverage artifacts and upload a single time to Codecov

Although the pull_request trigger does not have access to GitHub secrets, the workflow_run trigger does.

Based on:

Rationale

This has the following benefits:

  • Reduces how hard we hit the Codecov API
  • Waits until all tests pass before reporting coverage, no initially failing coverage metrics
  • Uses our upload token, even for PRs contributed from forks, no more issues!
  • Allows us to update to codecov-action@v4, which doesn't support tokenless uploads

@github-actions github-actions bot added the testing Continuous integration testing label Feb 4, 2024
@adamjstewart adamjstewart added this to the 0.5.2 milestone Feb 4, 2024
@adamjstewart adamjstewart marked this pull request as ready for review February 4, 2024 16:48
@adamjstewart
Copy link
Collaborator Author

I don't think new workflows run until they've been merged into upstream. Going to force merge and then test in a follow-up PR.

@adamjstewart adamjstewart merged commit 8d60e85 into microsoft:main Feb 4, 2024
19 checks passed
@adamjstewart adamjstewart deleted the ci/codecov-2 branch February 4, 2024 17:56
@adamjstewart adamjstewart removed this from the 0.5.2 milestone Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Continuous integration testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant