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

Fix: To check if kebechet's advise manager is working on all overlays #1096

Merged
merged 1 commit into from
Jul 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions kebechet/managers/thoth_advise/thoth_advise.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def _open_merge_request(
) -> typing.Optional[PullRequest]:
"""Open a pull/merge request for dependency update."""
commit_msg = "Auto generated update"

if self._metadata_indicates_internal_trigger():
body = _INTERNAL_TRIGGER_PR_BODY_LOOKUP[
int(self.metadata["message_justification"]) # type: ignore
Expand All @@ -154,7 +153,6 @@ def _open_merge_request(
)

body = f"# Automatic Update of {full_name} runtime-environment\n" + body

# Delete branch if it didn't change Pipfile.lock
diff = self.repo.git.diff(self.project.default_branch, files)
if diff == "":
Expand Down Expand Up @@ -187,11 +185,11 @@ def _write_advise(self, adv_results: dict):
with open(".thoth.yaml", "r") as f:
thoth_config = yaml.safe_load(f)
overlays_dir = thoth_config.get("overlays_dir")
requirements_lock = adv_results["result"]["report"]["products"][0]["project"][
requirements_lock = adv_results["report"]["products"][0]["project"][
"requirements_locked"
]
requirements = adv_results["result"]["parameters"]["project"]["requirements"]
requirements_format = adv_results["result"]["parameters"]["requirements_format"]
requirements = adv_results["parameters"]["project"]["requirements"]
requirements_format = adv_results["parameters"]["requirements_format"]
if overlays_dir:
with cwd(f"{overlays_dir}/{self.runtime_environment}"):
lib.write_files(
Expand Down Expand Up @@ -325,7 +323,6 @@ def run(self, labels: list, analysis_id=None):
runtime_environments = [
thoth_config["runtime_environments"][0]["name"]
]

for e in runtime_environments:
try:
analysis_id = lib.advise_here(
Expand Down Expand Up @@ -380,16 +377,26 @@ def run(self, labels: list, analysis_id=None):
)
return False
_LOGGER.debug(json.dumps(res))

with open(".thoth.yaml", "r") as f:
thoth_config = yaml.safe_load(f)
overlays_dir = thoth_config.get("overlays_dir")
self.runtime_environment = _runtime_env_name_from_advise_response(
res[0]
)
to_ret = False
if res[1] is False:
_LOGGER.info("Advise succeeded")
self._write_advise(res[0])
res[0].update({"document_id": analysis_id})
file_path = (
os.path.join(
overlays_dir, str(self.runtime_environment), "Pipfile.lock"
)
if overlays_dir
else "Pipfile.lock"
)
opened_merge = self._open_merge_request(
branch_name, labels, ["Pipfile.lock"], res[0].get("metadata")
branch_name, labels, [file_path], res[0]
Copy link
Member

Choose a reason for hiding this comment

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

Wouldnt this res[0] put a lot of info on the pr ?

Copy link
Member Author

Choose a reason for hiding this comment

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

)
if opened_merge and self._tracking_issue:
comment = (
Expand Down