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

(Git-6) Use new Git Backend in Entire auto_tick flow #3004

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ytausch
Copy link
Contributor

@ytausch ytausch commented Sep 16, 2024

Description:

Building upon #3003, this replaces the remaining auto_tick logic to use the new git backend.
Notably, this PR ensures that the new backend is used for opening PRs and commenting on PRs.

Checklist:

  • Pydantic model updated or no update needed

Cross-refs, links to issues, etc:

#3003 should be merged first.

@ytausch
Copy link
Contributor Author

ytausch commented Sep 16, 2024

@0xbe7a I think this is worth reviewing, even with limited knowledge of the codebase

added: open PR, comment on PR
@@ -48,7 +52,7 @@ class PullRequestState(StrEnum):
"""


class PullRequestInfoHead(StrictBaseModel):
class PullRequestInfoHead(ValidatedBaseModel):
Copy link

Choose a reason for hiding this comment

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

Why did you relax this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In GitHubBackend.create_pull_request, the pr_json pydantic model is directly validated on the JSON returned by the GitHub API. However, we do not want to keep all the information the API returns, mainly since these pydantic models also correspond to the data stored in cf-graph. Hence, I relaxed this to ignore any additional data returned by GitHub.
Since the direct usage of the model also prevents the code from introducing additional extra fields to the pr_json data, it's OK that the model validation test can no longer detect such extra fields when processing the cf-graph data.

Copy link

codecov bot commented Sep 16, 2024

Codecov Report

Attention: Patch coverage is 89.92000% with 63 lines in your changes missing coverage. Please review.

Project coverage is 77.40%. Comparing base (a1942f2) to head (d29da4a).

Files with missing lines Patch % Lines
conda_forge_tick/auto_tick.py 14.00% 43 Missing ⚠️
conda_forge_tick/git_utils.py 88.79% 13 Missing ⚠️
tests/test_git_utils.py 98.40% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3004      +/-   ##
==========================================
+ Coverage   76.27%   77.40%   +1.12%     
==========================================
  Files         115      115              
  Lines       12532    12948     +416     
==========================================
+ Hits         9559    10022     +463     
+ Misses       2973     2926      -47     

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

)
except subprocess.CalledProcessError as e:
raise GitCliError("Error running git command.") from e
e.stdout = replace_tokens(e.stdout, self.__hidden_tokens)
Copy link

Choose a reason for hiding this comment

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

I'm not a huge fan of encoding the credentials in the remote URL and then censoring the logs. I think a better approach would be similar to how GitHub handles it in the checkout action, by setting up the 'http.https://github.com/.extraheader' git config to include the authorization header.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah putting the credentials on disk is not so great too right, or did I miss something? In any case, I don't actually care either way, but if we do put credentials on disk, we'll want to ensure they get cleaned up before the python process exits. On CI, GitHub will do this for us but potentially people running locally with a token might not.

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.

3 participants