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

feat: Add comparison endpoint for impacted files #212

Merged
merged 15 commits into from
Nov 3, 2023
Merged

Conversation

JerrySentry
Copy link
Contributor

@JerrySentry JerrySentry commented Oct 25, 2023

Purpose/Motivation

Adding two new endpoints to public v2 API

  1. Ability to get comparisons with only the impacted files between the two commits (this similar to GraphQL API Comparison type)
  2. Ability to get the Segment of diff for a particular file (this is similar to GraphQL API Segments type)

Overall these endpoints improve response times compared to the two equivalent public v2 endpoints since data retrieved are precomputed by worker and payload is much less since not all files in the repo is returned in the response.

This also refactors some code with the GraphQL data loader to share the same query.

Links to relevant tickets

codecov/engineering-team#654

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.

@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

Merging #212 (baab8cb) into main (7d07156) will increase coverage by 0.07%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##            main    #212     +/-   ##
=======================================
+ Coverage   95.51   95.58   +0.07     
=======================================
  Files        716     716             
  Lines      15713   15832    +119     
=======================================
+ Hits       15008   15132    +124     
+ Misses       705     700      -5     
Flag Coverage Δ
unit 95.66% <100.00%> (?)
unit-latest-uploader 95.66% <100.00%> (?)

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

Files Coverage Δ
api/public/v2/compare/views.py 98.11% <100.00%> (+0.33%) ⬆️
api/shared/compare/mixins.py 98.64% <100.00%> (+0.68%) ⬆️
api/shared/compare/serializers.py 100.00% <100.00%> (ø)
graphql_api/dataloader/comparison.py 98.43% <100.00%> (-0.03%) ⬇️
services/comparison.py 99.34% <100.00%> (+<0.01%) ⬆️

... and 2 files with indirect coverage changes

@codecov-staging
Copy link

codecov-staging bot commented Oct 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!.

@codecov-qa
Copy link

codecov-qa bot commented Oct 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7d07156) 95.60% compared to head (baab8cb) 95.66%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #212      +/-   ##
==========================================
+ Coverage   95.60%   95.66%   +0.05%     
==========================================
  Files         602      602              
  Lines       15307    15426     +119     
==========================================
+ Hits        14635    14757     +122     
+ Misses        672      669       -3     
Flag Coverage Δ
unit 95.66% <100.00%> (+0.05%) ⬆️
unit-latest-uploader 95.66% <100.00%> (+0.05%) ⬆️

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.

@codecov-public-qa
Copy link

codecov-public-qa bot commented Oct 25, 2023

Codecov Report

Merging #212 (baab8cb) into main (7d07156) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #212      +/-   ##
==========================================
+ Coverage   95.60%   95.66%   +0.05%     
==========================================
  Files         602      602              
  Lines       15307    15426     +119     
==========================================
+ Hits        14635    14757     +122     
+ Misses        672      669       -3     
Flag Coverage Δ
unit 95.66% <100.00%> (+0.05%) ⬆️
unit-latest-uploader 95.66% <100.00%> (+0.05%) ⬆️

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

Files Coverage Δ
api/public/v2/compare/views.py 98.11% <100.00%> (+0.33%) ⬆️
api/shared/compare/mixins.py 98.64% <100.00%> (+0.68%) ⬆️
api/shared/compare/serializers.py 100.00% <100.00%> (ø)
graphql_api/dataloader/comparison.py 98.43% <100.00%> (-0.03%) ⬇️
services/comparison.py 99.33% <100.00%> (+<0.01%) ⬆️

... and 1 file with indirect coverage changes

Impacted file tree graph

@JerrySentry JerrySentry changed the title [WIP] feat: Add comparison endpoint for impacted files feat: Add comparison endpoint for impacted files Oct 31, 2023
api/shared/compare/mixins.py Outdated Show resolved Hide resolved

return Response(
ImpactedFilesComparisonSerializer(
comparison,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could just pass in a ComparisonReport here. I don't think this comparison is actually used anywhere inside?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The comparison object is still used in the ComparisonSerializer for displaying the head/base coverage and some other things.

def impacted_files(self, request, *args, **kwargs):
comparison = self.get_object()

return Response(
Copy link
Contributor

Choose a reason for hiding this comment

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

If the commit comparison is still being processed should we fallback to computing the impacted files on-the-fly?

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively maybe the serializer includes the state and we update the docs (the docstring comment in the child view) to explain that this state might change after the initial request.

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 see, right now if the comparison is still being computed it would return an empty object for the impacted files. I think the most consistent thing to do during pending state is to compute on-the-fly the files similar to what's already happening when the CommitComparison object doesn't exist yet.

@JerrySentry JerrySentry merged commit 206e7ef into main Nov 3, 2023
19 of 20 checks passed
@JerrySentry JerrySentry deleted the api_654a branch November 3, 2023 17:08
scott-codecov added a commit that referenced this pull request Nov 6, 2023
* main:
  Test ats run (#229)
  Release 23.11.2 (#228)
  feat: Add comparison endpoint for impacted files (#212)
  Update shared version (#226)
  feat: add a filter for public/private repo filter for viewableRepositories (#224)
  fix: speedup flag filtering in GraphQL API (#223)
  fix: Disable early notify comment (#219)
  Add 'value' key to the plan representation resolver  (#216)
  713 adjust available plans in plan service (#214)
  feat: Allow upload requests originating from Shelter to set storage path (#172)
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.

None yet

2 participants