Repository navigation
Skip Codecov uploads for pushes to non-default branches - #37
Open
zigpy-review-bot wants to merge 1 commit into
Open
zigpy-review-bot wants to merge 1 commit into
zigpy-review-bot wants to merge 1 commit into
Conversation
A PR from a branch in the same repository runs CI twice for the same commit: the `push` run tests the branch as is, and the `pull_request` run tests the merge with the base branch. Both uploaded to Codecov, which merges the two reports even though they cover different versions of the code, so PRs whose base branch has moved on got bogus project coverage. Skip the upload for pushes to anything but the default branch (other branches and tags). PRs now upload from their `pull_request` run only, pushes to the default branch still upload, and runs in forked repositories are still skipped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a PR comes from a branch in the same repository, CI runs twice for the same commit:
pushrun tests the branch as is;pull_requestrun tests GitHub's merge with the base branch.Both upload to Codecov under the same commit SHA, and Codecov merges the two reports even though they cover different versions of the code. If the base branch has moved on, the result is corrupted. For example, zigpy/zigpy#1909's report lists
zigpy/appdb.pywith 1007 coverable lines: the union of the 629-line version on the PR's base and the 666-line version on currentdev. The PR doesn't touch that file, but the inflated misses failcodecov/projectwith "indirect changes".This PR skips the upload for
pushevents on anything but the repository's default branch:pull_requestrun only, the same way PRs from forks already do today.merge_group,workflow_dispatch) behave as before.Limitations
dev→masterrelease PR) still upload twice: once from thedevpush and once from the PR. That's harmless when the base branch has no commits missing fromdev, since both uploads then cover the same code.--fail-undercheck still applies.The workflow passes actionlint (the only warning is the existing one about
CODE_FOLDER), which only checks the condition's syntax; its behavior shows in real runs.Affected repositories
Repositories in the org that call this workflow with
push:on all branches get the double upload: zigpy, bellows, zigpy-znp, zigpy-deconz, zigpy-xbee, zigpy-zigate, zigpy-cli and zigpy-ziggurat. zha, zha-device-handlers and zigpy-ota already limitpush:to their main branches, so they don't. Outside the org, NabuCasa/universal-silabs-flasher, smlight-tech/pysmlight, smlight-tech/smlight-cc-flasher and lhespress/zigpy-espzb also call it with all-branch pushes, so they get the same change.Alternative or addition: per-repository triggers
Instead of this change, or in addition to it, each affected repository could limit its own
push:trigger to its main branch, as zha does. That also removes the duplicate test runs, but branches pushed without a PR would then get no CI at all. Those would be separate PRs in each repository; I can open them if that's preferred.