From 4824e4e9e550d1a78ac606016a8cac4c763a1f76 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Fri, 10 Oct 2025 15:25:38 +0200 Subject: [PATCH 1/9] No need for extra subfolder --- goth/runner/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/goth/runner/__init__.py b/goth/runner/__init__.py index 478b22cb..b632c9a0 100644 --- a/goth/runner/__init__.py +++ b/goth/runner/__init__.py @@ -113,8 +113,7 @@ def __init__( ): # Set up the logging directory for this runner self.test_name = test_name or self._current_pytest_test_name() or "" - date_str = datetime.now(tz=timezone.utc).strftime("%Y-%m-%d_%H-%M-%S") - self.log_dir = base_log_dir / self.test_name / date_str + self.log_dir = base_log_dir / self.test_name self.log_dir.mkdir(parents=True, exist_ok=True) self.api_assertions_module = api_assertions_module From f11d4f4d7972f0c67db088920dab7e17a6053a1a Mon Sep 17 00:00:00 2001 From: scx1332 Date: Fri, 10 Oct 2025 15:38:58 +0200 Subject: [PATCH 2/9] Asset cache local --- goth/runner/download/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/goth/runner/download/__init__.py b/goth/runner/download/__init__.py index 1b726be3..218e3550 100644 --- a/goth/runner/download/__init__.py +++ b/goth/runner/download/__init__.py @@ -18,7 +18,7 @@ ) logger = logging.getLogger(__name__) -ASSET_CACHE_DIR = Path(tempfile.gettempdir()) / "goth_asset_cache" +ASSET_CACHE_DIR = "asset_cache" ENV_API_TOKEN = "GITHUB_TOKEN" ENV_YAGNA_BRANCH = "YAGNA_BRANCH" From 584648a9de0b13100c35850d3463032174ef06fe Mon Sep 17 00:00:00 2001 From: scx1332 Date: Fri, 10 Oct 2025 15:41:46 +0200 Subject: [PATCH 3/9] Asset cache local --- goth/runner/download/__init__.py | 50 ++++++++++++++++---------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/goth/runner/download/__init__.py b/goth/runner/download/__init__.py index 218e3550..9ffdd131 100644 --- a/goth/runner/download/__init__.py +++ b/goth/runner/download/__init__.py @@ -18,7 +18,7 @@ ) logger = logging.getLogger(__name__) -ASSET_CACHE_DIR = "asset_cache" +ASSET_CACHE_DIR = Path("asset_cache") ENV_API_TOKEN = "GITHUB_TOKEN" ENV_YAGNA_BRANCH = "YAGNA_BRANCH" @@ -48,12 +48,12 @@ class GithubDownloader(ABC): """Session object for making HTTP requests.""" def __init__( - self, - owner: str = DEFAULT_OWNER, - purge_cache: bool = False, - repo: str = DEFAULT_REPO, - token: Optional[str] = DEFAULT_TOKEN, - verbose: bool = False, + self, + owner: str = DEFAULT_OWNER, + purge_cache: bool = False, + repo: str = DEFAULT_REPO, + token: Optional[str] = DEFAULT_TOKEN, + verbose: bool = False, ): if not token: raise ValueError("GitHub token was not provided.") @@ -112,7 +112,7 @@ def _get_workflow(self, workflow_name: str) -> dict: return workflow def _get_latest_run( - self, workflow: dict, branch: str, commit: Optional[str] = None + self, workflow: dict, branch: str, commit: Optional[str] = None ) -> Optional[dict]: """Filter out the latest successful workflow run.""" workflow_id = workflow["id"] @@ -191,12 +191,12 @@ def _download_artifact(self, artifact: dict) -> Path: return cache_dir def download( - self, - artifact_name: str = DEFAULT_ARTIFACT, - branch: str = DEFAULT_BRANCH, - commit: Optional[str] = DEFAULT_COMMIT, - output: Optional[Path] = None, - workflow_name: str = DEFAULT_WORKFLOW, + self, + artifact_name: str = DEFAULT_ARTIFACT, + branch: str = DEFAULT_BRANCH, + commit: Optional[str] = DEFAULT_COMMIT, + output: Optional[Path] = None, + workflow_name: str = DEFAULT_WORKFLOW, ) -> Path: """Download an artifact being the result of a given GitHub Actions workflow. @@ -253,10 +253,10 @@ def __init__(self, repo: str, *args, **kwargs): self.repo_name = repo def _get_latest_release( - self, - tag_substring: str, - content_type: str, - use_unstable: bool = True, + self, + tag_substring: str, + content_type: str, + use_unstable: bool = True, ) -> Optional[dict]: """Get the latest version, this includes pre-releases. @@ -303,7 +303,7 @@ def release_filter(release: dict, tag_substring: str) -> bool: return matching_release def _get_asset( - self, release: dict, content_type: str, asset_name: Optional[str] = None + self, release: dict, content_type: str, asset_name: Optional[str] = None ) -> Optional[dict]: assets = release["assets"] logger.debug("assets=%s", json.dumps(obj2dict(assets))) @@ -328,12 +328,12 @@ def _download_asset(self, asset: dict) -> Path: return cache_file def download( - self, - asset_name: str = "", - content_type: str = DEFAULT_CONTENT_TYPE, - output: Optional[Path] = None, - tag_substring: str = "", - use_unstable: bool = True, + self, + asset_name: str = "", + content_type: str = DEFAULT_CONTENT_TYPE, + output: Optional[Path] = None, + tag_substring: str = "", + use_unstable: bool = True, ) -> Path: """Download the latest release (or pre-release) from a given GitHub repo. From 43260fddaff56214d9bd7b4d2425415a2379621e Mon Sep 17 00:00:00 2001 From: scx1332 Date: Fri, 10 Oct 2025 15:46:50 +0200 Subject: [PATCH 4/9] Build docker directory fixed --- goth/runner/container/build.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/goth/runner/container/build.py b/goth/runner/container/build.py index 0bfccc31..d1cf5f23 100644 --- a/goth/runner/container/build.py +++ b/goth/runner/container/build.py @@ -13,7 +13,7 @@ from goth.runner.download import ( ArtifactDownloader, ReleaseDownloader, - ENV_API_TOKEN, + ENV_API_TOKEN, ASSET_CACHE_DIR, ) from goth.runner.process import run_command @@ -87,18 +87,20 @@ async def _build_docker_image( ) -> None: """Set up a temporary build directory and issue `docker build` command there.""" - with TemporaryDirectory() as temp_path: - build_dir = Path(temp_path) - setup_context(build_dir) + rnd_str = os.urandom(4).hex() + build_dir = ASSET_CACHE_DIR / "docker_build" / rnd_str + build_dir.mkdir(parents=True) - logger.info( - "Building %s Docker image. dockerfile=%s, build dir=%s", - image_name, - dockerfile, - build_dir, - ) - command = ["docker", "build", "-t", image_name, str(build_dir)] - await run_command(command) + setup_context(build_dir) + + logger.info( + "Building %s Docker image. dockerfile=%s, build dir=%s", + image_name, + dockerfile, + build_dir, + ) + command = ["docker", "build", "-t", image_name, str(build_dir)] + await run_command(command) async def build_proxy_image(docker_dir: Path) -> None: From 0054239b1024ecac2cb39ad15f87e3ed9af36f0a Mon Sep 17 00:00:00 2001 From: scx1332 Date: Fri, 10 Oct 2025 16:13:03 +0200 Subject: [PATCH 5/9] Build docker directory fixed --- .github/workflows/codestyle.yml | 2 +- goth/interactive.py | 6 ++-- goth/runner/container/build.py | 3 +- goth/runner/download/__init__.py | 50 ++++++++++++++++---------------- poetry.lock | 46 ++++++++++++++++++----------- pyproject.toml | 2 +- 6 files changed, 61 insertions(+), 48 deletions(-) diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml index 5784fd4b..803ce7f9 100644 --- a/.github/workflows/codestyle.yml +++ b/.github/workflows/codestyle.yml @@ -31,7 +31,7 @@ jobs: run: python3 .github/scripts/poetry_install.py --version 2.2.1 - name: Install dependencies - run: poetry install --no-root + run: poetry install - name: Run formatters in check mode run: poetry run poe checks_codestyle diff --git a/goth/interactive.py b/goth/interactive.py index eb8ae6a1..20561baf 100644 --- a/goth/interactive.py +++ b/goth/interactive.py @@ -2,20 +2,20 @@ import asyncio import logging from pathlib import Path -import tempfile from typing import Dict, Optional from goth.configuration import Configuration from goth.runner import Runner +from goth.runner.download import ASSET_CACHE_DIR from goth.runner.probe import ProviderProbe, RequestorProbe - logger = logging.getLogger(__name__) -env_file: Path = Path(tempfile.gettempdir()) / "goth_interactive.env" +env_file: Path = ASSET_CACHE_DIR / "goth_interactive.env" def _write_env_file(env: Dict[str, str]) -> None: + ASSET_CACHE_DIR.mkdir(parents=True, exist_ok=True) with env_file.open("w") as f: for key, val in env.items(): f.write(f"export {key}={val}\n") diff --git a/goth/runner/container/build.py b/goth/runner/container/build.py index d1cf5f23..5c403791 100644 --- a/goth/runner/container/build.py +++ b/goth/runner/container/build.py @@ -13,7 +13,8 @@ from goth.runner.download import ( ArtifactDownloader, ReleaseDownloader, - ENV_API_TOKEN, ASSET_CACHE_DIR, + ENV_API_TOKEN, + ASSET_CACHE_DIR, ) from goth.runner.process import run_command diff --git a/goth/runner/download/__init__.py b/goth/runner/download/__init__.py index 9ffdd131..5d4de1b2 100644 --- a/goth/runner/download/__init__.py +++ b/goth/runner/download/__init__.py @@ -18,7 +18,7 @@ ) logger = logging.getLogger(__name__) -ASSET_CACHE_DIR = Path("asset_cache") +ASSET_CACHE_DIR = Path("cache") ENV_API_TOKEN = "GITHUB_TOKEN" ENV_YAGNA_BRANCH = "YAGNA_BRANCH" @@ -48,12 +48,12 @@ class GithubDownloader(ABC): """Session object for making HTTP requests.""" def __init__( - self, - owner: str = DEFAULT_OWNER, - purge_cache: bool = False, - repo: str = DEFAULT_REPO, - token: Optional[str] = DEFAULT_TOKEN, - verbose: bool = False, + self, + owner: str = DEFAULT_OWNER, + purge_cache: bool = False, + repo: str = DEFAULT_REPO, + token: Optional[str] = DEFAULT_TOKEN, + verbose: bool = False, ): if not token: raise ValueError("GitHub token was not provided.") @@ -112,7 +112,7 @@ def _get_workflow(self, workflow_name: str) -> dict: return workflow def _get_latest_run( - self, workflow: dict, branch: str, commit: Optional[str] = None + self, workflow: dict, branch: str, commit: Optional[str] = None ) -> Optional[dict]: """Filter out the latest successful workflow run.""" workflow_id = workflow["id"] @@ -191,12 +191,12 @@ def _download_artifact(self, artifact: dict) -> Path: return cache_dir def download( - self, - artifact_name: str = DEFAULT_ARTIFACT, - branch: str = DEFAULT_BRANCH, - commit: Optional[str] = DEFAULT_COMMIT, - output: Optional[Path] = None, - workflow_name: str = DEFAULT_WORKFLOW, + self, + artifact_name: str = DEFAULT_ARTIFACT, + branch: str = DEFAULT_BRANCH, + commit: Optional[str] = DEFAULT_COMMIT, + output: Optional[Path] = None, + workflow_name: str = DEFAULT_WORKFLOW, ) -> Path: """Download an artifact being the result of a given GitHub Actions workflow. @@ -253,10 +253,10 @@ def __init__(self, repo: str, *args, **kwargs): self.repo_name = repo def _get_latest_release( - self, - tag_substring: str, - content_type: str, - use_unstable: bool = True, + self, + tag_substring: str, + content_type: str, + use_unstable: bool = True, ) -> Optional[dict]: """Get the latest version, this includes pre-releases. @@ -303,7 +303,7 @@ def release_filter(release: dict, tag_substring: str) -> bool: return matching_release def _get_asset( - self, release: dict, content_type: str, asset_name: Optional[str] = None + self, release: dict, content_type: str, asset_name: Optional[str] = None ) -> Optional[dict]: assets = release["assets"] logger.debug("assets=%s", json.dumps(obj2dict(assets))) @@ -328,12 +328,12 @@ def _download_asset(self, asset: dict) -> Path: return cache_file def download( - self, - asset_name: str = "", - content_type: str = DEFAULT_CONTENT_TYPE, - output: Optional[Path] = None, - tag_substring: str = "", - use_unstable: bool = True, + self, + asset_name: str = "", + content_type: str = DEFAULT_CONTENT_TYPE, + output: Optional[Path] = None, + tag_substring: str = "", + use_unstable: bool = True, ) -> Path: """Download the latest release (or pre-release) from a given GitHub repo. diff --git a/poetry.lock b/poetry.lock index 38a1ae05..0bbf1dda 100644 --- a/poetry.lock +++ b/poetry.lock @@ -210,36 +210,48 @@ files = [ [[package]] name = "black" -version = "22.12.0" +version = "24.10.0" description = "The uncompromising code formatter." optional = false -python-versions = ">=3.7" +python-versions = ">=3.9" groups = ["dev"] files = [ - {file = "black-22.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9eedd20838bd5d75b80c9f5487dbcb06836a43833a37846cf1d8c1cc01cef59d"}, - {file = "black-22.12.0-cp310-cp310-win_amd64.whl", hash = "sha256:159a46a4947f73387b4d83e87ea006dbb2337eab6c879620a3ba52699b1f4351"}, - {file = "black-22.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d30b212bffeb1e252b31dd269dfae69dd17e06d92b87ad26e23890f3efea366f"}, - {file = "black-22.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:7412e75863aa5c5411886804678b7d083c7c28421210180d67dfd8cf1221e1f4"}, - {file = "black-22.12.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c116eed0efb9ff870ded8b62fe9f28dd61ef6e9ddd28d83d7d264a38417dcee2"}, - {file = "black-22.12.0-cp37-cp37m-win_amd64.whl", hash = "sha256:1f58cbe16dfe8c12b7434e50ff889fa479072096d79f0a7f25e4ab8e94cd8350"}, - {file = "black-22.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:77d86c9f3db9b1bf6761244bc0b3572a546f5fe37917a044e02f3166d5aafa7d"}, - {file = "black-22.12.0-cp38-cp38-win_amd64.whl", hash = "sha256:82d9fe8fee3401e02e79767016b4907820a7dc28d70d137eb397b92ef3cc5bfc"}, - {file = "black-22.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:101c69b23df9b44247bd88e1d7e90154336ac4992502d4197bdac35dd7ee3320"}, - {file = "black-22.12.0-cp39-cp39-win_amd64.whl", hash = "sha256:559c7a1ba9a006226f09e4916060982fd27334ae1998e7a38b3f33a37f7a2148"}, - {file = "black-22.12.0-py3-none-any.whl", hash = "sha256:436cc9167dd28040ad90d3b404aec22cedf24a6e4d7de221bec2730ec0c97bcf"}, - {file = "black-22.12.0.tar.gz", hash = "sha256:229351e5a18ca30f447bf724d007f890f97e13af070bb6ad4c0a441cd7596a2f"}, + {file = "black-24.10.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e6668650ea4b685440857138e5fe40cde4d652633b1bdffc62933d0db4ed9812"}, + {file = "black-24.10.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:1c536fcf674217e87b8cc3657b81809d3c085d7bf3ef262ead700da345bfa6ea"}, + {file = "black-24.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:649fff99a20bd06c6f727d2a27f401331dc0cc861fb69cde910fe95b01b5928f"}, + {file = "black-24.10.0-cp310-cp310-win_amd64.whl", hash = "sha256:fe4d6476887de70546212c99ac9bd803d90b42fc4767f058a0baa895013fbb3e"}, + {file = "black-24.10.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:5a2221696a8224e335c28816a9d331a6c2ae15a2ee34ec857dcf3e45dbfa99ad"}, + {file = "black-24.10.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f9da3333530dbcecc1be13e69c250ed8dfa67f43c4005fb537bb426e19200d50"}, + {file = "black-24.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4007b1393d902b48b36958a216c20c4482f601569d19ed1df294a496eb366392"}, + {file = "black-24.10.0-cp311-cp311-win_amd64.whl", hash = "sha256:394d4ddc64782e51153eadcaaca95144ac4c35e27ef9b0a42e121ae7e57a9175"}, + {file = "black-24.10.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:b5e39e0fae001df40f95bd8cc36b9165c5e2ea88900167bddf258bacef9bbdc3"}, + {file = "black-24.10.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:d37d422772111794b26757c5b55a3eade028aa3fde43121ab7b673d050949d65"}, + {file = "black-24.10.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:14b3502784f09ce2443830e3133dacf2c0110d45191ed470ecb04d0f5f6fcb0f"}, + {file = "black-24.10.0-cp312-cp312-win_amd64.whl", hash = "sha256:30d2c30dc5139211dda799758559d1b049f7f14c580c409d6ad925b74a4208a8"}, + {file = "black-24.10.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:1cbacacb19e922a1d75ef2b6ccaefcd6e93a2c05ede32f06a21386a04cedb981"}, + {file = "black-24.10.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:1f93102e0c5bb3907451063e08b9876dbeac810e7da5a8bfb7aeb5a9ef89066b"}, + {file = "black-24.10.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ddacb691cdcdf77b96f549cf9591701d8db36b2f19519373d60d31746068dbf2"}, + {file = "black-24.10.0-cp313-cp313-win_amd64.whl", hash = "sha256:680359d932801c76d2e9c9068d05c6b107f2584b2a5b88831c83962eb9984c1b"}, + {file = "black-24.10.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:17374989640fbca88b6a448129cd1745c5eb8d9547b464f281b251dd00155ccd"}, + {file = "black-24.10.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:63f626344343083322233f175aaf372d326de8436f5928c042639a4afbbf1d3f"}, + {file = "black-24.10.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ccfa1d0cb6200857f1923b602f978386a3a2758a65b52e0950299ea014be6800"}, + {file = "black-24.10.0-cp39-cp39-win_amd64.whl", hash = "sha256:2cd9c95431d94adc56600710f8813ee27eea544dd118d45896bb734e9d7a0dc7"}, + {file = "black-24.10.0-py3-none-any.whl", hash = "sha256:3bb2b7a1f7b685f85b11fed1ef10f8a9148bceb49853e47a294a3dd963c1dd7d"}, + {file = "black-24.10.0.tar.gz", hash = "sha256:846ea64c97afe3bc677b761787993be4991810ecc7a4a937816dd6bddedc4875"}, ] [package.dependencies] click = ">=8.0.0" mypy-extensions = ">=0.4.3" +packaging = ">=22.0" pathspec = ">=0.9.0" platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_full_version < \"3.11.0a7\""} +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} [package.extras] colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)"] +d = ["aiohttp (>=3.10)"] jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] uvloop = ["uvloop (>=0.15.2)"] @@ -1782,4 +1794,4 @@ propcache = ">=0.2.1" [metadata] lock-version = "2.1" python-versions = "^3.10.1" -content-hash = "d92034d3f31b41c45caff288ee19944af345a470cf8dce320f8e967edd14765f" +content-hash = "a4a9e7d3a09821d1f8ca832055ca5b9224ebe1880342837ffdba6b397743cfd3" diff --git a/pyproject.toml b/pyproject.toml index 4bf72acd..717d30aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,7 @@ ya-tmp-pyapi = "=0.7.0" ghapi = "^1.0" [tool.poetry.group.dev.dependencies] -black = "^22.1" +black = "^24.10.0" flake8 = "^7.0" flake8-docstrings = "^1.7" flake8-pyproject = "^1.2" From 6d344fc95bc54067c90d28b3f90410551b60ec08 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Fri, 10 Oct 2025 16:22:42 +0200 Subject: [PATCH 6/9] fixes --- goth/runner/__init__.py | 1 - goth/runner/container/__init__.py | 4 ++-- goth/runner/container/build.py | 1 - goth/runner/container/compose.py | 9 +++++++-- goth/runner/log.py | 4 ++-- goth/runner/probe/mixin.py | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/goth/runner/__init__.py b/goth/runner/__init__.py index b632c9a0..8d24e7ef 100644 --- a/goth/runner/__init__.py +++ b/goth/runner/__init__.py @@ -2,7 +2,6 @@ import asyncio from contextlib import asynccontextmanager, AsyncExitStack -from datetime import datetime, timezone from itertools import chain import logging import os diff --git a/goth/runner/container/__init__.py b/goth/runner/container/__init__.py index 412e75dd..06845e36 100644 --- a/goth/runner/container/__init__.py +++ b/goth/runner/container/__init__.py @@ -1,7 +1,7 @@ """Classes and utilties to manage docker Containers.""" from dataclasses import dataclass, field -from datetime import datetime +from datetime import datetime, timezone from enum import Enum from pathlib import Path from typing import Callable, Dict, List, Optional @@ -205,7 +205,7 @@ def _restart(self): # using naive datetime object as `since` argument deliberately # see: https://github.com/docker/docker-py/issues/2712 self.logs.update_stream( - self._container.logs(stream=True, follow=True, since=datetime.utcnow()) + self._container.logs(stream=True, follow=True, since=datetime.now(timezone.utc)) ) def _update_state(self, *_args, **_kwargs): diff --git a/goth/runner/container/build.py b/goth/runner/container/build.py index 5c403791..ff8e8243 100644 --- a/goth/runner/container/build.py +++ b/goth/runner/container/build.py @@ -5,7 +5,6 @@ import os from pathlib import Path import shutil -from tempfile import TemporaryDirectory from typing import Callable, List, Optional, Dict from goth.project import PROJECT_ROOT diff --git a/goth/runner/container/compose.py b/goth/runner/container/compose.py index 9c4fbd82..b7b48b17 100644 --- a/goth/runner/container/compose.py +++ b/goth/runner/container/compose.py @@ -1,7 +1,7 @@ """Module responsible for parsing the docker-compose.yml used in the tests.""" import contextlib from dataclasses import dataclass -from datetime import datetime +from datetime import datetime, timezone import logging import os from pathlib import Path @@ -260,7 +260,12 @@ def _start_log_monitors(self, log_dir: Path) -> None: container = containers[0] monitor.start( - container.logs(follow=True, since=datetime.utcnow(), stream=True, timestamps=True) + container.logs( + follow=True, + since=datetime.now(timezone.utc), + stream=True, + timestamps=True, + ) ) self._log_monitors[service_name] = monitor diff --git a/goth/runner/log.py b/goth/runner/log.py index 8f4479b9..ec547e13 100644 --- a/goth/runner/log.py +++ b/goth/runner/log.py @@ -1,11 +1,11 @@ """Log utilities for the runner.""" import contextlib -import datetime import os from dataclasses import dataclass import logging import logging.config +from datetime import datetime, timezone from pathlib import Path import tempfile import time @@ -154,7 +154,7 @@ def configure_logging_for_test(test_log_dir: Path) -> None: proxy_handler.setFormatter(formatter) pyl_proxy_logger.addHandler(proxy_handler) pyl_proxy_logger.info( - "Proxy log started: {}".format(datetime.datetime.utcnow().isoformat()) + "Proxy log started: {}".format(datetime.now(timezone.utc).isoformat()) ) yield diff --git a/goth/runner/probe/mixin.py b/goth/runner/probe/mixin.py index fcca2dbe..6af54f20 100644 --- a/goth/runner/probe/mixin.py +++ b/goth/runner/probe/mixin.py @@ -150,7 +150,7 @@ async def counter_proposal( async def create_agreement(self: ProbeProtocol, proposal: Proposal) -> str: """Call create_agreement on the market api.""" - valid_to = str(datetime.utcnow() + timedelta(days=1)) + "Z" + valid_to = str(datetime.now(datetime.timezone.utc)() + timedelta(days=1)) + "Z" logger.debug( "Creating agreement, proposal_id=%s, valid_to=%s", proposal.proposal_id, From 524132902b037dadbf09c934dd2f48d4233b3c35 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Fri, 10 Oct 2025 17:46:55 +0200 Subject: [PATCH 7/9] f --- goth/__main__.py | 1 + goth/address.py | 1 + goth/assertions/common.py | 1 + goth/configuration.py | 1 + goth/interactive.py | 1 + goth/payment_config.py | 1 + goth/project.py | 1 + goth/runner/container/compose.py | 1 + goth/runner/container/utils.py | 1 + goth/runner/download/__init__.py | 1 + goth/runner/probe/agent.py | 1 + goth/runner/probe/rest_client.py | 1 + goth/runner/proxy.py | 1 + goth/runner/step.py | 1 + test/integration/test_payment_platform.py | 1 + test/integration/test_use_proxy.py | 1 + test/unit/assertions/test_assertions.py | 9 +++------ test/unit/assertions/test_monitor.py | 1 + test/unit/configuration/test_configuration.py | 1 + test/unit/runner/cli/test_command_runner.py | 1 + test/unit/runner/probe/test_probe.py | 1 + test/unit/runner/probe/test_run_command_on_host.py | 1 + 22 files changed, 24 insertions(+), 6 deletions(-) diff --git a/goth/__main__.py b/goth/__main__.py index 37b95d1e..72065b0d 100644 --- a/goth/__main__.py +++ b/goth/__main__.py @@ -1,4 +1,5 @@ """Main entry point to `goth`.""" + import argparse import asyncio from datetime import datetime, timezone diff --git a/goth/address.py b/goth/address.py index 8364b67e..d87efa4c 100644 --- a/goth/address.py +++ b/goth/address.py @@ -7,6 +7,7 @@ in the proxy container. If you rename any of them here then make sure to also apply the same renaming in `nginx.conf`. """ + from string import Template from typing import Dict, Mapping, Optional diff --git a/goth/assertions/common.py b/goth/assertions/common.py index 4c6cedd0..566d6f28 100644 --- a/goth/assertions/common.py +++ b/goth/assertions/common.py @@ -1,4 +1,5 @@ """Common assertions related to API calls.""" + from typing import Set from goth.api_monitor.api_events import ( diff --git a/goth/configuration.py b/goth/configuration.py index 17a27be9..9bb4777f 100644 --- a/goth/configuration.py +++ b/goth/configuration.py @@ -1,4 +1,5 @@ """Defines a class representing `goth` configuration.""" + from pathlib import Path from typing import Any, Dict, List, Optional, Tuple, Type, Union from dpath import MergeType diff --git a/goth/interactive.py b/goth/interactive.py index 20561baf..659f1d9f 100644 --- a/goth/interactive.py +++ b/goth/interactive.py @@ -1,4 +1,5 @@ """Interactive runner for `goth` network.""" + import asyncio import logging from pathlib import Path diff --git a/goth/payment_config.py b/goth/payment_config.py index 93b03a00..a6df8cd7 100644 --- a/goth/payment_config.py +++ b/goth/payment_config.py @@ -1,4 +1,5 @@ """All possible payment-related configuration, in one place.""" + from dataclasses import dataclass, field from typing import Dict diff --git a/goth/project.py b/goth/project.py index d998d5a5..38cc3482 100644 --- a/goth/project.py +++ b/goth/project.py @@ -1,4 +1,5 @@ """Module with information on the project itself, e.g. project root directory.""" + from pathlib import Path import goth diff --git a/goth/runner/container/compose.py b/goth/runner/container/compose.py index b7b48b17..1a65187c 100644 --- a/goth/runner/container/compose.py +++ b/goth/runner/container/compose.py @@ -1,4 +1,5 @@ """Module responsible for parsing the docker-compose.yml used in the tests.""" + import contextlib from dataclasses import dataclass from datetime import datetime, timezone diff --git a/goth/runner/container/utils.py b/goth/runner/container/utils.py index 7cd633f6..ff40078c 100755 --- a/goth/runner/container/utils.py +++ b/goth/runner/container/utils.py @@ -1,4 +1,5 @@ """Utilities related to Docker containers.""" + from pathlib import Path from typing import Dict, List, Tuple diff --git a/goth/runner/download/__init__.py b/goth/runner/download/__init__.py index 5d4de1b2..87b37337 100644 --- a/goth/runner/download/__init__.py +++ b/goth/runner/download/__init__.py @@ -1,4 +1,5 @@ """Package related to downloading assets necessary for building yagna images.""" + import time from abc import ABC import logging diff --git a/goth/runner/probe/agent.py b/goth/runner/probe/agent.py index d1f1c524..b398fc7f 100644 --- a/goth/runner/probe/agent.py +++ b/goth/runner/probe/agent.py @@ -1,4 +1,5 @@ """Module for agent components to be used with `Probe` objects.""" + import abc import logging from typing import Optional, TYPE_CHECKING diff --git a/goth/runner/probe/rest_client.py b/goth/runner/probe/rest_client.py index 05a80340..864951c9 100644 --- a/goth/runner/probe/rest_client.py +++ b/goth/runner/probe/rest_client.py @@ -1,4 +1,5 @@ """Module containing classes related to the yagna REST API client.""" + import dataclasses import logging from typing import TypeVar, TYPE_CHECKING diff --git a/goth/runner/proxy.py b/goth/runner/proxy.py index 31871c3f..64d85974 100644 --- a/goth/runner/proxy.py +++ b/goth/runner/proxy.py @@ -1,4 +1,5 @@ """A class for starting an embedded instance of mitmproxy.""" + import contextlib import logging from typing import AsyncIterator, Mapping, Optional diff --git a/goth/runner/step.py b/goth/runner/step.py index fae07516..573a2047 100644 --- a/goth/runner/step.py +++ b/goth/runner/step.py @@ -1,4 +1,5 @@ """A minimal runner implementation.""" + import asyncio import functools import logging diff --git a/test/integration/test_payment_platform.py b/test/integration/test_payment_platform.py index 579aa3c1..6c93b741 100644 --- a/test/integration/test_payment_platform.py +++ b/test/integration/test_payment_platform.py @@ -1,4 +1,5 @@ """Test if "payment_config" in `goth-config.yml` works as expected.""" + from pathlib import Path import pytest diff --git a/test/integration/test_use_proxy.py b/test/integration/test_use_proxy.py index 2216b8a0..f53d132c 100644 --- a/test/integration/test_use_proxy.py +++ b/test/integration/test_use_proxy.py @@ -1,4 +1,5 @@ """Integration test for agent-daemon communication through MITM proxy.""" + import asyncio from functools import partial from pathlib import Path diff --git a/test/unit/assertions/test_assertions.py b/test/unit/assertions/test_assertions.py index 80a2fac2..053031ca 100644 --- a/test/unit/assertions/test_assertions.py +++ b/test/unit/assertions/test_assertions.py @@ -529,17 +529,14 @@ async def toplevel(_stream): async def test_assertion_names(): """Test if assertion names are constructed correctly.""" - async def inner(_stream): - ... + async def inner(_stream): ... def make_assertion(_arg): - async def innermost(_stream): - ... + async def innermost(_stream): ... return innermost - async def parametrized(x, y, _stream): - ... + async def parametrized(x, y, _stream): ... a1 = Assertion(toplevel) assert a1.name == f"{__name__}.toplevel" diff --git a/test/unit/assertions/test_monitor.py b/test/unit/assertions/test_monitor.py index 97ed954b..8135f352 100644 --- a/test/unit/assertions/test_monitor.py +++ b/test/unit/assertions/test_monitor.py @@ -1,4 +1,5 @@ """Test the `assertions.monitor`.""" + import asyncio import pytest diff --git a/test/unit/configuration/test_configuration.py b/test/unit/configuration/test_configuration.py index 18033b00..7459b4e7 100644 --- a/test/unit/configuration/test_configuration.py +++ b/test/unit/configuration/test_configuration.py @@ -1,4 +1,5 @@ """Unit tests for `goth.configuration` module.""" + from pathlib import Path import pytest diff --git a/test/unit/runner/cli/test_command_runner.py b/test/unit/runner/cli/test_command_runner.py index 47c9020a..55c53869 100644 --- a/test/unit/runner/cli/test_command_runner.py +++ b/test/unit/runner/cli/test_command_runner.py @@ -4,6 +4,7 @@ - `runner.cli.base.DockerCommandRunner` - `runner.cli.base.DockerJSONCommandRunner` """ + import shlex import sys diff --git a/test/unit/runner/probe/test_probe.py b/test/unit/runner/probe/test_probe.py index 5fc7b703..743c6b0f 100644 --- a/test/unit/runner/probe/test_probe.py +++ b/test/unit/runner/probe/test_probe.py @@ -1,4 +1,5 @@ """Unit tests for the goth.runner.probe.Probe class.""" + import pytest from unittest.mock import MagicMock diff --git a/test/unit/runner/probe/test_run_command_on_host.py b/test/unit/runner/probe/test_run_command_on_host.py index de2a6303..c15e1996 100644 --- a/test/unit/runner/probe/test_run_command_on_host.py +++ b/test/unit/runner/probe/test_run_command_on_host.py @@ -1,4 +1,5 @@ """Tests for the method Probe.run_command_on_host.""" + import asyncio import os import sys From 074d7304fa7bbacf1e35d32afa80e8b76bd5cba5 Mon Sep 17 00:00:00 2001 From: scx1332 Date: Fri, 10 Oct 2025 17:53:15 +0200 Subject: [PATCH 8/9] fix timezone --- goth/__main__.py | 2 +- goth/runner/probe/mixin.py | 2 +- test/integration/conftest.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/goth/__main__.py b/goth/__main__.py index 72065b0d..07b56f03 100644 --- a/goth/__main__.py +++ b/goth/__main__.py @@ -21,7 +21,7 @@ def make_logs_dir(base_dir: Path) -> Path: """Create a unique subdirectory for this test run.""" - date_str = datetime.now(tz=timezone.utc).strftime("%Y-%m-%d_%H-%M-%S") + date_str = datetime.now(timezone.utc).strftime("%Y-%m-%d_%H-%M-%S") log_dir = base_dir / f"goth_{date_str}" log_dir.mkdir(parents=True) diff --git a/goth/runner/probe/mixin.py b/goth/runner/probe/mixin.py index 6af54f20..f1555c6c 100644 --- a/goth/runner/probe/mixin.py +++ b/goth/runner/probe/mixin.py @@ -150,7 +150,7 @@ async def counter_proposal( async def create_agreement(self: ProbeProtocol, proposal: Proposal) -> str: """Call create_agreement on the market api.""" - valid_to = str(datetime.now(datetime.timezone.utc)() + timedelta(days=1)) + "Z" + valid_to = str(datetime.now(timezone.utc) + timedelta(days=1)) + "Z" logger.debug( "Creating agreement, proposal_id=%s, valid_to=%s", proposal.proposal_id, diff --git a/test/integration/conftest.py b/test/integration/conftest.py index 04c6c624..5665083f 100644 --- a/test/integration/conftest.py +++ b/test/integration/conftest.py @@ -12,7 +12,7 @@ def log_dir() -> Path: """Return path to dir where goth test session logs should be placed.""" base_dir = Path("/", "tmp", "goth-tests") - date_str = datetime.now(tz=timezone.utc).strftime("%Y-%m-%d_%H-%M-%S") + date_str = datetime.now(timezone.utc).strftime("%Y-%m-%d_%H-%M-%S") log_dir = base_dir / f"goth_{date_str}" log_dir.mkdir(parents=True) configure_logging(log_dir) From 6394d13e4e8467e49ea5b547e78a6296c707c66b Mon Sep 17 00:00:00 2001 From: sieci Date: Fri, 10 Oct 2025 19:29:00 +0200 Subject: [PATCH 9/9] fix wrong date str --- goth/runner/probe/mixin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/goth/runner/probe/mixin.py b/goth/runner/probe/mixin.py index f1555c6c..873df7a0 100644 --- a/goth/runner/probe/mixin.py +++ b/goth/runner/probe/mixin.py @@ -150,7 +150,7 @@ async def counter_proposal( async def create_agreement(self: ProbeProtocol, proposal: Proposal) -> str: """Call create_agreement on the market api.""" - valid_to = str(datetime.now(timezone.utc) + timedelta(days=1)) + "Z" + valid_to = (datetime.now(timezone.utc) + timedelta(days=1)).isoformat() logger.debug( "Creating agreement, proposal_id=%s, valid_to=%s", proposal.proposal_id,