-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 codecov client #1169
Merged
Merged
Changes from 7 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
39f8d2c
initial commit
rohitvinnakota-codecov 5f2e47e
Merge branch 'main' of https://github.com/getsentry/seer into rvinnak…
rohitvinnakota-codecov 10fdd12
Update codecov_client.py
rohitvinnakota-codecov 6e33f73
saving WIP
rohitvinnakota-codecov 38f419e
Fix merge
rohitvinnakota-codecov 50ea0ac
Add prompt
rohitvinnakota-codecov 36868a2
Updated commit
rohitvinnakota-codecov 1745bbb
Update
rohitvinnakota-codecov 086a8f2
undo some things
rohitvinnakota-codecov 2e22ea6
Add init py
rohitvinnakota-codecov 63347dc
Update
rohitvinnakota-codecov af83011
Update signature
rohitvinnakota-codecov f1d993d
Add test
rohitvinnakota-codecov e1d380f
Add to app config
rohitvinnakota-codecov 417dacc
Merge branch 'main' into rvinnakota/add-codecov-client
rohitvinnakota-codecov 6f3c316
Update
rohitvinnakota-codecov 6f9c5c6
More tests
rohitvinnakota-codecov 3a5fb74
Update
rohitvinnakota-codecov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import requests | ||
|
||
|
||
CODECOV_TOKEN = 'FETCH FROM ENV' | ||
class CodecovClient: | ||
@staticmethod | ||
def fetch_coverage(owner_username, repo_name, pullid, token=CODECOV_TOKEN): | ||
url = f"https://api.codecov.io/api/v2/github/{owner_username}/repos/{repo_name}/pulls/{pullid}" | ||
headers = { | ||
"Authorization": f"Bearer {token}", | ||
"Accept": "application/json" | ||
} | ||
response = requests.get(url, headers=headers) | ||
if response.status_code == 200: | ||
return response.json() | ||
else: | ||
response.raise_for_status() | ||
|
||
@staticmethod | ||
def fetch_test_results_for_commit(owner_username, repo_name, latest_commit_sha, token=CODECOV_TOKEN): | ||
url = f"https://api.codecov.io/api/v2/github/{owner_username}/repos/{repo_name}/test-results" | ||
headers = { | ||
"Authorization": f"Bearer {token}", | ||
"Accept": "application/json", | ||
latest_commit_sha: latest_commit_sha, | ||
} | ||
response = requests.get(url, headers=headers) | ||
if response.status_code == 200: | ||
return response.json() | ||
else: | ||
response.raise_for_status() | ||
|
||
|
||
@staticmethod | ||
def ping(): | ||
return "pong" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is totes fine for now, but in the future, using instance methods makes it easier to potentially subclass for test mock purposes.
This is a minor nit that doesn't need to be addresses here, but food for thought on future design.