From b857c2544b1e9c7e9e3b0e27f491a16357dc25cc Mon Sep 17 00:00:00 2001 From: Iaroslav Popov Date: Tue, 26 Mar 2024 14:32:44 +0000 Subject: [PATCH 1/4] delay repo clone until we can choose branch --- softpack_core/artifacts.py | 27 +++++++++------- softpack_core/schemas/environment.py | 47 ++++++++++++++-------------- softpack_core/service.py | 17 ++++++++-- 3 files changed, 54 insertions(+), 37 deletions(-) diff --git a/softpack_core/artifacts.py b/softpack_core/artifacts.py index 30dc558..f9a2388 100644 --- a/softpack_core/artifacts.py +++ b/softpack_core/artifacts.py @@ -180,7 +180,6 @@ def __init__(self) -> None: self.ldap = LDAP() self.settings = app.settings - path = self.settings.artifacts.path.expanduser() / ".git" credentials = None try: credentials = pygit2.UserPass( @@ -194,10 +193,23 @@ def __init__(self) -> None: credentials=credentials ) - branch = self.settings.artifacts.repo.branch + @property + def signature(self) -> pygit2.Signature: + """Get current pygit2 commit signature: author/committer/timestamp.""" + # creating one of these implicitly looks up the current time. + return pygit2.Signature( + self.settings.artifacts.repo.author, + self.settings.artifacts.repo.email, + ) + + def clone_repo(self, branch: str = None): + if branch is None: + branch = self.settings.artifacts.repo.branch + if branch is None: branch = "main" + path = self.settings.artifacts.path.expanduser() / ".git" if path.is_dir(): shutil.rmtree(path) @@ -217,15 +229,6 @@ def __init__(self) -> None: ] ) - @property - def signature(self) -> pygit2.Signature: - """Get current pygit2 commit signature: author/committer/timestamp.""" - # creating one of these implicitly looks up the current time. - return pygit2.Signature( - self.settings.artifacts.repo.author, - self.settings.artifacts.repo.email, - ) - def user_folder(self, user: Optional[str] = None) -> Path: """Get the user folder for a given user. @@ -511,3 +514,5 @@ def delete_environment( new_tree = tree_builder.write() return self.build_tree(self.repo, root_tree, new_tree, full_path) + +artifacts = Artifacts() diff --git a/softpack_core/schemas/environment.py b/softpack_core/schemas/environment.py index 8e989d8..f5e56f1 100644 --- a/softpack_core/schemas/environment.py +++ b/softpack_core/schemas/environment.py @@ -21,7 +21,7 @@ from strawberry.file_uploads import Upload from softpack_core.app import app -from softpack_core.artifacts import Artifacts, Package, State, Type +from softpack_core.artifacts import artifacts, Artifacts, Package, State, Type from softpack_core.module import GenerateEnvReadme, ToSoftpackYML from softpack_core.schemas.base import BaseSchema @@ -306,7 +306,6 @@ class Environment: packages: list[Package] state: Optional[State] tags: list[str] - artifacts = Artifacts() requested: Optional[datetime.datetime] = None build_start: Optional[datetime.datetime] = None @@ -337,7 +336,7 @@ def iter(cls) -> list["Environment"]: except statistics.StatisticsError: avg_wait_secs = None - environment_folders = cls.artifacts.iter() + environment_folders = artifacts.iter() environment_objects = list( filter(None, map(cls.from_artifact, environment_folders)) ) @@ -488,7 +487,7 @@ def create_new_env( return input_err # Check if an env with same name already exists at given path - if cls.artifacts.get(Path(env.path), env.name): + if artifacts.get(Path(env.path), env.name): return EnvironmentAlreadyExistsError( message="This name is already used in this location", path=env.path, @@ -510,19 +509,19 @@ def create_new_env( meta = dict(tags=sorted(set(env.tags or []))) metaData = yaml.dump(meta) - tree_oid = cls.artifacts.create_files( + tree_oid = artifacts.create_files( new_folder_path, [ (env_type, ""), # e.g. .built_by_softpack ( - cls.artifacts.environments_file, + artifacts.environments_file, definitionData, ), # softpack.yml - (cls.artifacts.meta_file, metaData), + (artifacts.meta_file, metaData), ], True, ) - cls.artifacts.commit_and_push( + artifacts.commit_and_push( tree_oid, "create environment folder" ) except RuntimeError as e: @@ -546,7 +545,7 @@ def check_env_exists( Returns: Union[None, EnvironmentNotFoundError]: an error if env not found. """ - if cls.artifacts.get(path.parent, path.name): + if artifacts.get(path.parent, path.name): return None return EnvironmentNotFoundError( @@ -580,7 +579,7 @@ def add_tag( if (response := validate_tag(tag)) is not None: return response - tree = cls.artifacts.get(Path(path), name) + tree = artifacts.get(Path(path), name) if tree is None: return EnvironmentNotFoundError(path=path, name=name) box = tree.spec() @@ -590,10 +589,10 @@ def add_tag( tags.add(tag) metadata = yaml.dump({"tags": sorted(tags)}) - tree_oid = cls.artifacts.create_file( - environment_path, cls.artifacts.meta_file, metadata, overwrite=True + tree_oid = artifacts.create_file( + environment_path, artifacts.meta_file, metadata, overwrite=True ) - cls.artifacts.commit_and_push(tree_oid, "create environment folder") + artifacts.commit_and_push(tree_oid, "create environment folder") return AddTagSuccess(message="Tag successfully added") @classmethod @@ -607,9 +606,9 @@ def delete(cls, name: str, path: str) -> DeleteResponse: # type: ignore Returns: A message confirming the success or failure of the operation. """ - if cls.artifacts.get(Path(path), name): - tree_oid = cls.artifacts.delete_environment(name, path) - cls.artifacts.commit_and_push(tree_oid, "delete environment") + if artifacts.get(Path(path), name): + tree_oid = artifacts.delete_environment(name, path) + artifacts.commit_and_push(tree_oid, "delete environment") return DeleteEnvironmentSuccess( message="Successfully deleted the environment" ) @@ -690,13 +689,13 @@ async def convert_module_file_to_artifacts( readme = GenerateEnvReadme(module_path) module_file = UploadFile( - filename=cls.artifacts.module_file, file=io.BytesIO(contents) + filename=artifacts.module_file, file=io.BytesIO(contents) ) softpack_file = UploadFile( - filename=cls.artifacts.environments_file, file=io.BytesIO(yml) + filename=artifacts.environments_file, file=io.BytesIO(yml) ) readme_file = UploadFile( - filename=cls.artifacts.readme_file, file=io.BytesIO(readme) + filename=artifacts.readme_file, file=io.BytesIO(readme) ) return await cls.write_module_artifacts( @@ -729,9 +728,9 @@ async def write_module_artifacts( WriteArtifactResponse: contains message and commit hash of softpack.yml upload. """ - module_file.name = cls.artifacts.module_file - readme_file.name = cls.artifacts.readme_file - softpack_file.name = cls.artifacts.environments_file + module_file.name = artifacts.module_file + readme_file.name = artifacts.readme_file + softpack_file.name = artifacts.environments_file return await cls.write_artifacts( folder_path=environment_path, @@ -775,10 +774,10 @@ async def write_artifacts( (file.name, cast(str, (await file.read()).decode())) ) - tree_oid = cls.artifacts.create_files( + tree_oid = artifacts.create_files( Path(folder_path), new_files, overwrite=True ) - cls.artifacts.commit_and_push(tree_oid, "write artifact") + artifacts.commit_and_push(tree_oid, "write artifact") return WriteArtifactSuccess( message="Successfully written artifact(s)", ) diff --git a/softpack_core/service.py b/softpack_core/service.py index ff38101..050f115 100644 --- a/softpack_core/service.py +++ b/softpack_core/service.py @@ -14,7 +14,7 @@ from typer import Typer from typing_extensions import Annotated -from softpack_core.artifacts import State +from softpack_core.artifacts import State, artifacts from softpack_core.schemas.environment import ( CreateEnvironmentSuccess, Environment, @@ -43,16 +43,29 @@ def run( "--reload", help="Automatically reload when changes are detected.", ), - ] = False + ] = False, + branch: Annotated[ + str, + typer.Option( + "--branch", + help="Create and use this branch of Artefacts repo.", + ), + ] = 'main' ) -> None: """Start the SoftPack Core REST API service. Args: reload: Enable auto-reload. + branch: branch to use Returns: None. """ + if branch != 'main': + print(f'Changing branch to {branch}') + + artifacts.clone_repo(branch=branch) + uvicorn.run( "softpack_core.app:app.router", host=app.settings.server.host, From b256e49fbb4c6094a84c7aefce22a50366127263 Mon Sep 17 00:00:00 2001 From: Iaroslav Popov Date: Tue, 26 Mar 2024 15:06:41 +0000 Subject: [PATCH 2/4] create input branch --- softpack_core/artifacts.py | 17 +++++++++++++++++ softpack_core/service.py | 2 ++ 2 files changed, 19 insertions(+) diff --git a/softpack_core/artifacts.py b/softpack_core/artifacts.py index f9a2388..d77b4f8 100644 --- a/softpack_core/artifacts.py +++ b/softpack_core/artifacts.py @@ -10,6 +10,7 @@ from enum import Enum from pathlib import Path from typing import Iterable, Iterator, List, Optional, Tuple, Union +import tempfile import pygit2 import strawberry @@ -228,7 +229,23 @@ def clone_repo(self, branch: str = None): self.repo.head.shorthand, ] ) + + def create_remote_branch(self, branch: str): + temp_dir = tempfile.TemporaryDirectory() + + repo = pygit2.clone_repository( + self.settings.artifacts.repo.url, + path=temp_dir.name, + callbacks=self.credentials_callback, + bare=True + ) + + commit = repo.revparse_single('HEAD') + repo.create_branch(branch, commit) + remote = repo.remotes[0] + remote.push([f'refs/heads/{branch}'], callbacks=self.credentials_callback) + def user_folder(self, user: Optional[str] = None) -> Path: """Get the user folder for a given user. diff --git a/softpack_core/service.py b/softpack_core/service.py index 050f115..89c1c82 100644 --- a/softpack_core/service.py +++ b/softpack_core/service.py @@ -63,6 +63,8 @@ def run( """ if branch != 'main': print(f'Changing branch to {branch}') + # FIXME do only when branch does not exist + artifacts.create_remote_branch(branch) artifacts.clone_repo(branch=branch) From 46d7d9b2ba91b674093b61f75abff582dd0efcb6 Mon Sep 17 00:00:00 2001 From: Iaroslav Popov Date: Wed, 3 Apr 2024 14:38:14 +0100 Subject: [PATCH 3/4] fix tests --- softpack_core/artifacts.py | 32 +++++++++++------- softpack_core/schemas/environment.py | 6 ++-- softpack_core/service.py | 6 ++-- tests/integration/conftest.py | 4 +-- tests/integration/test_artifacts.py | 2 ++ tests/integration/test_builderupload.py | 11 ++++--- tests/integration/test_environment.py | 44 ++++++++++++------------- tests/integration/test_resend_builds.py | 3 +- tests/integration/utils.py | 16 ++++----- 9 files changed, 67 insertions(+), 57 deletions(-) diff --git a/softpack_core/artifacts.py b/softpack_core/artifacts.py index d77b4f8..ab2558c 100644 --- a/softpack_core/artifacts.py +++ b/softpack_core/artifacts.py @@ -6,11 +6,11 @@ import itertools import shutil +import tempfile from dataclasses import dataclass from enum import Enum from pathlib import Path from typing import Iterable, Iterator, List, Optional, Tuple, Union -import tempfile import pygit2 import strawberry @@ -202,8 +202,9 @@ def signature(self) -> pygit2.Signature: self.settings.artifacts.repo.author, self.settings.artifacts.repo.email, ) - - def clone_repo(self, branch: str = None): + + def clone_repo(self, branch: Optional[str] = None) -> None: + """Clone the specified branch (default main) to path in settings.""" if branch is None: branch = self.settings.artifacts.repo.branch @@ -229,23 +230,29 @@ def clone_repo(self, branch: str = None): self.repo.head.shorthand, ] ) - - def create_remote_branch(self, branch: str): + + def create_remote_branch(self, branch: str) -> None: + """Create a branch in remote if it doesn't exist yet.""" temp_dir = tempfile.TemporaryDirectory() repo = pygit2.clone_repository( self.settings.artifacts.repo.url, path=temp_dir.name, callbacks=self.credentials_callback, - bare=True + bare=True, ) - - commit = repo.revparse_single('HEAD') - repo.create_branch(branch, commit) - remote = repo.remotes[0] - remote.push([f'refs/heads/{branch}'], callbacks=self.credentials_callback) - + try: + repo.branches['origin/' + branch] + except KeyError: + commit = repo.revparse_single('HEAD') + repo.create_branch(branch, commit) + + remote = repo.remotes[0] + remote.push( + [f'refs/heads/{branch}'], callbacks=self.credentials_callback + ) + def user_folder(self, user: Optional[str] = None) -> Path: """Get the user folder for a given user. @@ -532,4 +539,5 @@ def delete_environment( return self.build_tree(self.repo, root_tree, new_tree, full_path) + artifacts = Artifacts() diff --git a/softpack_core/schemas/environment.py b/softpack_core/schemas/environment.py index f5e56f1..4421083 100644 --- a/softpack_core/schemas/environment.py +++ b/softpack_core/schemas/environment.py @@ -21,7 +21,7 @@ from strawberry.file_uploads import Upload from softpack_core.app import app -from softpack_core.artifacts import artifacts, Artifacts, Package, State, Type +from softpack_core.artifacts import Artifacts, Package, State, Type, artifacts from softpack_core.module import GenerateEnvReadme, ToSoftpackYML from softpack_core.schemas.base import BaseSchema @@ -521,9 +521,7 @@ def create_new_env( ], True, ) - artifacts.commit_and_push( - tree_oid, "create environment folder" - ) + artifacts.commit_and_push(tree_oid, "create environment folder") except RuntimeError as e: return InvalidInputError( message="".join(format_exception_only(type(e), e)) diff --git a/softpack_core/service.py b/softpack_core/service.py index 89c1c82..0b2dc42 100644 --- a/softpack_core/service.py +++ b/softpack_core/service.py @@ -50,7 +50,7 @@ def run( "--branch", help="Create and use this branch of Artefacts repo.", ), - ] = 'main' + ] = 'main', ) -> None: """Start the SoftPack Core REST API service. @@ -65,7 +65,7 @@ def run( print(f'Changing branch to {branch}') # FIXME do only when branch does not exist artifacts.create_remote_branch(branch) - + artifacts.clone_repo(branch=branch) uvicorn.run( @@ -98,7 +98,7 @@ async def upload_artifacts( # type: ignore[no-untyped-def] if Environment.check_env_exists(Path(env_path)) is not None: create_response = Environment.create_new_env( EnvironmentInput.from_path(env_path), - Environment.artifacts.built_by_softpack_file, + artifacts.built_by_softpack_file, ) if not isinstance(create_response, CreateEnvironmentSuccess): diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 56aee99..0cca742 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -9,7 +9,7 @@ import pytest from softpack_core.artifacts import Artifacts, Package, app -from softpack_core.schemas.environment import Environment, EnvironmentInput +from softpack_core.schemas.environment import EnvironmentInput from tests.integration.utils import ( get_user_path_without_environments, new_test_artifacts, @@ -48,7 +48,7 @@ def testable_env_input(mocker) -> EnvironmentInput: artifacts: Artifacts = ad["artifacts"] user = ad["test_user"] - mocker.patch.object(Environment, 'artifacts', new=artifacts) + # mocker.patch.object(Environment, 'artifacts', new=artifacts) testable_env_input = EnvironmentInput( name="test_env_create", diff --git a/tests/integration/test_artifacts.py b/tests/integration/test_artifacts.py index 6adf398..0f2484b 100644 --- a/tests/integration/test_artifacts.py +++ b/tests/integration/test_artifacts.py @@ -37,6 +37,7 @@ def test_clone() -> None: assert os.path.isdir(path) is False artifacts = Artifacts() + artifacts.clone_repo() assert os.path.isdir(path) is True orig_repo_path = app.settings.artifacts.path @@ -48,6 +49,7 @@ def test_clone() -> None: app.settings.artifacts.path = orig_repo_path artifacts = Artifacts() + artifacts.clone_repo() assert file_in_repo(artifacts, file_path) diff --git a/tests/integration/test_builderupload.py b/tests/integration/test_builderupload.py index a752b43..4063aac 100644 --- a/tests/integration/test_builderupload.py +++ b/tests/integration/test_builderupload.py @@ -10,6 +10,7 @@ from fastapi.testclient import TestClient from softpack_core.app import app +from softpack_core.artifacts import artifacts from softpack_core.schemas.environment import Environment from softpack_core.service import ServiceAPI from tests.integration.utils import file_in_repo @@ -43,15 +44,15 @@ def test_builder_upload(testable_env_input): assert resp.json().get("message") == "Successfully written artifact(s)" assert Environment.check_env_exists(Path(env_path)) is None assert file_in_repo( - Environment.artifacts, - Path(Environment.artifacts.environments_root, env_path, softpackYaml), + artifacts, + Path(artifacts.environments_root, env_path, softpackYaml), ) assert file_in_repo( - Environment.artifacts, - Path(Environment.artifacts.environments_root, env_path, spackLock), + artifacts, + Path(artifacts.environments_root, env_path, spackLock), ) - tree = Environment.artifacts.get(env_parent, env_name) + tree = artifacts.get(env_parent, env_name) assert tree is not None assert tree.get(softpackYaml).data == softpackYamlContents diff --git a/tests/integration/test_environment.py b/tests/integration/test_environment.py index d59fb5d..ca00fc3 100644 --- a/tests/integration/test_environment.py +++ b/tests/integration/test_environment.py @@ -14,7 +14,7 @@ import yaml from fastapi import UploadFile -from softpack_core.artifacts import Artifacts +from softpack_core.artifacts import Artifacts, artifacts from softpack_core.schemas.environment import ( AddTagSuccess, BuilderError, @@ -59,12 +59,12 @@ def test_create(httpx_post, testable_env_input: EnvironmentInput) -> None: httpx_post.assert_called() dir = Path( - Environment.artifacts.environments_root, + artifacts.environments_root, testable_env_input.path, testable_env_input.name + "-1", ) - builtPath = dir / Environment.artifacts.built_by_softpack_file - ymlPath = dir / Environment.artifacts.environments_file + builtPath = dir / artifacts.built_by_softpack_file + ymlPath = dir / artifacts.environments_file assert file_in_remote(builtPath) ymlFile = file_in_remote(ymlPath) expected_yaml = { @@ -72,18 +72,18 @@ def test_create(httpx_post, testable_env_input: EnvironmentInput) -> None: "packages": ["pkg_test"], } assert yaml.safe_load(ymlFile.data.decode()) == expected_yaml - meta_yml = file_in_remote(dir / Environment.artifacts.meta_file) + meta_yml = file_in_remote(dir / artifacts.meta_file) expected_meta_yml = {"tags": []} actual_meta_yml = yaml.safe_load(meta_yml.data.decode()) assert actual_meta_yml == expected_meta_yml dir = Path( - Environment.artifacts.environments_root, + artifacts.environments_root, "groups/not_already_in_repo", "test_env_create2-1", ) - builtPath = dir / Environment.artifacts.built_by_softpack_file - ymlPath = dir / Environment.artifacts.environments_file + builtPath = dir / artifacts.built_by_softpack_file + ymlPath = dir / artifacts.environments_file assert file_in_remote(builtPath) ymlFile = file_in_remote(ymlPath) expected_yaml = { @@ -92,7 +92,7 @@ def test_create(httpx_post, testable_env_input: EnvironmentInput) -> None: } assert yaml.safe_load(ymlFile.data.decode()) == expected_yaml - meta_yml = file_in_remote(dir / Environment.artifacts.meta_file) + meta_yml = file_in_remote(dir / artifacts.meta_file) expected_meta_yml = {"tags": ["bar", "foo"]} actual_meta_yml = yaml.safe_load(meta_yml.data.decode()) assert actual_meta_yml == expected_meta_yml @@ -102,10 +102,10 @@ def test_create(httpx_post, testable_env_input: EnvironmentInput) -> None: assert isinstance(result, CreateEnvironmentSuccess) path = Path( - Environment.artifacts.environments_root, + artifacts.environments_root, testable_env_input.path, testable_env_input.name + "-2", - Environment.artifacts.built_by_softpack_file, + artifacts.built_by_softpack_file, ) assert file_in_remote(path) @@ -174,12 +174,12 @@ def test_create_does_not_clean_up_after_builder_failure( assert isinstance(result, BuilderError) dir = Path( - Environment.artifacts.environments_root, + artifacts.environments_root, testable_env_input.path, testable_env_input.name, ) - builtPath = dir / Environment.artifacts.built_by_softpack_file - ymlPath = dir / Environment.artifacts.environments_file + builtPath = dir / artifacts.built_by_softpack_file + ymlPath = dir / artifacts.environments_file assert file_in_remote(builtPath) assert file_in_remote(ymlPath) @@ -195,7 +195,7 @@ def test_delete(httpx_post, testable_env_input) -> None: httpx_post.assert_called_once() path = Path( - Environment.artifacts.environments_root, + artifacts.environments_root, testable_env_input.path, testable_env_input.name, Artifacts.built_by_softpack_file, @@ -235,7 +235,7 @@ async def test_write_artifact(httpx_post, testable_env_input): assert isinstance(result, WriteArtifactSuccess) path = Path( - Environment.artifacts.environments_root, + artifacts.environments_root, testable_env_input.path, testable_env_input.name + "-1", upload.filename, @@ -418,23 +418,23 @@ async def test_create_from_module(httpx_post, testable_env_input): assert isinstance(result, EnvironmentAlreadyExistsError) parent_path = Path( - Environment.artifacts.group_folder(), + artifacts.group_folder(), "hgi", env_name, ) - readme_path = Path(parent_path, Environment.artifacts.readme_file) + readme_path = Path(parent_path, artifacts.readme_file) assert file_in_remote( - Path(parent_path, Environment.artifacts.environments_file), - Path(parent_path, Environment.artifacts.module_file), + Path(parent_path, artifacts.environments_file), + Path(parent_path, artifacts.module_file), readme_path, - Path(parent_path, Environment.artifacts.generated_from_module_file), + Path(parent_path, artifacts.generated_from_module_file), ) with open(test_files_dir / "shpc.readme", "rb") as fh: expected_readme_data = fh.read() - tree = Environment.artifacts.repo.head.peel(pygit2.Tree) + tree = artifacts.repo.head.peel(pygit2.Tree) obj = tree[str(readme_path)] assert obj is not None assert obj.data == expected_readme_data diff --git a/tests/integration/test_resend_builds.py b/tests/integration/test_resend_builds.py index bfe76c5..e8d2a54 100644 --- a/tests/integration/test_resend_builds.py +++ b/tests/integration/test_resend_builds.py @@ -9,6 +9,7 @@ from fastapi.testclient import TestClient from softpack_core.app import app +from softpack_core.artifacts import artifacts from softpack_core.schemas.environment import ( CreateEnvironmentSuccess, Environment, @@ -31,7 +32,7 @@ def test_resend_pending_builds( orig_name = testable_env_input.name testable_env_input.name += "-1" r = Environment.create_new_env( - testable_env_input, Environment.artifacts.built_by_softpack_file + testable_env_input, artifacts.built_by_softpack_file ) assert isinstance(r, CreateEnvironmentSuccess) testable_env_input.name = orig_name diff --git a/tests/integration/utils.py b/tests/integration/utils.py index 31b2e16..dc008b4 100644 --- a/tests/integration/utils.py +++ b/tests/integration/utils.py @@ -11,7 +11,7 @@ import pygit2 import pytest -from softpack_core.artifacts import Artifacts, app +from softpack_core.artifacts import Artifacts, app, artifacts from softpack_core.schemas.environment import EnvironmentInput artifacts_dict = dict[ @@ -21,15 +21,9 @@ def new_test_artifacts() -> artifacts_dict: - temp_dir = tempfile.TemporaryDirectory() - app.settings.artifacts.path = Path(temp_dir.name) - - artifacts = Artifacts() - branch_name = app.settings.artifacts.repo.branch - branch = artifacts.repo.branches.get(branch_name) - if branch is None or branch_name == "main": + if branch_name == "" or branch_name == "main": pytest.skip( ( "Your artifacts repo must have a branch named after your " @@ -37,6 +31,11 @@ def new_test_artifacts() -> artifacts_dict: ) ) + temp_dir = tempfile.TemporaryDirectory() + app.settings.artifacts.path = Path(temp_dir.name) + artifacts.create_remote_branch(branch_name) + artifacts.clone_repo(branch=branch_name) + dict = reset_test_repo(artifacts) dict["temp_dir"] = temp_dir dict["artifacts"] = artifacts @@ -178,6 +177,7 @@ def file_in_remote( temp_dir = tempfile.TemporaryDirectory() app.settings.artifacts.path = Path(temp_dir.name) artifacts = Artifacts() + artifacts.clone_repo() file = None for path_with_environment in paths_with_environment: From d4252c48d1fd34a9cd5c85b8ef0ab156d198b7df Mon Sep 17 00:00:00 2001 From: Iaroslav Popov Date: Wed, 3 Apr 2024 14:38:30 +0100 Subject: [PATCH 4/4] add usage to README --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 2ab81d6..01cae04 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,20 @@ poetry run strawberry export-schema softpack_core.graphql:GraphQL.schema > schem [Tox]: https://tox.wiki [MkDocs]: https://www.mkdocs.org +## Usage + +To start a server in production: + +```bash +softpack-core service run +``` + +To run a server to test softpack-web: + +```bash +softpack-core service run --branch +``` + ## Credits This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [altaf-ali/cookiecutter-pypackage](https://altaf-ali.github.io/cookiecutter-pypackage) project template.