Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add commit status GQL type and filtering of commits #593

Merged
merged 9 commits into from
Jun 6, 2024
Merged

Conversation

JerrySentry
Copy link
Contributor

closes: codecov/engineering-team#1726

Add a concept of commit status, the difference between this and commit.state is that the value of status examines all the uploads (ie sessions) belonging to the commit, will return:

  • completed if all uploads are processed state
  • error if any one upload is error state
  • pending if any one upload is uploaded state (error has prio)

Also added a filter option coverageStatus to Repository.commits

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@JerrySentry JerrySentry requested a review from a team as a code owner May 31, 2024 16:44
@codecov-notifications
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented May 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.49%. Comparing base (6fc8d0c) to head (4890904).

✅ All tests successful. No failed tests found.

@@            Coverage Diff             @@
##             main     #593      +/-   ##
==========================================
+ Coverage   91.46%   91.49%   +0.02%     
==========================================
  Files         615      615              
  Lines       16328    16370      +42     
==========================================
+ Hits        14935    14977      +42     
  Misses       1393     1393              
Flag Coverage Δ
unit 91.49% <100.00%> (+0.02%) ⬆️
unit-latest-uploader 91.49% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
graphql_api/actions/commits.py 100.00% <100.00%> (ø)
graphql_api/types/commit/commit.py 100.00% <100.00%> (ø)
graphql_api/types/enums/__init__.py 100.00% <ø> (ø)
graphql_api/types/enums/enums.py 100.00% <100.00%> (ø)
graphql_api/types/repository/repository.py 100.00% <100.00%> (ø)

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

Copy link

codecov-public-qa bot commented May 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.49%. Comparing base (6fc8d0c) to head (4890904).

✅ All tests successful. No failed tests found ☺️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #593      +/-   ##
==========================================
+ Coverage   91.46%   91.49%   +0.02%     
==========================================
  Files         615      615              
  Lines       16328    16370      +42     
==========================================
+ Hits        14935    14977      +42     
  Misses       1393     1393              
Flag Coverage Δ
unit 91.49% <100.00%> (+0.02%) ⬆️
unit-latest-uploader 91.49% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
graphql_api/actions/commits.py 100.00% <100.00%> (ø)
graphql_api/types/commit/commit.py 100.00% <100.00%> (ø)
graphql_api/types/enums/__init__.py 100.00% <ø> (ø)
graphql_api/types/enums/enums.py 100.00% <100.00%> (ø)
graphql_api/types/repository/repository.py 100.00% <100.00%> (ø)

Impacted file tree graph

Copy link

codecov bot commented May 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.92%. Comparing base (6fc8d0c) to head (4890904).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@               Coverage Diff                @@
##               main       #593        +/-   ##
================================================
+ Coverage   95.91000   95.92000   +0.01000     
================================================
  Files           793        793                
  Lines         17646      17688        +42     
================================================
+ Hits          16926      16968        +42     
  Misses          720        720                
Flag Coverage Δ
unit 91.49% <100.00%> (+0.02%) ⬆️
unit-latest-uploader 91.49% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


# Returning commit status in order of priority
# If all are processed -> COMPLETED
if all(state == "processed" for state in upload_states):
Copy link
Contributor

@ajay-sentry ajay-sentry Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could combine this into a single pass if you want, not sure the typical size of states

return_status = CommitStatus.COMPLETED.value
for state in upload_states:
if state == 'error':
has_error = true --> can return early here too
if state == 'uploaded":
has_pending = true

if has_error:
return CommitStatus.ERROR.value
if has_pending:
return CommitStatus.PENDING.value

At the very least, I don't think we need the first check since if any are error or uploaded we return early, and if not we would have gone through the whole list :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, updated!

@JerrySentry JerrySentry added this pull request to the merge queue Jun 6, 2024
Merged via the queue into main with commit 9423583 Jun 6, 2024
21 of 22 checks passed
@JerrySentry JerrySentry deleted the may_30_state branch June 6, 2024 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[API] Fix commit.state for the commit and pulls page
3 participants