# How to make codecov branch status checks conditional

**URL:** <https://community.codecov.com/t/how-to-make-codecov-branch-status-checks-conditional/3549>\
**Category:** Support\
**Created:** [March 21, 2022, 2:49pm UTC](https://community.codecov.com/t/how-to-make-codecov-branch-status-checks-conditional/3549 "2022-03-21T14:49:41Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![calvinalkan](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/calvinalkan/32/2370_2.png) [@calvinalkan](https://community.codecov.com/u/calvinalkan)\
**Post date:** [March 21, 2022, 2:49pm UTC](https://community.codecov.com/t/how-to-make-codecov-branch-status-checks-conditional/3549/1 "2022-03-21T14:49:41Z")

</div>

### Description

I have the codecov/project and codecov/patch status  
set as required for protected branches in GitHub.  
I have tried every combination of the codecov.yml  
settings to achieve the following:

- If for a given commit coverage is uploaded  
all codecov checks must pass. If no coverage  
is uploaded the status checks should be set  
to “success” automatically. (IE. updating docs, README, etc).

In the codecov.yml reference  
it says about the “if\_not\_found” setting:

" `success` : the status will pass if there is no report for the head. Use this on commits / PRs where you won’t be uploading coverage but still want codecov status checks to pass. "

So what I’m expecting is that codecov status checks  
are set to success if no coverage is uploaded after  
all actions are run. However, its always stays stuck  
at "Expected — Waiting for status to be reported "

I’m thinking that maybe it has something to  
do with “skipped” actions not being recognized as  
completed.

### CI/CD URL

([ci(monorepo): wait\_for\_ci = false, n\_builds =1 by calvinalkan · Pull Request #112 · snicco/snicco · GitHub](https://github.com/sniccowp/sniccowp/pull/112))

### Codecov Output

No output. Uploading coverage is skipped for  
changes outside of src/\*.php

### Expected Results

codcov/project and codecov/patch  
should be set to true in the linked PR.

### Actual Results

codcov/project and codecov/patch  
are stuck waiting for a status to be reported.

### Additional Information

This is the codecov.yml currently used for this PR.

> <https://github.com/snicco/snicco/blob/79a392f3f646dced3f844cc612bb985991e20d50/codecov.yml>

But I tried every other imaginable combination.

---

<div class="post-metadata">

**Author:** ![tom](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/tom/32/8_2.png) [@tom](https://community.codecov.com/u/tom)\
**Post date:** [April 4, 2022, 4:28pm UTC](https://community.codecov.com/t/how-to-make-codecov-branch-status-checks-conditional/3549/2 "2022-04-04T16:28:01Z")

</div>

hi @calvinalkan I’m not sure this is quite possible. I see that the `if_not_found` reference is misleading, as it is more specific to flags.

The reason that it’s still waiting on a status, is that Codecov is not made aware of the commit (since no uploads are sent up). So Codecov doesn’t send up notifications. A way around this would be to send up a blank coverage report.

---

<div class="post-metadata">

**Author:** ![extesy](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/extesy/32/2679_2.png) [@extesy](https://community.codecov.com/u/extesy)\
**Post date:** [October 13, 2022, 7:12pm UTC](https://community.codecov.com/t/how-to-make-codecov-branch-status-checks-conditional/3549/3 "2022-10-13T19:12:11Z")

</div>

Do you have an example of how to generate and upload a blank coverage report?

---

<div class="post-metadata">

**Author:** ![FallMonkey](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/fallmonkey/32/2681_2.png) [@FallMonkey](https://community.codecov.com/u/FallMonkey)\
**Post date:** [October 13, 2022, 9:42pm UTC](https://community.codecov.com/t/how-to-make-codecov-branch-status-checks-conditional/3549/4 "2022-10-13T21:42:32Z")

</div>

There’re both `if_not_found` ([Status Checks](https://docs.codecov.com/docs/commit-status#if_not_found)) and `if_no_uploads` (seen in some public gists), and both are not making status check green. If both references are just wrong, and the only way is to upload a blank report, I think there’s definitely something to fix inside codecov so we can finally update stuff not influencing code coverage.

---

<div class="post-metadata">

**Author:** ![tom](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/tom/32/8_2.png) [@tom](https://community.codecov.com/u/tom)\
**Post date:** [October 14, 2022, 10:19pm UTC](https://community.codecov.com/t/how-to-make-codecov-branch-status-checks-conditional/3549/5 "2022-10-14T22:19:33Z")

</div>

@FallMonkey definitely, this is something we’re looking into doing. Unfortunately, right now it’s not possible.

@extesy If you were to create a `fake` coverage report, I would create a file `coverage-automatic.json` to be uploaded that might look like

```auto
{"files":[{"name":"{{ filename }}","coverage":[1]}],"uploader":"empty"}

```

This implies that some file (that exists in the `git` repo) named `{{ filename }}` has coverage on the first line. You may need to change it as appropriate.

---

<div class="post-metadata">

**Author:** ![FallMonkey](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/fallmonkey/32/2681_2.png) [@FallMonkey](https://community.codecov.com/u/FallMonkey)\
**Post date:** [October 15, 2022, 6:42am UTC](https://community.codecov.com/t/how-to-make-codecov-branch-status-checks-conditional/3549/6 "2022-10-15T06:42:05Z")

</div>

Thx for the followup!

Seems there’s one more thing until we get this working. After uploading the fake report json to codecov, my codecov will be stuck like below. Pushing another commit will get this to pass, but that new one will be stuck again. Forcing pushing notification will also work but it doesnt seem right.

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/codecov/original/2X/d/d775be7c6c5eacdeccd8e185bf302912777c8d92.png)  
 ![image](https://canada1.discourse-cdn.com/flex029/uploads/codecov/original/2X/8/8cfedd630acd028c040ba5477825164cc7b4fb34.png)

In this case, what CI completion exactly is codecov waiting for? The fake report upload workflow is the only CI running here and it’s already complete. Note: in normal PRs where real report will be uploaded, this works totally fine so our GHE integration with codecov app is functioning.

---

<div class="post-metadata">

**Author:** ![tom](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/tom/32/8_2.png) [@tom](https://community.codecov.com/u/tom)\
**Post date:** [October 17, 2022, 3:20pm UTC](https://community.codecov.com/t/how-to-make-codecov-branch-status-checks-conditional/3549/7 "2022-10-17T15:20:27Z")

</div>

@FallMonkey strange, can you share the commit SHA for one of these instances?

---

<div class="post-metadata">

**Author:** ![FallMonkey](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/fallmonkey/32/2681_2.png) [@FallMonkey](https://community.codecov.com/u/FallMonkey)\
**Post date:** [October 17, 2022, 4:27pm UTC](https://community.codecov.com/t/how-to-make-codecov-branch-status-checks-conditional/3549/8 "2022-10-17T16:27:38Z")

</div>

a0e3f308bb72f184daa4145709df4b14ab6b93ff

It’s a GHE repo and using self-hosted codecov so not sure if you could access that.

---

<div class="post-metadata">

**Author:** ![FallMonkey](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/fallmonkey/32/2681_2.png) [@FallMonkey](https://community.codecov.com/u/FallMonkey)\
**Post date:** [October 18, 2022, 7:06pm UTC](https://community.codecov.com/t/how-to-make-codecov-branch-status-checks-conditional/3549/9 "2022-10-18T19:06:07Z")

</div>

Any update here? Lemme know if I need to provide additional information.

---

<div class="post-metadata">

**Author:** ![jerrod](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/jerrod/32/41_2.png) [@jerrod](https://community.codecov.com/u/jerrod)\
**Post date:** [October 19, 2022, 5:21pm UTC](https://community.codecov.com/t/how-to-make-codecov-branch-status-checks-conditional/3549/10 "2022-10-19T17:21:58Z")

</div>

@FallMonkey given you are using us self-hosted, we will have to take a different approach to support. I spoke with your colleague and they will be tapping you in on a separate thread.

---

<div class="post-metadata">

**Author:** ![jerrod](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/jerrod/32/41_2.png) [@jerrod](https://community.codecov.com/u/jerrod)\
**Post date:** [October 19, 2022, 5:22pm UTC](https://community.codecov.com/t/how-to-make-codecov-branch-status-checks-conditional/3549/11 "2022-10-19T17:22:43Z")

</div>

For all Codecov users:

**Medium term:** I agree this is a problem and a good feature request. It had been in the backlog from a couple months back but is starting to get more attention now as a feature to better integrate with Github.

**Short term:** As far as remediation before we can build around this, I’m posting a response from our team:

A) You need to be using carryforward flags. That way, we won’t have to worry about any large swings in code coverage. You need the entire set of their coverage reports uploaded under one flag

B) We still need a coverage report for our notification system to send out the PR comment/status check. So “blank report” is actually a misnomer, because it has to contain data. What I would suggest is to find a file that will always exist where the first line will always be covered, and upload that file like this named coverage.xml

/home/runner/work/{{ owner name }}/{{ repo name }} 

alternatively you could use this format and call it something like coverage.json  
{“files”:[{“name”:“{{ filename }}”,“coverage”:[1]}],“uploader”:“R”}

---

<div class="post-metadata">

**Author:** ![drazisil](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/drazisil/32/496_2.png) [@drazisil](https://community.codecov.com/u/drazisil)\
**Post date:** [November 14, 2022, 3:25pm UTC](https://community.codecov.com/t/how-to-make-codecov-branch-status-checks-conditional/3549/12 "2022-11-14T15:25:49Z")

</div>

Here is an example report that will work for this purpose. Create and check the following three lines into the root of your repo as `lcov.info`

```auto
SF:lcov.info
DA:1,1
end_of_record

```
