Skip to content

Commit

Permalink
Move local-project dir inside sandcastle subfolder (#2166)
Browse files Browse the repository at this point in the history
Move local-project dir inside sandcastle subfolder

We need both upstream and dowstream repos in sandcastle shared folder.
For this reason I need to move the upstream repo from the root to a subfolder.
Fixes #1956
Merge after packit/packit#2054

RELEASE NOTES BEGIN
Packit now sets PACKIT_UPSTREAM_REPO and PACKIT_DOWNSTREAM_REPO environment variables for release syncing actions. The variables represent paths where the respective git repositories are cloned
RELEASE NOTES END

Reviewed-by: Nikola Forró
Reviewed-by: Maja Massarini
Reviewed-by: Laura Barcziová
  • Loading branch information
softwarefactory-project-zuul[bot] authored Aug 31, 2023
2 parents badd457 + bcc1314 commit b7d6775
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
6 changes: 6 additions & 0 deletions packit_service/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,9 @@ def from_number(number: int):
f"You were denied from using Packit Service. If you think this was done by mistake, "
f"please, [let us know]({CONTACTS_URL})."
)

# We want to be able to access both
# upstream and downstream repos through the
# shared sandcastle dir
SANDCASTLE_DG_REPO_DIR = "dist-git"
SANDCASTLE_LOCAL_PROJECT_DIR = "local-project"
4 changes: 2 additions & 2 deletions packit_service/worker/handlers/distgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ def run(self) -> TaskResults:
)
finally:
# remove temporary dist-git clone after we're done here - context:
# 1. the dist-git repo is cloned on worker, not sandbox
# 2. it's stored in /tmp, not in the mirrored sandbox PV
# 1. the dist-git repo could be cloned on worker, not sandbox
# 2. in such case it's stored in /tmp, not in the mirrored sandbox PV
# 3. it's not being cleaned up and it wastes pod's filesystem space
shutil.rmtree(self.packit_api.dg.local_project.working_dir)

Expand Down
8 changes: 7 additions & 1 deletion packit_service/worker/mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from abc import abstractmethod
import logging
import re
from pathlib import Path
from typing import Optional, Protocol, Union, List

from fasjson_client import Client
Expand All @@ -27,6 +28,8 @@

from packit_service.constants import (
FASJSON_URL,
SANDCASTLE_LOCAL_PROJECT_DIR,
SANDCASTLE_DG_REPO_DIR,
)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -191,6 +194,8 @@ def packit_api(self):
self.service_config,
self.job_config,
upstream_local_project=self.local_project,
dist_git_clone_path=Path(self.service_config.command_handler_work_dir)
/ SANDCASTLE_DG_REPO_DIR,
)
return self._packit_api

Expand Down Expand Up @@ -219,7 +224,8 @@ class LocalProjectMixin(Config):
def local_project(self) -> LocalProject:
if not self._local_project:
kwargs = dict(
working_dir=self.service_config.command_handler_work_dir,
working_dir=Path(self.service_config.command_handler_work_dir)
/ SANDCASTLE_LOCAL_PROJECT_DIR,
cache=RepositoryCache(
cache_path=self.service_config.repository_cache,
add_new=self.service_config.add_repositories_to_repository_cache,
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/test_release_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@ def test_dist_git_push_release_handle_multiple_branches(
flexmock(Signature).should_receive("apply_async").once()
flexmock(Pushgateway).should_receive("push").times(3).and_return()

from packit_service.worker.handlers.distgit import shutil

flexmock(shutil).should_receive("rmtree").and_return()

processing_results = SteveJobs().process_message(github_release_webhook)
event_dict, job, job_config, package_config = get_parameters_from_results(
processing_results
Expand Down Expand Up @@ -466,6 +470,10 @@ def test_dist_git_push_release_handle_one_failed(
flexmock(Signature).should_receive("apply_async").once()
flexmock(Pushgateway).should_receive("push").times(3).and_return()

from packit_service.worker.handlers.distgit import shutil

flexmock(shutil).should_receive("rmtree").and_return()

processing_results = SteveJobs().process_message(github_release_webhook)
event_dict, job, job_config, package_config = get_parameters_from_results(
processing_results
Expand Down

0 comments on commit b7d6775

Please sign in to comment.