-
Notifications
You must be signed in to change notification settings - Fork 50
Bug 2048352 - Migrate code-review bot to push to Github #3490
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
Draft
nahadji
wants to merge
8
commits into
mozilla:master
Choose a base branch
from
nahadji:bug-2048352-git-push
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,177
−31
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ad795d2
Bug 2048352 - Add a GitRepository to apply and push patch stacks to Git
nahadji 9e3b259
Bug 2048352 - Add a GitWorker and make GitRepository.clean() pristine
nahadji b0e5ba3
Bug 2048352 - Select the Git or Mercurial backend per repository
nahadji cf3be33
Bug 2048352 - Publish Git worker failures to Phabricator and Lando
nahadji 533a025
Bug 2048352 - Report missing base revisions and harden clean() on the…
nahadji 43f4072
Bug 2048352 - Fetch the Git deploy key from a dedicated Taskcluster s…
nahadji 1fc32c7
Bug 2048352 - Import workflow lazily in tests to keep date mocking ef…
nahadji 38599f0
Bug 2048352 - Authenticate Git pushes with a GitHub App installation …
nahadji 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -24,7 +24,10 @@ | |
| ) | ||
| RepositoryConf = collections.namedtuple( | ||
| "RepositoryConf", | ||
| "name, try_name, url, try_url, decision_env_prefix, ssh_user", | ||
| "name, try_name, url, try_url, decision_env_prefix, ssh_user, repo_type", | ||
| # repo_type is optional and defaults to Mercurial so existing repository | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please document that in https://github.com/mozilla/code-review/blob/master/docs/configuration.md |
||
| # secrets keep working; set it to "git" to push to a Git remote instead. | ||
| defaults=("hg",), | ||
| ) | ||
|
|
||
|
|
||
|
|
@@ -63,6 +66,10 @@ def __init__(self): | |
| # SSH Key used to push on try | ||
| self.ssh_key = None | ||
|
|
||
| # GitHub App credentials used to push on Git try repositories | ||
| self.github_app_id = None | ||
| self.github_app_privkey = None | ||
|
|
||
| # List of users that should trigger a new analysis | ||
| # Indexed by their Phabricator ID | ||
| self.user_blacklist = {} | ||
|
|
@@ -80,6 +87,8 @@ def setup( | |
| ssh_key=None, | ||
| mercurial_cache=None, | ||
| git_cache=None, | ||
| github_app_id=None, | ||
| github_app_privkey=None, | ||
| ): | ||
| # Detect source from env | ||
| if "TRY_TASK_ID" in os.environ and "TRY_TASK_GROUP_ID" in os.environ: | ||
|
|
@@ -123,13 +132,18 @@ def build_conf(nb, repo): | |
| assert isinstance( | ||
| repo, dict | ||
| ), "Repository configuration #{nb+1} is not a dict" | ||
| data = [] | ||
| data = {} | ||
| for key in RepositoryConf._fields: | ||
| assert ( | ||
| key in repo | ||
| ), f"Missing key {key} in repository configuration #{nb+1}" | ||
| data.append(repo[key]) | ||
| return RepositoryConf._make(data) | ||
| if key in repo: | ||
| data[key] = repo[key] | ||
| elif key in RepositoryConf._field_defaults: | ||
| # Optional field, fall back to its default (e.g. repo_type) | ||
| data[key] = RepositoryConf._field_defaults[key] | ||
| else: | ||
| raise AssertionError( | ||
| f"Missing key {key} in repository configuration #{nb+1}" | ||
| ) | ||
| return RepositoryConf(**data) | ||
|
|
||
| self.repositories = [build_conf(i, repo) for i, repo in enumerate(repositories)] | ||
| assert self.repositories, "No repositories available" | ||
|
|
@@ -161,6 +175,9 @@ def build_conf(nb, repo): | |
| # Fallback to mercurial cache to ease migration on production systems | ||
| self.git_cache = self.mercurial_cache | ||
|
|
||
| self.github_app_id = github_app_id | ||
| self.github_app_privkey = github_app_privkey | ||
|
|
||
| def load_user_blacklist(self, usernames, phabricator_api): | ||
| """ | ||
| Load all black listed users from Phabricator API | ||
|
|
||
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.
It would be nicer to create a dedicated
GITHUBmaaping in the conf with the following parts:app_idapp_privkeyThis would allow adding more configuration later on (as the needs for Github will certainly grow in that code base).
Also you need to document these new options there : https://github.com/mozilla/code-review/blob/master/docs/configuration.md