Don't comment on PRs with a certain base

Summary

Disable comments from Codecov for Pull request from a certain base.

Description

In addition to being able to configure whether Codecov comments based on the Pull Request’s head (as per Pull Request Comments) it would be nice if it is also possible to configure this based on the Pull Request’s base .

Examples

This would be useful in repositories that also use a service like Renovate or Greenkeeper, which create Pull Requests that I (and I imagine others) don’t necessarily want a coverage report for.

E.g. the Renovate Bot always opens Pull Request for a branch named renovate/*, so it would be nice if it is possible to disable comments on Pull Requests where the base branch matches renovate/*.

Hi @ericcornelissen

Would something like this work?

comment:
    - !"renovate/*"

Not sure if that’s even valid config, it’s mentally on the fly. I’ve shared your request with our product team.

Hi @drazisel,

As I understand the documentation (Pull Request Comments), that would make it so Codecov doesn’t comment on Pull Requests that want to merge something into a branch matching renovate/* (assuming you mean "!renovate/*", because !"renovate/*" is invalid YAML). I’m looking for the opposite.

However, for that matter, the example in the documentation isn’t considered valid when I run it through curl --data-binary @- https://codecov.io/validate. If I instead try branches: "!develop" it returns "branches: ["^!develop$"] which seems incorrect to me. Then again, I don’t know how you actually parse that string…

Why it seems incorrect to me is that this configuration doesn’t prevent Codecov from commenting on my Pull Requests going into the master branch.

Then again, perhaps I’m misunderstanding the documentation, and the configuration I linked above is preventing Codecov from commenting on Pull Requests that try to merge the master branch into another branch. If so, I’d be glad if you could tell me.

The validator is in the process of being updated, so that may explain it’s flakyness. If you can provide a commit SHA I can check the logs to see how the parser saw it.

Not sure which commit SHA you’re interested since the comments are on Pull Requests, this is one of the Pull Request I had not expected a comment on and this is another such Pull Request.

If you’re interested in the SHAs of the commits at which point these Pull Requests where opened those are: b46d84d491e8f16ffec39250eb6449f1018409cc and 9cb720e8e44ae2dca54c2bba2ff783ce74117af5 respectively.

The latest commits that are included in those Pull Requests (and therefore have triggered Codecov), are: ab146cb087555e5e9d785571f28746ab5945a06f and 574885316402ddf96c01633cf16ca0d602d213fc.

Hope that is enough information for you check the logs? Thanks a lot @drazisil!

It looks like for ab146cb087555e5e9d785571f28746ab5945a06f, we didn’t locate the codecov.yml file, where do you have it located and named?

574885316402ddf96c01633cf16ca0d602d213fc isn’t in the logs (may be too old)

That is very interesting. I’m using the Codecov GitHub Action and configured it to use my configuration file, which is this file. Based on the Action’s logging it seems to me that it found that file as well.

Any ideas @drazisil?

Please move the file to the root of the repo. Some of our systems can find it elsewhere, but not all. The repo root is the only supported location for codecov.yml`

Interesting, by “some of our systems” do you mean that certain settings only work if the codecov.yml file is in the root of the repository?

Except for the comment.branch configuration everything seems to work fine for me. Can you confirm that my understanding of that option is correct? My understanding is:

“If comment.branch: "!develop" is specified, then Codecov won’t comment if the Pull Request proposes to merge changes into the develop branch”

And not:

“If comment.branch: "!develop" is specified, then Codecov won’t comment if the Pull Request proposes to merge changes from the develop branch *into another branch”

Based on that I will have an answer for this topic, and decide whether I will move the configuration file.

@ericcornelissen Hey sorry for delay here – after further investigation, some good news and bad news:

Good news is, the way the feature is intended to work, it will support your usecase, e.g., a greenkeeper branch can have commenting turned off.

The bad news is, the feature is currently broken and we have a ticket in to fix it. In prioritizing this, is this an extremely important part of your Codecov usage, or more of a nice to have?

Jerrod