Multiple Slack notifications with CircleCI

Description

We have a single pipeline on CircleCI with steps “checkout → test → upload to codecov → build → deploy”.

Our codecov config file is:

Repository

private

CI/CD

CircleCI

Uploader

Commit SHAs

All commits in master branch

Codecov YAML

coverage:
  range: 60..85
  round: down
  precision: 2
  notify:
    slack:
      default:
        url: 'XXXX'
        only_pulls: false
        threshold: 0%
  status:
    project:
      default:
        target: 85%
        threshold: 0.5%
    patch:
      default:
        target: 85%
        threshold: 0.5%
codecov:
  notify:
    require_ci_to_pass: no
  ci:
    - '!circleci'

Codecov Output

#!/bin/bash -eo pipefail 
yarn global add codecov 
codecov 
 
yarn global v1.22.4
 
[1/4] Resolving packages...
 
[2/4] Fetching packages...
 
[3/4] Linking dependencies...
 
[4/4] Building fresh packages...
 
success Installed "codecov@3.7.0" with binaries:
 
      - codecov
 
Done in 1.07s.
 
  _____          _  
 
 / ____|        | |  
 
| |     ___   __| | ___  ___ _____   __  
 
| |    / _ \ / _` |/ _ \/ __/ _ \ \ / /  
 
| |___| (_) | (_| |  __/ (_| (_) \ V /  
 
 \_____\___/ \__,_|\___|\___\___/ \_/  
 
                                v3.7.0
 
==> Detecting CI Provider
 
    Circle CI Detected
 
==> Configuration: 
 
    Endpoint: https://codecov.io
 
{
 
  commit: 'XXXX',
 
  branch: 'XXXX',
 
  package: 'node-v3.7.0'
 
}
 
==> Building file structure
 
==> Generating gcov reports (skip via --disable=gcov)
 
    Failed to run gcov command.
 
==> Scanning for reports
 
    + /root/code/coverage/lcov.info
 
==> Uploading reports
 
    Success!
 
    View report at: XXXX
 
CircleCI received exit code 0 

Steps to Reproduce

  1. [First Step]
  2. [Second Step]
  3. [and so on…]

Expected behavior: [What you expect to happen]
To only have one Slack notification. Instead we always get a random number thats over 5 notifications.

Actual behavior: [What actually happens]
Multiple Slack notifications.

Flakiness? [Does this happen all the time or only sometimes?]
All the times but random number of notifications.

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

Hi @kbariotis, could you provide a SHA here so we can debug for you?

Yes thank you @tom

here are a few from the same repo, that all resulted in multiple duplicated Slack notifications:

  • 85dc8fe62826550e1f2a779d72ad733043ad40d4
  • 94e550c005ab135b143ffa5d08c4448014bcddda
  • 49401d8af3a2e47f944598e78674760d21fdaa56

Hi @kbariotis, I think this should solve your issue by adding after_n_builds

@tom First, we tried it and didn’t help. I’m pretty sure one of the SHAs I sent you above had the option but if not, I can look up on the our history and find you one.

Second, we don’t do multiple builds. Why would the after_n_builds help in this case? And even if it does, what value should we set it to when we only do one build?

Thanks

Hi @kbariotis, I didn’t notice you only had one build. I’ve escalated this to the product team to scope out the issue and work on a fix. Thanks for your patience here.

Hi @kbariotis, apologies for the delay, but would you be able to provide a few more recent SHAs? Our logs do not go that far back now.

@tom 23a449969ca76d737f28a0c4fbbef65b2da26ce9

Hi @kbariotis, unrelated, but I noticed there was an error in your yaml file. Unfortunately, we do not support ! in the codecov -> ci section.

Thank you @tom we’ve fixed that after figuring out that your docs are a bit outdated

1 Like

Oof, sorry about that @kbariotis . I’ve updated the docs.

Hi @kbariotis, apologies for the delay here. From what I understand, every time we get a webhook from GitHub saying that the PR has been changed or updated, we send out an updated notification. For PR comments and status checks, this usually doesn’t result in duplicates, because we can just edit over the originals. For Slack notifications, there is not easy way for us to do this. I have added a ticket to the product team to take a look at seeing if this is possible.

For your case, in particular. are you seeing the Slack notifications align with interactions on the PR?

@tom we are using the NPM package of codecov to manually upload the test results. You shouldn’t bother with GitHub. Could that be the cause of this issue?

@kbariotis, sorry for the late reply here. We bother with GitHub because our notification system depends on their webhooks to let us know if a CI has passed/failed and other status check information. It also lets us know when there have been changes to a PR like a force-push.

We are still investigating with the product team for a possible solution.

Got it, thank you @tom.

Hopefully this will be fixed for others as well. :slight_smile:

1 Like

Hi @kbariotis, just an update that we are still taking a look at this. Thanks for your patience here.

Hi @kbariotis, we made a fix in our system which should help from getting the same notification from Codecov. Let me know if this still isn’t working for you.