Confusion about codecov data at different time

Description

When I got the coverage data of commit 96a326b67f30688ee3362e5c755d85d5f6e80ad0 in repo goc at 2020-12-22T07:25:38, I got the details as follows:

( The request is: curl https://codecov.io/api/gh/qiniu/goc/commit/96a326b67f30688ee3362e5c755d85d5f6e80ad0 )

{
“owner”: {
“username”: “qiniu”,
“remaining_credits”: 5,
“name”: “qiniu”,
“service”: “github”,
“students”: {
“count”: 0,
“activated_count”: 0
},
“updatestamp”: “2020-12-28T02:18:08.881041”,
“avatar_url”: null,
“service_id”: “1563636”
},
“repo”: {
“using_integration”: true,
“name”: “goc”,
“language”: “go”,
“deleted”: false,
“bot_username”: null,
“activated”: false,
“private”: false,
“updatestamp”: “2020-12-28T02:18:22.723246+00:00”,
“branch”: “master”,
“active”: true,
“service_id”: “261943284”,
“image_token”: “7AHPDDLXQ3”
},
“meta”: {
“status”: 200
},
“commit”: {
“commitid”: “96a326b67f30688ee3362e5c755d85d5f6e80ad0”,
“parent”: “51601902e2bdb29bee83006a73b48d8aa7334a8d”,
“author”: {
“username”: “CarlJi”,
“service_id”: “10810759”,
“name”: “Changjun Ji”,
“service”: “github”,
“email”: “jinsdu@outlook.com
},
“deleted”: null,
“timestamp”: “2020-12-22T07:22:35”,
“parent_totals”: {
“C”: 0,
“b”: 0,
“d”: 0,
“f”: 34,
“h”: 1174,
“M”: 0,
“c”: “68.05797”,
“N”: 0,
“p”: 106,
“m”: 445,
“diff”: [
5,
37,
35,
1,
1,
“94.59459”,
0,
0,
0,
0,
0,
0,
0
],
“s”: 6,
“n”: 1725
},
“ci_passed”: true,
“totals”: {
“C”: 0,
“b”: 0,
“d”: 0,
“f”: 34,
“h”: 1172,
“M”: 0,
“c”: “67.94203”,
“N”: 0,
“p”: 106,
“m”: 447,
“diff”: [
5,
37,
33,
3,
1,
“89.18919”,
0,
0,
0,
0,
0,
0,
0
],
“s”: 3,
“n”: 1725
},
“pullid”: null,
“notified”: true,
“state”: “complete”,
“updatestamp”: “2020-12-22T07:23:55.196278”,
“branch”: “master”,
“report”: “”,
“message”: “Merge pull request #148 from qiniu/revert-143-buildCopy\n\nRevert "optimize the file copy strategy of goc build"”,
“merged”: true
}
}

While when I created the same request at 2020-12-28T10:30:00, the response was different with what I got earlier. Details were as follows:
(Simply show some fields by adding “// different” after line)

{
“owner”: {
“username”: “qiniu”,
“remaining_credits”: 5,
“name”: “qiniu”,
“service”: “github”,
“students”: {
“count”: 0,
“activated_count”: 0
},
“updatestamp”: “2020-12-28T02:18:08.881041”,
“avatar_url”: null,
“service_id”: “1563636”
},
“repo”: {
“using_integration”: true,
“name”: “goc”,
“language”: “go”,
“deleted”: false,
“bot_username”: null,
“activated”: false,
“private”: false,
“updatestamp”: “2020-12-28T02:18:22.723246+00:00”,
“branch”: “master”,
“active”: true,
“service_id”: “261943284”,
“image_token”: “7AHPDDLXQ3”
},
“meta”: {
“status”: 200
},
“commit”: {
“commitid”: “96a326b67f30688ee3362e5c755d85d5f6e80ad0”,
“parent”: “51601902e2bdb29bee83006a73b48d8aa7334a8d”,
“author”: {
“username”: “CarlJi”,
“service_id”: “10810759”,
“name”: “Changjun Ji”,
“service”: “github”,
“email”: “jinsdu@outlook.com
},
“deleted”: null,
“timestamp”: “2020-12-22T07:22:35”,
“parent_totals”: {
“C”: 0,
“b”: 0,
“d”: 0,
“f”: 37,
“h”: 1535, // different
“M”: 0,
“c”: “75.28200”, // different
“N”: 0,
“p”: 144,
“m”: 360,
“diff”: [
5,
37,
35,
1,
1,
“94.59459”,
0,
0,
0,
0,
0,
0,
0
],
“s”: 16,
“n”: 2039 // different
},
“ci_passed”: true,
“totals”: {
“C”: 0,
“b”: 0,
“d”: 0,
“f”: 37,
“h”: 1535, // different
“M”: 0,
“c”: “75.28200”, // different
“N”: 0,
“p”: 144,
“m”: 360,
“diff”: [
5,
37,
35, // different
1, // different
1,
“94.59459”, // different
0,
0,
0,
0,
0,
0,
0
],
“s”: 19,
“n”: 2039 // different
},
“pullid”: null,
“notified”: true,
“state”: “complete”,
“updatestamp”: “2020-12-22T07:23:55.196278”,
“branch”: “master”,
“report”: “”,
“message”: “Merge pull request #148 from qiniu/revert-143-buildCopy\n\nRevert "optimize the file copy strategy of goc build"”,
“merged”: true
}
}

Commit SHAs

96a326b67f30688ee3362e5c755d85d5f6e80ad0

Repository

It seems like some race condition happened at the earlier request? So what I got is not the final data ?
I want to figure out why the responses of the same request at different time are different ?
If I want to get the exact final coverage data of some commit as soon as possible, what’s your suggest ?

@fansi404, you have a number of builds for that commit. I’m guessing that it is likely some of those builds had not finished processing, and the reason for the differences in values. Does that make sense to you?

@tom, Thanks for answering the confusion.

Here is the background of my appeal:

I want to capture the coverage data of repo goc once it changes. I need to draw picture like below(The difference is that picture shown on Codecov displays commits’ coverage data detail, while I need the repo’s)

I captured the data like this: Every 5 minutes, I initiated the following request, focus on the ‘commit’ field(NOTE: not ‘commits’ field) to get the commit whose coverage data can represent the whole repo’s. If the ‘state’ field equals complete the ‘commitid’ is newly accured, I record this as repo’s coverage info for certain time.

curl https://codecov.io/api/gh/qiniu/goc/branch/master

If the builds are not finished, I will get some unstable data which will changed after all builds finished.
This caused me a huge headache.
Is there any signal I can get from codecov APIs to confirm that all builds are finished so I can make the request below later to make sure what I get is the correct data ?

curl https://codecov.io/api/gh/qiniu/goc/branch/master

Looking forward to your reply.

@tom, I really need your professional suggestion. Thanks so much.

Hi @fansi404 and apologies for the delay. I don’t know if there is an easy way to do this strictly with Codecov’s API, but I would recommend trying GitHub’s API.

You could do the following:

  1. Prevent Codecov from reporting a status check in the yaml until all CIs have finished. You can also try after_n_builds
  2. Call the GitHub API for the status check to see what state it is in
  3. When it has returned success, the Codecov API should be stable.