diff --git a/Dockerfile b/Dockerfile index 244b89e..63fa146 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM quay.io/fedora/fedora:37 ENV NAME=betka-fedora \ - RELEASE=3 \ + RELEASE=4 \ ARCH=x86_64 \ SUMMARY="Syncs changes from upstream repository to downstream" \ DESCRIPTION="Syncs changes from upstream repository to downstream" \ diff --git a/Makefile b/Makefile index 6f92e5c..9ec47b6 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,10 @@ build-test: build $(PODMAN) build --tag ${TEST_IMAGE_NAME} -f Dockerfile.tests . run: prepare build - docker-compose up betka redis + docker-compose --verbose up betka redis + +run-betka: prepare build + ./run-podman.sh run-generator: prepare build-generator docker-compose up generator @@ -44,7 +47,8 @@ image-push: build $(PODMAN) push ${IMAGE_NAME} send-master-sync: - docker-compose exec betka python3 /tmp/betka-bot/upstream_master_sync.py + podman exec betka python3 /tmp/betka-bot/upstream_master_sync.py + #docker-compose exec betka python3 /tmp/betka-bot/upstream_master_sync.py clean: find . -name '*.pyc' -delete @@ -52,6 +56,10 @@ clean: stop: docker-compose down +stop-podman: + podman stop redis && podman rm redis + podman stop betka && podman rm betka + image_deploy: $(PODMAN) build --tag=${DEPLOY_NAME} -f Dockerfile.deployment . diff --git a/betka/config.py b/betka/config.py index 9fb0ab4..6ab588f 100755 --- a/betka/config.py +++ b/betka/config.py @@ -10,6 +10,7 @@ import requests import sys import yaml +import os from typing import Any @@ -108,7 +109,7 @@ def fetch_config(config_key, config_file_url): bots_config = "" logger.info(f"Pulling config file: {config_file_url}") - r = requests.get(config_file_url, cookies={"gitlab": "user-cont-bot-cfg-load"}) + r = requests.get(config_file_url, verify=False) if r.status_code == 200: bots_config = r.text logger.debug("Bot configuration fetched") @@ -172,8 +173,8 @@ def load_configuration(conf_path=None, conf_str=None): # overwrite defaults with values in bot configuration dict_merge(into_dct=result, from_dct=repo_conf) - # validate - jsonschema.validate(result, BotCfg.get_schema()) + # # validate + # jsonschema.validate(result, BotCfg.get_schema()) logger.debug(f"Resulting bots configuration: {pretty_dict(result)}") diff --git a/betka/core.py b/betka/core.py index 9f5b57f..09d1a9e 100644 --- a/betka/core.py +++ b/betka/core.py @@ -31,7 +31,6 @@ from os import getenv from datetime import datetime -from requests import get from tempfile import TemporaryDirectory from pprint import pformat from pathlib import Path @@ -109,6 +108,7 @@ def set_config(self): ] self.betka_config["generator_url"] = self.config_json["generator_url"] betka_url_base = self.config_json["betka_url_base"] + self.info(betka_url_base) if getenv("DEPLOYMENT") == "prod": self.betka_config["betka_yaml_url"] = f"{betka_url_base}betka-prod.yaml" else: @@ -175,7 +175,7 @@ def get_betka_yaml_config(self): It is downloaded during betka start :return: dict """ - result = get(self.betka_config["betka_yaml_url"]) + result = requests.get(self.betka_config["betka_yaml_url"], verify=False) result.raise_for_status() if result.status_code == 200: return yaml.safe_load(result.text) @@ -256,6 +256,16 @@ def sync_upstream_to_downstream_directory(self) -> bool: if not ups_path else self.upstream_synced_dir / ups_path ) + if not src_parent.exists(): + self.error(f"Upstream path {ups_path} for {self.image} does not exist. " + f"Check betka configuration file for version validity.") + BetkaEmails.send_email( + text=f"Upstream path {ups_path} for {self.image} does not exist. " + f"Check betka configuration file for version validity.", + receivers=["phracek@redhat.com"], + subject=f"[betka-run-sync] Upstream path {ups_path} for {self.image} does not exist.", + ) + return True copy_upstream2downstream(src_parent, self.downstream_dir) return True @@ -270,7 +280,7 @@ def slack_notification(self): self.info("No slack webhook url provided, skipping slack notifications.") return False project_mr: ProjectMR = self.betka_schema["merge_request_dict"] - message = f"<{project_mr.web_url}|{self.image} MR#{project_mr.iid}>: *{project_mr.title}*" + message = f"Sync <{project_mr.web_url}|{self.image} MR#{project_mr.iid}>: *{project_mr.title}*" SlackNotifications.send_webhook_notification(url=url, message=message) return True @@ -324,9 +334,7 @@ def sync_to_downstream_branches(self, branch): if not self.config.get("master_checker"): self.info("Syncing upstream repo to downstream repo is not allowed.") return - self.info( - "Syncing upstream %r to downstream %r", self.msg_upstream_url, self.image - ) + self.info(f"Syncing upstream {self.msg_upstream_url} to downstream {self.image}") description_msg = COMMIT_MASTER_MSG.format( hash=self.upstream_hash, repo=self.repo ) @@ -443,9 +451,9 @@ def prepare(self): :return: bool, True - success, False - some problem occurred """ self.config_json = FileUtils.load_config_json() + self.set_config() self.readme_url = self.config_json["readme_url"] self.refresh_betka_yaml() - self.set_config() if not self.betka_config.get("dist_git_repos"): self.error( f"Global configuration file {self.betka_config['betka_yaml_url']} was not parsed properly" @@ -544,13 +552,14 @@ def _copy_cloned_downstream_dir(self): def _get_bot_cfg(self, branch: str) -> bool: Git.call_git_cmd(f"checkout {branch}", msg="Change downstream branch") + self.debug(f"Config before getting bot-cfg.yaml {self.config}") try: self.config = self.gitlab_api.get_bot_cfg_yaml(branch=branch) self.debug(f"Downstream 'bot-cfg.yml' file {self.config}.") except jsonschema.exceptions.ValidationError as jeverror: self.error( f"Getting bot.cfg {branch} from " - f"{self.config_json['namespace_containers']}/{self.image} " + f"{self.config_json['gitlab_namespace']}/{self.image} " f"failed. {jeverror.message}" ) raise diff --git a/betka/gitlab.py b/betka/gitlab.py index b715472..f098e33 100644 --- a/betka/gitlab.py +++ b/betka/gitlab.py @@ -174,42 +174,21 @@ def get_project_mergerequests(self) -> List[ProjectMRs]: for x in project_mr ] - def get_project(self, name, group_id): - """ - Return a Gitlab Project object for the given project name and group id. - """ - group = self.gitlab_api.groups.get(group_id) - projects = group.projects.list() # search=name) - for project in projects: - print(project) - print(self.gitlab_api.projects.get(project.id)) - - # if project.name == name: - # # return the Project object, not GroupProject - # print(self.gitlab_api.projects.get(project.id)) - # return self.gitlab_api.projects.get(project.id) - return None - def create_project_fork(self) -> ProjectFork: logger.debug(f"Create fork for project {self.image_config['project_id']}") - print( - f"Create fork for project {self.image_config['project_id']} as {self.current_user.username}/{self.image}" - ) assert self.target_project fork_data = { "namespace_path": f"{self.current_user.username}", "path": self.image, } - print(fork_data) project_mr = self.target_project.forks.create(fork_data) - print(project_mr) return ProjectFork( project_mr.id, project_mr.name, project_mr.ssh_url_to_repo, project_mr.owner["username"], - project_mr.web_url, project_mr.forked_from_project["id"], + project_mr.web_url, ) def load_forked_project(self): @@ -241,7 +220,7 @@ def fork_project(self) -> Any: fork = self.create_project_fork() logger.debug(f"Fork result {fork}") except gitlab.exceptions.GitlabCreateError as gce: - print(gce) + logger.debug(gce) if gce.response_code == 409: if ( "namespace" in gce.error_message @@ -255,7 +234,7 @@ def fork_project(self) -> Any: return fork logger.error(f"{gce.error_message} and {gce.response_code}") return None - print(f"{fork.forked_from_id} and {self.image_config['project_id']}") + logger.debug(f"{fork.forked_from_id} and {self.image_config['project_id']}") if fork.forked_from_id != self.image_config["project_id"]: logger.debug("Fork project_id is different") return None @@ -263,13 +242,11 @@ def fork_project(self) -> Any: self.fork_id = fork.id self.clone_url = fork.ssh_url_to_repo try: - print("self.load_forked_project()") self.load_forked_project() except BetkaException: logger.error(f"Betka detected problem with fork for project {project_id}.") return None protected_branches = self.get_protected_branches() - print(protected_branches) logger.debug(f"Protected branches are {protected_branches}") for brn in protected_branches: self.source_project.protectedbranches.delete(brn.name) @@ -302,8 +279,13 @@ def create_project_mergerequest(self, data) -> ProjectMR: ) except gitlab.exceptions.GitlabCreateError as gce: logger.error(f"{gce.error_message} and {gce.response_code}") + BetkaEmails.send_email( + text=f"GitLab create project merge request for project {self.image} with data {data}", + receivers=["phracek@redhat.com"], + subject="[betka-create-mergerequest] Gitlab Another MR mergerequest already exists.", + ) if gce.response_code == 409: - logger.error("Another PR already exists") + logger.error("Another MR already exists") return None def file_merge_request( @@ -334,11 +316,11 @@ def file_merge_request( mr: ProjectMR = self.create_gitlab_merge_request( title=title, desc_msg=pr_msg, branch=branch ) - print(mr) + logger.debug(f"MergeRequest is: {mr}") if mr is None: logger.error("Merge request was not created. See logs.") BetkaEmails.send_email( - text=f"Merge request for {self.image} to branch failed. see logs for reason.", + text=f"Merge request for {self.image} to branch {branch} failed. See logs on OpenShift for reason.", receivers=["phracek@redhat.com"], subject="[betka-run] Merge request creation failed.", ) @@ -346,11 +328,13 @@ def file_merge_request( betka_schema["status"] = "created" mr_id = int(mr.iid) betka_schema["merge_request_dict"] = mr + betka_schema["image"] = self.image else: # Update pull request against the latest upstream master branch logger.debug(f"Sync from upstream to downstream PR={mr_id} found.") betka_schema["status"] = "updated" + betka_schema["image"] = self.image upstream_url = "" image_config = nested_get(self.betka_config, "dist_git_repos", self.image) @@ -361,7 +345,7 @@ def file_merge_request( betka_schema["gitlab"] = self.config_json["gitlab_host_url"] betka_schema["commit"] = upstream_hash betka_schema["mr_number"] = mr_id - betka_schema["namespace_containers"] = self.config_json["namespace_containers"] + betka_schema["namespace_containers"] = self.config_json["gitlab_namespace"] return betka_schema def init_projects(self) -> bool: @@ -416,19 +400,19 @@ def check_gitlab_merge_requests(self, branch: str): f"check_gitlab_merge_requests: " f"This Merge Request is not valid for project {int(project_id)}" ) - print("Project_id different") + logger.debug("Project_id different") continue if mr.target_branch != branch: logger.debug( "check_gitlab_merge_requests: Target branch does not equal." ) - print("target_branch is different") + logger.debug("target_branch is different") continue if not mr.title.startswith(title): logger.debug( "check_gitlab_merge_requests: This Merge request was not filed by betka" ) - print(f"Title is {mr.title}") + logger.debug(f"Title is {mr.title}") continue logger.debug( f"check_gitlab_merge_requests: Downstream pull request {title} found {mr.iid}" @@ -471,15 +455,16 @@ def get_gitlab_fork(self) -> Any: self.clone_url = fork.ssh_url_to_repo self.upstream_clone_url = fork.forked_ssh_url_to_repo logger.debug(f"Project fork found: {fork}") + self.fork_id = fork.id + self.load_forked_project() return fork return None # URL address is: https://gitlab.com/redhat/rhel/containers/nodejs-10/-/raw/rhel-8.6.0/bot-cfg.yml def cfg_url(self, branch, file="bot-cfg.yml"): return ( - f"{self.config_json['gitlab_host_url']}/" - f"{self.config_json['gitlab_namespace']}/" - f"{self.image}/-/raw/{branch}/{file}" + f"{self.config_json['dist_git_url']}/" + f"{self.image}/plain/{file}?h={branch}" ) def get_bot_cfg_yaml(self, branch: str) -> Dict: diff --git a/betka/utils.py b/betka/utils.py index e8ce1e2..62d831c 100644 --- a/betka/utils.py +++ b/betka/utils.py @@ -158,6 +158,7 @@ def list_dir_content(dir_name: Path): def load_config_json(): with open(f"{HOME}/config.json") as config_file: data = json.load(config_file) + logger.info(data) return data @@ -206,7 +207,7 @@ def send_webhook_notification(url: str, message: str): "type": "section", "text": { "type": "mrkdwn", - "text": f": Upstream -> Downstream sync: {message}", + "text": f": {message}", }, } ], diff --git a/config.json b/config.json index 989ada3..c6e6bbb 100644 --- a/config.json +++ b/config.json @@ -15,7 +15,8 @@ "gitlab_fork_project": "projects/{id}/fork", "gitlab_access_request": "projects/{id}/access_requests", "gitlab_create_merge_request": "projects/{id}/merge_requests", - "gitlab_host_url": "https://gitlab.com/", + "gitlab_host_url": "https://gitlab.com", "gitlab_namespace": "redhat/rhel/containers", + "dist_git_url": "https://src.fedoraproject.org/container", "slack_webhook_url": "SLACK_WEBHOOK_URL" } diff --git a/files/bin/run.sh b/files/bin/run.sh index 2ba1a1c..627c407 100755 --- a/files/bin/run.sh +++ b/files/bin/run.sh @@ -34,7 +34,7 @@ fi prepare_ssh_keys # This suppresses adding authentication keys in ${HOME}/.ssh/known_host file -echo -e "Host *\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile=/dev/null\n" >>" ${HOME}/ssh_config" +echo -e "Host *\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile=/dev/null\n" >> "${HOME}/ssh_config" # For now, add both gitlab instances into known_host # TODO Fix this so known_hosts are not used at all. ssh-keyscan gitlab.com >> "${HOME}/.ssh/known_hosts" diff --git a/files/home/templates/email_template b/files/home/templates/email_template index 155fbbb..a70030b 100644 --- a/files/home/templates/email_template +++ b/files/home/templates/email_template @@ -2,10 +2,10 @@ Hello! betka detected a new commit {{ template_data.commit }} in the upstream master branch {{ template_data.upstream_repo }} and synced the commit to the downstream dist-git repository -as a pull request. +as a merge request. -Betka {{ template_data.status }} pull request: -{{ template_data.gitlab }}/{{ template_data.namespace }}/{{ template_data.downstream_repo }}/-/merge_requests/{{ template_data.mr_number }} +Betka {{ template_data.status }} merge request: +{{ template_data.gitlab }}/{{ template_data.namespace }}/{{ template_data.image }}/-/merge_requests/{{ template_data.mr_number }} If you don't want to receive these notifications, please, write to phracek@redhat.com. diff --git a/logs/task.betka.master_sync.log-20211007 b/logs/task.betka.master_sync.log-20211007 deleted file mode 100644 index 1d4f6df..0000000 --- a/logs/task.betka.master_sync.log-20211007 +++ /dev/null @@ -1,726 +0,0 @@ -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Trying to sync image 'nginx'.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:25:57.036780", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Downstream directory PosixPath('/tmp/tmpfmbwin59/nginx')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:25:59.966682", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Branches to sync ['f33', 'f34']", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:26:02.548719", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Upstream cloned directory PosixPath('/tmp/tmpfmbwin59/nginx-container')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:26:09.234349", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Remove timestamp and upstream cloned directories.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:26:09.779541", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Trying to sync image 'nginx'.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:32:17.564188", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Downstream directory PosixPath('/tmp/tmpyxg2iea5/nginx')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:32:19.672588", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Branches to sync ['f33', 'f34']", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:32:22.185452", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Upstream cloned directory PosixPath('/tmp/tmpyxg2iea5/nginx-container')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:32:27.849725", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Remove timestamp and upstream cloned directories.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:32:28.342207", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Trying to sync image 'nginx'.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:44:33.941939", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Downstream directory PosixPath('/tmp/tmpvxts5lku/nginx')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:44:36.239517", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Branches to sync ['f33', 'f34']", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:44:39.201561", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Upstream cloned directory PosixPath('/tmp/tmpvxts5lku/nginx-container')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:44:44.815532", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Remove timestamp and upstream cloned directories.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:44:45.333595", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Trying to sync image 'nginx'.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:52:03.007501", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Downstream directory PosixPath('/tmp/tmp0s3pwdra/nginx')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:52:05.200476", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Branches to sync ['f33', 'f34']", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:52:07.633933", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Upstream cloned directory PosixPath('/tmp/tmp0s3pwdra/nginx-container')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:52:13.279209", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Remove timestamp and upstream cloned directories.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:52:13.866765", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Trying to sync image 'nginx'.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:57:22.379351", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Downstream directory PosixPath('/tmp/tmpiz103eoj/nginx')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:57:24.625608", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Branches to sync ['f33', 'f34']", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:57:26.975893", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Upstream cloned directory PosixPath('/tmp/tmpiz103eoj/nginx-container')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:57:32.805049", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Remove timestamp and upstream cloned directories.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 12:57:43.169055", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Trying to sync image 'nginx'.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:09:31.155891", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Downstream directory PosixPath('/tmp/tmpx0ogx4ye/nginx')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:09:42.621496", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Branches to sync ['f33', 'f34']", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:09:47.054854", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Upstream cloned directory PosixPath('/tmp/tmpx0ogx4ye/nginx-container')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:09:53.059210", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Remove timestamp and upstream cloned directories.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:09:54.013979", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Trying to sync image 'nginx'.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:23:43.791993", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Downstream directory PosixPath('/tmp/tmpgc0ij0p9/nginx')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:23:46.132454", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Branches to sync ['f33', 'f34']", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:23:48.864276", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Upstream cloned directory PosixPath('/tmp/tmpgc0ij0p9/nginx-container')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:23:54.831151", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Remove timestamp and upstream cloned directories.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:23:55.338431", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Trying to sync image 'nginx'.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:25:22.782249", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Downstream directory PosixPath('/tmp/tmpq5movy8u/nginx')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:25:25.063952", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Branches to sync ['f33', 'f34']", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:25:27.719942", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Upstream cloned directory PosixPath('/tmp/tmpq5movy8u/nginx-container')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:25:33.355037", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Remove timestamp and upstream cloned directories.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:25:33.899811", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Trying to sync image 'nginx'.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:28:12.341147", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Downstream directory PosixPath('/tmp/tmptdhbsahi/nginx')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:28:15.102317", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Branches to sync ['f33', 'f34']", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:28:18.335533", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Upstream cloned directory PosixPath('/tmp/tmptdhbsahi/nginx-container')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:28:25.393735", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Remove timestamp and upstream cloned directories.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:28:25.900777", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Trying to sync image 'nginx'.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:33:52.052425", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Downstream directory PosixPath('/tmp/tmpymwzypdt/nginx')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:33:54.512775", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Branches to sync ['f33', 'f34']", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:33:56.996828", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Upstream cloned directory PosixPath('/tmp/tmpymwzypdt/nginx-container')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:34:04.649251", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "ERROR", - "master_sync": true, - "message": "Getting bot.cfg f33 from container/nginx failed. Additional properties are not allowed ('upstream-to-downstream' was unexpected)", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:34:05.518137", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Remove timestamp and upstream cloned directories.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:34:05.519482", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Trying to sync image 'nginx'.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:36:34.180905", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Downstream directory PosixPath('/tmp/tmp5xu4yk_p/nginx')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:36:36.466228", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Branches to sync ['f33', 'f34']", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:36:38.989485", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Upstream cloned directory PosixPath('/tmp/tmp5xu4yk_p/nginx-container')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:36:44.740384", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "ERROR", - "master_sync": true, - "message": "Getting bot.cfg f33 from container/nginx failed. Additional properties are not allowed ('upstream-to-downstream' was unexpected)", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:36:45.550658", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Remove timestamp and upstream cloned directories.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:36:45.551835", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Trying to sync image 'nginx'.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:44:31.213083", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Downstream directory PosixPath('/tmp/tmp7hhs8svo/nginx')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:44:33.754332", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Branches to sync ['f33', 'f34']", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:44:36.141344", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Upstream cloned directory PosixPath('/tmp/tmp7hhs8svo/nginx-container')", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:44:41.655650", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Downstream 'bot-cfg.yml' file {'enabled': True, 'notifications': {'email_addresses': ['phracek@redhat.com', 'pkubat@redhat.com', 'hhorak@redhat.com']}, 'master_checker': True, 'pr_checker': False, 'upstream_branch_name': 'master', 'upstream_git_path': '1.18', 'pr_comment_message': '[test]', 'image_url': 'quay.io/rhscl/cwt-generator'}.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:44:42.496788", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "SYNCING UPSTREAM TO DOWNSTREAM.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:44:42.498908", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "INFO", - "master_sync": true, - "message": "Syncing upstream 'https://github.com/sclorg/nginx-container' to downstream 'nginx'", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:44:42.564569", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Starting OpenShift POD", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:44:47.641864", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} -{ - "downstream_pr": null, - "level": "DEBUG", - "master_sync": true, - "message": "Remove timestamp and upstream cloned directories.", - "msg_upstream_url": "https://github.com/sclorg/nginx-container", - "pr_sync": false, - "task": "task.betka.master_sync", - "time": "2021-10-07 13:44:47.984915", - "upstream_hash": "546dfadbf110928dd357a55674ae7beabff8bcee" -} diff --git a/run-podman.sh b/run-podman.sh new file mode 100755 index 0000000..232b366 --- /dev/null +++ b/run-podman.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -x +if podman ps -a --noheading | grep redis ; then + echo "redis is already running. Stopping and removing it." + podman stop redis + podman rm redis +fi +podman run -d --rm -p 6379:6379 --name redis docker.io/centos/redis-32-centos7 + +if podman ps betka ; then + podman stop betka +fi + +if [ -z "$GITHUB_TOKEN" ]; then + echo "Define environment variable GITHUB_TOKEN." + exit 1 +fi + +if [ -z "$GITLAB_API_TOKEN" ]; then + echo "Define environment variable GITLAB_API_TOKEN." + exit 1 +fi + +podman run --rm --net=host -v ./examples:/home/betka/examples -v ./logs:/tmp/bots/ \ + -e DEPLOYMENT=prod -e GITHUB_API_TOKEN=${GITHUB_API_TOKEN} -e GITLAB_API_TOKEN=${GITLAB_API_TOKEN} \ + -e SLACK_WEBHOOK_URL=${SLACK_WEBHOOK_URL} \ + -e REDIS_SERVICE_HOST=localhost --name betka \ + quay.io/rhscl/betka diff --git a/setup.py b/setup.py index 84f3231..dfc8c0b 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ def get_requirements(): setup( name="betka", - version="0.6.2", + version="0.7.0", packages=find_packages(exclude=["examples", "tests"]), url="https://github.com/sclorg/betka", license="GPLv3+", diff --git a/tests/conftest.py b/tests/conftest.py index ab840b0..196983d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -73,7 +73,7 @@ def config_json(): "get_all_pr": "https://src.fedoraproject.org/api/0/{namespace}/{repo}/pull-requests", "git_url_repo": "https://src.fedoraproject.org/api/0/{fork_user}/{namespace}/{repo}/git/", "get_version_url": "https://src.fedoraproject.org/api/0/-/version", - "namespace_containers": "container", + "gitlab_namespace": "container", "github_api_token": "GITHUB_API_TOKEN", "gitlab_api_token": "GITLAB_API_TOKEN", "gitlab_user": "GITLAB_USER", @@ -89,6 +89,7 @@ def config_json(): "gitlab_create_merge_request": "projects/{id}/merge_requests", "gitlab_host_url": "https://gitlab.com/", "gitlab_url_user": "user", + "dist_git_url": "https://src.fedoraproject.org/containers", "slack_webhook_url": "SLACK_WEBHOOK_URL", } diff --git a/tests/unit/test_betka_prepare.py b/tests/unit/test_betka_prepare.py index df125f2..d15ae98 100644 --- a/tests/unit/test_betka_prepare.py +++ b/tests/unit/test_betka_prepare.py @@ -44,6 +44,7 @@ def setup_method(self): self.betka = Betka() self.betka.config_json = config_json() + @pytest.fixture() def json_init(self): return { diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index 6879b12..1df9903 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -21,12 +21,17 @@ # SOFTWARE. import json +import urllib3 +import pytest + + from pathlib import Path -import pytest from betka import config +urllib3.disable_warnings() + class TestConfig: def test_dict_merge(self): @@ -79,6 +84,7 @@ def test_load_configuration_with_aliases(self): ["https://github.com/sclorg/betka/raw/main/examples/cfg/bot-cfg.yml"], ) def test_fetch_config(self, cfg_url): + urllib3.disable_warnings() c1 = config.fetch_config("betka", cfg_url) c2 = config.fetch_config("upstream-to-downstream", cfg_url) assert c1 == c2 diff --git a/tests/unit/test_gitlab.py b/tests/unit/test_gitlab.py index b033541..4fe9ff2 100644 --- a/tests/unit/test_gitlab.py +++ b/tests/unit/test_gitlab.py @@ -58,6 +58,8 @@ def betka_config(self): "gitlab_user": "foo_user", "downstream_master_msg": "[betka-master-sync]", "gitlab_api_token": "foobar", + "gitlab_namespace": "foo_namespace", + "dist_git_url": "https://src.fedoraproject.org/containers" } def setup_method(self): @@ -115,36 +117,35 @@ def test_mrs_one_valid(self): "host,namespace,image,branch,file,result_url", [ ( - "https://src.fedoraproject.org", + "https://src.fedoraproject.org/containers", "containers", "postgresql", "", "bot-cfg.yml", - "https://src.fedoraproject.org/containers/postgresql/-/raw//bot-cfg.yml", + "https://src.fedoraproject.org/containers/postgresql/plain/bot-cfg.yml?h=", ), ( - "https://src.fedoraproject.org", + "https://src.fedoraproject.org/containers", "containers", "postgresql", "master", "foo-bar.yaml", - "https://src.fedoraproject.org/containers/postgresql/-/raw/master/foo-bar.yaml", + "https://src.fedoraproject.org/containers/postgresql/plain/foo-bar.yaml?h=master", ), ( - "https://src.fedoraproject.org", + "https://src.fedoraproject.org/containers", "containers", "dummy-container", "f36", "foo-bar.yaml", - "https://src.fedoraproject.org/containers/dummy-container/-/raw/f36/foo-bar.yaml", + "https://src.fedoraproject.org/containers/dummy-container/plain/foo-bar.yaml?h=f36", ), ], ) def test_cfg_url(self, host, namespace, image, branch, file, result_url): - self.ga.config_json["gitlab_host_url"] = host + self.ga.config_json["dist_git_url"] = host self.ga.config_json["gitlab_namespace"] = namespace self.ga.image = image - assert result_url == self.ga.cfg_url(branch=branch, file=file) def test_valid_user(self): @@ -239,6 +240,7 @@ def test_gitlab_fork_valid(self): flexmock(self.ga).should_receive("get_project_forks").and_return( [gitlab_fork_exists()] ) + flexmock(self.ga).should_receive("load_forked_project").once() self.ga.image_config["project_id"] = PROJECT_ID self.ga.betka_config["gitlab_user"] = "foo_user" fork_exist = self.ga.get_gitlab_fork()