dycw-actions 0.8.5__py3-none-any.whl → 0.11.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- actions/__init__.py +1 -1
- actions/clean_dir/lib.py +5 -12
- actions/cli.py +18 -2
- actions/constants.py +2 -4
- actions/git_clone_with/__init__.py +1 -0
- actions/git_clone_with/cli.py +41 -0
- actions/git_clone_with/constants.py +7 -0
- actions/git_clone_with/lib.py +78 -0
- actions/git_clone_with/settings.py +20 -0
- actions/pre_commit/conformalize_repo/action_dicts.py +40 -41
- actions/pre_commit/conformalize_repo/cli.py +16 -3
- actions/pre_commit/conformalize_repo/constants.py +7 -3
- actions/pre_commit/conformalize_repo/lib.py +243 -163
- actions/pre_commit/conformalize_repo/settings.py +43 -11
- actions/pre_commit/constants.py +4 -1
- actions/pre_commit/format_requirements/lib.py +5 -10
- actions/pre_commit/replace_sequence_strs/lib.py +5 -10
- actions/pre_commit/touch_empty_py/lib.py +8 -14
- actions/pre_commit/touch_py_typed/lib.py +8 -13
- actions/pre_commit/update_requirements/lib.py +5 -11
- actions/pre_commit/utilities.py +83 -72
- actions/publish_package/lib.py +12 -16
- actions/random_sleep/cli.py +2 -2
- actions/random_sleep/lib.py +9 -18
- actions/register_gitea_runner/configs/entrypoint.sh +8 -8
- actions/register_gitea_runner/lib.py +23 -30
- actions/run_hooks/lib.py +11 -15
- actions/setup_cronjob/lib.py +16 -24
- actions/setup_ssh_config/__init__.py +1 -0
- actions/setup_ssh_config/cli.py +17 -0
- actions/setup_ssh_config/constants.py +7 -0
- actions/setup_ssh_config/lib.py +30 -0
- actions/tag_commit/lib.py +12 -16
- actions/utilities.py +7 -0
- {dycw_actions-0.8.5.dist-info → dycw_actions-0.11.3.dist-info}/METADATA +4 -3
- {dycw_actions-0.8.5.dist-info → dycw_actions-0.11.3.dist-info}/RECORD +38 -29
- {dycw_actions-0.8.5.dist-info → dycw_actions-0.11.3.dist-info}/WHEEL +1 -1
- {dycw_actions-0.8.5.dist-info → dycw_actions-0.11.3.dist-info}/entry_points.txt +0 -0
|
@@ -8,14 +8,22 @@ from actions.utilities import LOADER
|
|
|
8
8
|
|
|
9
9
|
@settings
|
|
10
10
|
class Settings:
|
|
11
|
-
|
|
11
|
+
ci__certificates: bool = option(
|
|
12
12
|
default=False, help="Update CA certficates before each step"
|
|
13
13
|
)
|
|
14
14
|
ci__gitea: bool = option(default=False, help="Set up CI on Gitea")
|
|
15
|
-
|
|
15
|
+
ci__token_checkout: Secret[str] | None = secret(
|
|
16
|
+
default=None, help="Set up CI with this checkout token"
|
|
17
|
+
)
|
|
18
|
+
ci__token_github: Secret[str] | None = secret(
|
|
19
|
+
default=None, help="Set up CI with this GitHub token"
|
|
20
|
+
)
|
|
16
21
|
ci__pull_request__pre_commit: bool = option(
|
|
17
22
|
default=False, help="Set up CI 'pull-request.yaml' pre-commit"
|
|
18
23
|
)
|
|
24
|
+
ci__pull_request__pre_commit__submodules: str | None = option(
|
|
25
|
+
default=None, help="Set up CI 'pull-request.yaml' pre-commit with submodules"
|
|
26
|
+
)
|
|
19
27
|
ci__pull_request__pyright: bool = option(
|
|
20
28
|
default=False, help="Set up CI 'pull-request.yaml' pyright"
|
|
21
29
|
)
|
|
@@ -28,24 +36,48 @@ class Settings:
|
|
|
28
36
|
ci__pull_request__pytest__windows: bool = option(
|
|
29
37
|
default=False, help="Set up CI 'pull-request.yaml' pytest with Windows"
|
|
30
38
|
)
|
|
31
|
-
|
|
39
|
+
ci__pull_request__pytest__all_versions: bool = option(
|
|
40
|
+
default=False, help="Set up CI 'pull-request.yaml' pytest with all versions"
|
|
41
|
+
)
|
|
42
|
+
ci__pull_request__pytest__sops_age_key: Secret[str] | None = secret(
|
|
32
43
|
default=None,
|
|
33
44
|
help="Set up CI 'pull-request.yaml' pytest with this 'age' key for 'sops'",
|
|
34
45
|
)
|
|
35
46
|
ci__pull_request__ruff: bool = option(
|
|
36
47
|
default=False, help="Set up CI 'pull-request.yaml' ruff"
|
|
37
48
|
)
|
|
38
|
-
|
|
39
|
-
default=False, help="Set up CI 'push.yaml' publishing"
|
|
49
|
+
ci__push__publish__github: bool = option(
|
|
50
|
+
default=False, help="Set up CI 'push.yaml' publishing to GitHub"
|
|
51
|
+
)
|
|
52
|
+
ci__push__publish__primary: bool = option(
|
|
53
|
+
default=False, help="Set up CI 'push.yaml' publishing #1"
|
|
54
|
+
)
|
|
55
|
+
ci__push__publish__primary__job_name: str = option(
|
|
56
|
+
default="pypi", help="Set up CI 'push.yaml' publishing #1 with this job name"
|
|
57
|
+
)
|
|
58
|
+
ci__push__publish__primary__username: str | None = option(
|
|
59
|
+
default=None, help="Set up CI 'push.yaml' publishing #1 with this username"
|
|
60
|
+
)
|
|
61
|
+
ci__push__publish__primary__password: Secret[str] | None = secret(
|
|
62
|
+
default=None, help="Set up CI 'push.yaml' publishing #1 with this password"
|
|
63
|
+
)
|
|
64
|
+
ci__push__publish__primary__publish_url: str | None = option(
|
|
65
|
+
default=None, help="Set up CI 'push.yaml' publishing #1 with this URL"
|
|
66
|
+
)
|
|
67
|
+
ci__push__publish__secondary: bool = option(
|
|
68
|
+
default=False, help="Set up CI 'push.yaml' publishing #2"
|
|
69
|
+
)
|
|
70
|
+
ci__push__publish__secondary__job_name: str = option(
|
|
71
|
+
default="pypi2", help="Set up CI 'push.yaml' publishing #2 with this job name"
|
|
40
72
|
)
|
|
41
|
-
|
|
42
|
-
default=None, help="Set up CI 'push.yaml' publishing with this username"
|
|
73
|
+
ci__push__publish__secondary__username: str | None = option(
|
|
74
|
+
default=None, help="Set up CI 'push.yaml' publishing #2 with this username"
|
|
43
75
|
)
|
|
44
|
-
|
|
45
|
-
default=None, help="Set up CI 'push.yaml' publishing with this password"
|
|
76
|
+
ci__push__publish__secondary__password: Secret[str] | None = secret(
|
|
77
|
+
default=None, help="Set up CI 'push.yaml' publishing #2 with this password"
|
|
46
78
|
)
|
|
47
|
-
|
|
48
|
-
default=None, help="Set up CI 'push.yaml' publishing with this URL"
|
|
79
|
+
ci__push__publish__secondary__publish_url: str | None = option(
|
|
80
|
+
default=None, help="Set up CI 'push.yaml' publishing #2 with this URL"
|
|
49
81
|
)
|
|
50
82
|
ci__push__tag: bool = option(default=False, help="Set up CI 'push.yaml' tagging")
|
|
51
83
|
ci__push__tag__all: bool = option(
|
actions/pre_commit/constants.py
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from utilities.whenever import HOUR
|
|
4
|
+
|
|
3
5
|
from actions.constants import PATH_ACTIONS
|
|
4
6
|
|
|
5
7
|
PATH_PRE_COMMIT = PATH_ACTIONS / "pre_commit"
|
|
8
|
+
THROTTLE_DELTA = 12 * HOUR
|
|
6
9
|
|
|
7
10
|
|
|
8
|
-
__all__ = ["PATH_PRE_COMMIT"]
|
|
11
|
+
__all__ = ["PATH_PRE_COMMIT", "THROTTLE_DELTA"]
|
|
@@ -3,7 +3,9 @@ from __future__ import annotations
|
|
|
3
3
|
import sys
|
|
4
4
|
from typing import TYPE_CHECKING
|
|
5
5
|
|
|
6
|
-
from utilities.
|
|
6
|
+
from utilities.functions import get_func_name
|
|
7
|
+
from utilities.tabulate import func_param_desc
|
|
8
|
+
from utilities.text import repr_str
|
|
7
9
|
|
|
8
10
|
from actions import __version__
|
|
9
11
|
from actions.logging import LOGGER
|
|
@@ -18,15 +20,7 @@ if TYPE_CHECKING:
|
|
|
18
20
|
|
|
19
21
|
|
|
20
22
|
def format_requirements(*paths: PathLike) -> None:
|
|
21
|
-
LOGGER.info(
|
|
22
|
-
strip_and_dedent("""
|
|
23
|
-
Running '%s' (version %s) with settings:
|
|
24
|
-
- paths = %s
|
|
25
|
-
"""),
|
|
26
|
-
format_requirements.__name__,
|
|
27
|
-
__version__,
|
|
28
|
-
paths,
|
|
29
|
-
)
|
|
23
|
+
LOGGER.info(func_param_desc(format_requirements, __version__, f"{paths=}"))
|
|
30
24
|
modifications: set[Path] = set()
|
|
31
25
|
for path in paths:
|
|
32
26
|
_format_path(path, modifications=modifications)
|
|
@@ -36,6 +30,7 @@ def format_requirements(*paths: PathLike) -> None:
|
|
|
36
30
|
", ".join(map(repr_str, sorted(modifications))),
|
|
37
31
|
)
|
|
38
32
|
sys.exit(1)
|
|
33
|
+
LOGGER.info("Finished running %r", get_func_name(format_requirements))
|
|
39
34
|
|
|
40
35
|
|
|
41
36
|
def _format_path(
|
|
@@ -10,7 +10,9 @@ from libcst.matchers import Subscript as MSubscript
|
|
|
10
10
|
from libcst.matchers import SubscriptElement as MSubscriptElement
|
|
11
11
|
from libcst.matchers import matches
|
|
12
12
|
from libcst.metadata import MetadataWrapper
|
|
13
|
-
from utilities.
|
|
13
|
+
from utilities.functions import get_func_name
|
|
14
|
+
from utilities.tabulate import func_param_desc
|
|
15
|
+
from utilities.text import repr_str
|
|
14
16
|
|
|
15
17
|
from actions import __version__
|
|
16
18
|
from actions.logging import LOGGER
|
|
@@ -24,15 +26,7 @@ if TYPE_CHECKING:
|
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
def replace_sequence_strs(*paths: PathLike) -> None:
|
|
27
|
-
LOGGER.info(
|
|
28
|
-
strip_and_dedent("""
|
|
29
|
-
Running '%s' (version %s) with settings:
|
|
30
|
-
- paths = %s
|
|
31
|
-
"""),
|
|
32
|
-
replace_sequence_strs.__name__,
|
|
33
|
-
__version__,
|
|
34
|
-
paths,
|
|
35
|
-
)
|
|
29
|
+
LOGGER.info(func_param_desc(replace_sequence_strs, __version__, f"{paths=}"))
|
|
36
30
|
modifications: set[Path] = set()
|
|
37
31
|
for path in paths:
|
|
38
32
|
_format_path(path, modifications=modifications)
|
|
@@ -42,6 +36,7 @@ def replace_sequence_strs(*paths: PathLike) -> None:
|
|
|
42
36
|
", ".join(map(repr_str, sorted(modifications))),
|
|
43
37
|
)
|
|
44
38
|
sys.exit(1)
|
|
39
|
+
LOGGER.info("Finished running %r", get_func_name(replace_sequence_strs))
|
|
45
40
|
|
|
46
41
|
|
|
47
42
|
def _format_path(
|
|
@@ -4,14 +4,15 @@ import sys
|
|
|
4
4
|
from typing import TYPE_CHECKING
|
|
5
5
|
|
|
6
6
|
from libcst import parse_statement
|
|
7
|
-
from utilities.
|
|
7
|
+
from utilities.functions import get_func_name
|
|
8
|
+
from utilities.tabulate import func_param_desc
|
|
9
|
+
from utilities.text import repr_str
|
|
8
10
|
from utilities.throttle import throttle
|
|
9
|
-
from utilities.whenever import HOUR
|
|
10
11
|
|
|
11
12
|
from actions import __version__
|
|
12
|
-
from actions.constants import PATH_THROTTLE_CACHE
|
|
13
13
|
from actions.logging import LOGGER
|
|
14
|
-
from actions.pre_commit.
|
|
14
|
+
from actions.pre_commit.constants import THROTTLE_DELTA
|
|
15
|
+
from actions.pre_commit.utilities import path_throttle_cache, yield_python_file
|
|
15
16
|
|
|
16
17
|
if TYPE_CHECKING:
|
|
17
18
|
from collections.abc import MutableSet
|
|
@@ -21,15 +22,7 @@ if TYPE_CHECKING:
|
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
def _touch_empty_py(*paths: PathLike) -> None:
|
|
24
|
-
LOGGER.info(
|
|
25
|
-
strip_and_dedent("""
|
|
26
|
-
Running '%s' (version %s) with settings:
|
|
27
|
-
- paths = %s
|
|
28
|
-
"""),
|
|
29
|
-
touch_empty_py.__name__,
|
|
30
|
-
__version__,
|
|
31
|
-
paths,
|
|
32
|
-
)
|
|
25
|
+
LOGGER.info(func_param_desc(touch_empty_py, __version__, f"{paths=}"))
|
|
33
26
|
modifications: set[Path] = set()
|
|
34
27
|
for path in paths:
|
|
35
28
|
_format_path(path, modifications=modifications)
|
|
@@ -39,10 +32,11 @@ def _touch_empty_py(*paths: PathLike) -> None:
|
|
|
39
32
|
", ".join(map(repr_str, sorted(modifications))),
|
|
40
33
|
)
|
|
41
34
|
sys.exit(1)
|
|
35
|
+
LOGGER.info("Finished running %r", get_func_name(touch_empty_py))
|
|
42
36
|
|
|
43
37
|
|
|
44
38
|
touch_empty_py = throttle(
|
|
45
|
-
delta=
|
|
39
|
+
delta=THROTTLE_DELTA, path=path_throttle_cache(_touch_empty_py)
|
|
46
40
|
)(_touch_empty_py)
|
|
47
41
|
|
|
48
42
|
|
|
@@ -4,14 +4,16 @@ import sys
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from typing import TYPE_CHECKING
|
|
6
6
|
|
|
7
|
+
from utilities.functions import get_func_name
|
|
7
8
|
from utilities.iterables import one
|
|
8
|
-
from utilities.
|
|
9
|
+
from utilities.tabulate import func_param_desc
|
|
10
|
+
from utilities.text import repr_str
|
|
9
11
|
from utilities.throttle import throttle
|
|
10
|
-
from utilities.whenever import HOUR
|
|
11
12
|
|
|
12
13
|
from actions import __version__
|
|
13
|
-
from actions.constants import PATH_THROTTLE_CACHE
|
|
14
14
|
from actions.logging import LOGGER
|
|
15
|
+
from actions.pre_commit.constants import THROTTLE_DELTA
|
|
16
|
+
from actions.pre_commit.utilities import path_throttle_cache
|
|
15
17
|
|
|
16
18
|
if TYPE_CHECKING:
|
|
17
19
|
from collections.abc import MutableSet
|
|
@@ -20,15 +22,7 @@ if TYPE_CHECKING:
|
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
def _touch_py_typed(*paths: PathLike) -> None:
|
|
23
|
-
LOGGER.info(
|
|
24
|
-
strip_and_dedent("""
|
|
25
|
-
Running '%s' (version %s) with settings:
|
|
26
|
-
- paths = %s
|
|
27
|
-
"""),
|
|
28
|
-
touch_py_typed.__name__,
|
|
29
|
-
__version__,
|
|
30
|
-
paths,
|
|
31
|
-
)
|
|
25
|
+
LOGGER.info(func_param_desc(touch_py_typed, __version__, f"{paths=}"))
|
|
32
26
|
modifications: set[Path] = set()
|
|
33
27
|
for path in paths:
|
|
34
28
|
_format_path(path, modifications=modifications)
|
|
@@ -38,10 +32,11 @@ def _touch_py_typed(*paths: PathLike) -> None:
|
|
|
38
32
|
", ".join(map(repr_str, sorted(modifications))),
|
|
39
33
|
)
|
|
40
34
|
sys.exit(1)
|
|
35
|
+
LOGGER.info("Finished running %r", get_func_name(touch_py_typed))
|
|
41
36
|
|
|
42
37
|
|
|
43
38
|
touch_py_typed = throttle(
|
|
44
|
-
delta=
|
|
39
|
+
delta=THROTTLE_DELTA, path=path_throttle_cache(_touch_py_typed)
|
|
45
40
|
)(_touch_py_typed)
|
|
46
41
|
|
|
47
42
|
|
|
@@ -5,8 +5,9 @@ from functools import partial
|
|
|
5
5
|
from typing import TYPE_CHECKING
|
|
6
6
|
|
|
7
7
|
from pydantic import TypeAdapter
|
|
8
|
-
from utilities.functions import max_nullable
|
|
9
|
-
from utilities.
|
|
8
|
+
from utilities.functions import get_func_name, max_nullable
|
|
9
|
+
from utilities.tabulate import func_param_desc
|
|
10
|
+
from utilities.text import repr_str
|
|
10
11
|
|
|
11
12
|
from actions import __version__
|
|
12
13
|
from actions.logging import LOGGER
|
|
@@ -33,15 +34,7 @@ if TYPE_CHECKING:
|
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
def update_requirements(*paths: PathLike) -> None:
|
|
36
|
-
LOGGER.info(
|
|
37
|
-
strip_and_dedent("""
|
|
38
|
-
Running '%s' (version %s) with settings:
|
|
39
|
-
- paths = %s
|
|
40
|
-
"""),
|
|
41
|
-
update_requirements.__name__,
|
|
42
|
-
__version__,
|
|
43
|
-
paths,
|
|
44
|
-
)
|
|
37
|
+
LOGGER.info(func_param_desc(update_requirements, __version__, f"{paths=}"))
|
|
45
38
|
modifications: set[Path] = set()
|
|
46
39
|
for path in paths:
|
|
47
40
|
_format_path(path, modifications=modifications)
|
|
@@ -51,6 +44,7 @@ def update_requirements(*paths: PathLike) -> None:
|
|
|
51
44
|
", ".join(map(repr_str, sorted(modifications))),
|
|
52
45
|
)
|
|
53
46
|
sys.exit(1)
|
|
47
|
+
LOGGER.info("Finished running %r", get_func_name(update_requirements))
|
|
54
48
|
|
|
55
49
|
|
|
56
50
|
def _format_path(
|
actions/pre_commit/utilities.py
CHANGED
|
@@ -12,12 +12,12 @@ from libcst import Module, parse_module
|
|
|
12
12
|
from rich.pretty import pretty_repr
|
|
13
13
|
from tomlkit import TOMLDocument, aot, array, document, string, table
|
|
14
14
|
from tomlkit.items import AoT, Array, Table
|
|
15
|
-
from utilities.functions import ensure_class, ensure_str
|
|
15
|
+
from utilities.functions import ensure_class, ensure_str, get_func_name
|
|
16
16
|
from utilities.iterables import OneEmptyError, OneNonUniqueError, one
|
|
17
17
|
from utilities.packaging import Requirement
|
|
18
18
|
from utilities.types import PathLike, StrDict
|
|
19
19
|
|
|
20
|
-
from actions.constants import YAML_INSTANCE
|
|
20
|
+
from actions.constants import PATH_CACHE, YAML_INSTANCE
|
|
21
21
|
from actions.logging import LOGGER
|
|
22
22
|
from actions.utilities import are_equal_modulo_new_line, write_text, yaml_dump
|
|
23
23
|
|
|
@@ -222,76 +222,10 @@ class PyProjectDependencies:
|
|
|
222
222
|
##
|
|
223
223
|
|
|
224
224
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
with yield_mutable_write_context(
|
|
230
|
-
path, json.loads, dict, json.dumps, modifications=modifications
|
|
231
|
-
) as dict_:
|
|
232
|
-
yield dict_
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
##
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
@contextmanager
|
|
239
|
-
def yield_python_file(
|
|
240
|
-
path: PathLike, /, *, modifications: MutableSet[Path] | None = None
|
|
241
|
-
) -> Iterator[WriteContext[Module]]:
|
|
242
|
-
with yield_immutable_write_context(
|
|
243
|
-
path,
|
|
244
|
-
parse_module,
|
|
245
|
-
lambda: Module(body=[]),
|
|
246
|
-
lambda module: module.code,
|
|
247
|
-
modifications=modifications,
|
|
248
|
-
) as context:
|
|
249
|
-
yield context
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
##
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
@contextmanager
|
|
256
|
-
def yield_text_file(
|
|
257
|
-
path: PathLike, /, *, modifications: MutableSet[Path] | None = None
|
|
258
|
-
) -> Iterator[WriteContext[str]]:
|
|
259
|
-
with yield_immutable_write_context(
|
|
260
|
-
path, str, lambda: "", str, modifications=modifications
|
|
261
|
-
) as context:
|
|
262
|
-
yield context
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
##
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
@contextmanager
|
|
269
|
-
def yield_toml_doc(
|
|
270
|
-
path: PathLike, /, *, modifications: MutableSet[Path] | None = None
|
|
271
|
-
) -> Iterator[TOMLDocument]:
|
|
272
|
-
with yield_mutable_write_context(
|
|
273
|
-
path, tomlkit.parse, document, tomlkit.dumps, modifications=modifications
|
|
274
|
-
) as doc:
|
|
275
|
-
yield doc
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
##
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
@contextmanager
|
|
282
|
-
def yield_mutable_write_context[T](
|
|
283
|
-
path: PathLike,
|
|
284
|
-
loads: Callable[[str], T],
|
|
285
|
-
get_default: Callable[[], T],
|
|
286
|
-
dumps: Callable[[T], str],
|
|
287
|
-
/,
|
|
288
|
-
*,
|
|
289
|
-
modifications: MutableSet[Path] | None = None,
|
|
290
|
-
) -> Iterator[T]:
|
|
291
|
-
with yield_immutable_write_context(
|
|
292
|
-
path, loads, get_default, dumps, modifications=modifications
|
|
293
|
-
) as context:
|
|
294
|
-
yield context.output
|
|
225
|
+
def path_throttle_cache(func: Callable[..., Any]) -> Path:
|
|
226
|
+
func_name = get_func_name(func)
|
|
227
|
+
cwd_name = Path.cwd().name
|
|
228
|
+
return PATH_CACHE / "throttle" / f"{func_name}--{cwd_name}"
|
|
295
229
|
|
|
296
230
|
|
|
297
231
|
##
|
|
@@ -348,6 +282,81 @@ def yield_immutable_write_context[T](
|
|
|
348
282
|
##
|
|
349
283
|
|
|
350
284
|
|
|
285
|
+
@contextmanager
|
|
286
|
+
def yield_json_dict(
|
|
287
|
+
path: PathLike, /, *, modifications: MutableSet[Path] | None = None
|
|
288
|
+
) -> Iterator[StrDict]:
|
|
289
|
+
with yield_mutable_write_context(
|
|
290
|
+
path, json.loads, dict, json.dumps, modifications=modifications
|
|
291
|
+
) as dict_:
|
|
292
|
+
yield dict_
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
##
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
@contextmanager
|
|
299
|
+
def yield_mutable_write_context[T](
|
|
300
|
+
path: PathLike,
|
|
301
|
+
loads: Callable[[str], T],
|
|
302
|
+
get_default: Callable[[], T],
|
|
303
|
+
dumps: Callable[[T], str],
|
|
304
|
+
/,
|
|
305
|
+
*,
|
|
306
|
+
modifications: MutableSet[Path] | None = None,
|
|
307
|
+
) -> Iterator[T]:
|
|
308
|
+
with yield_immutable_write_context(
|
|
309
|
+
path, loads, get_default, dumps, modifications=modifications
|
|
310
|
+
) as context:
|
|
311
|
+
yield context.output
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
##
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
@contextmanager
|
|
318
|
+
def yield_python_file(
|
|
319
|
+
path: PathLike, /, *, modifications: MutableSet[Path] | None = None
|
|
320
|
+
) -> Iterator[WriteContext[Module]]:
|
|
321
|
+
with yield_immutable_write_context(
|
|
322
|
+
path,
|
|
323
|
+
parse_module,
|
|
324
|
+
lambda: Module(body=[]),
|
|
325
|
+
lambda module: module.code,
|
|
326
|
+
modifications=modifications,
|
|
327
|
+
) as context:
|
|
328
|
+
yield context
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
##
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
@contextmanager
|
|
335
|
+
def yield_text_file(
|
|
336
|
+
path: PathLike, /, *, modifications: MutableSet[Path] | None = None
|
|
337
|
+
) -> Iterator[WriteContext[str]]:
|
|
338
|
+
with yield_immutable_write_context(
|
|
339
|
+
path, str, lambda: "", str, modifications=modifications
|
|
340
|
+
) as context:
|
|
341
|
+
yield context
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
##
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
@contextmanager
|
|
348
|
+
def yield_toml_doc(
|
|
349
|
+
path: PathLike, /, *, modifications: MutableSet[Path] | None = None
|
|
350
|
+
) -> Iterator[TOMLDocument]:
|
|
351
|
+
with yield_mutable_write_context(
|
|
352
|
+
path, tomlkit.parse, document, tomlkit.dumps, modifications=modifications
|
|
353
|
+
) as doc:
|
|
354
|
+
yield doc
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
##
|
|
358
|
+
|
|
359
|
+
|
|
351
360
|
@contextmanager
|
|
352
361
|
def yield_yaml_dict(
|
|
353
362
|
path: PathLike, /, *, modifications: MutableSet[Path] | None = None
|
|
@@ -360,6 +369,7 @@ def yield_yaml_dict(
|
|
|
360
369
|
|
|
361
370
|
__all__ = [
|
|
362
371
|
"PyProjectDependencies",
|
|
372
|
+
"WriteContext",
|
|
363
373
|
"ensure_aot_contains",
|
|
364
374
|
"ensure_contains",
|
|
365
375
|
"ensure_contains_partial_dict",
|
|
@@ -375,6 +385,7 @@ __all__ = [
|
|
|
375
385
|
"get_table",
|
|
376
386
|
"is_partial_dict",
|
|
377
387
|
"is_partial_str",
|
|
388
|
+
"path_throttle_cache",
|
|
378
389
|
"yield_immutable_write_context",
|
|
379
390
|
"yield_json_dict",
|
|
380
391
|
"yield_mutable_write_context",
|
actions/publish_package/lib.py
CHANGED
|
@@ -2,8 +2,9 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import TYPE_CHECKING
|
|
4
4
|
|
|
5
|
+
from utilities.functions import get_func_name
|
|
6
|
+
from utilities.tabulate import func_param_desc
|
|
5
7
|
from utilities.tempfile import TemporaryDirectory
|
|
6
|
-
from utilities.text import strip_and_dedent
|
|
7
8
|
|
|
8
9
|
from actions import __version__
|
|
9
10
|
from actions.logging import LOGGER
|
|
@@ -23,21 +24,15 @@ def publish_package(
|
|
|
23
24
|
native_tls: bool = SETTINGS.native_tls,
|
|
24
25
|
) -> None:
|
|
25
26
|
LOGGER.info(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
__version__,
|
|
36
|
-
username,
|
|
37
|
-
password,
|
|
38
|
-
publish_url,
|
|
39
|
-
trusted_publishing,
|
|
40
|
-
native_tls,
|
|
27
|
+
func_param_desc(
|
|
28
|
+
publish_package,
|
|
29
|
+
__version__,
|
|
30
|
+
f"{username=}",
|
|
31
|
+
f"{password=}",
|
|
32
|
+
f"{publish_url=}",
|
|
33
|
+
f"{trusted_publishing=}",
|
|
34
|
+
f"{native_tls=}",
|
|
35
|
+
)
|
|
41
36
|
)
|
|
42
37
|
with TemporaryDirectory() as temp:
|
|
43
38
|
logged_run("uv", "build", "--out-dir", str(temp), "--wheel", "--clear")
|
|
@@ -51,6 +46,7 @@ def publish_package(
|
|
|
51
46
|
*(["--native-tls"] if native_tls else []),
|
|
52
47
|
f"{temp}/*",
|
|
53
48
|
)
|
|
49
|
+
LOGGER.info("Finished running %r", get_func_name(publish_package))
|
|
54
50
|
|
|
55
51
|
|
|
56
52
|
__all__ = ["publish_package"]
|
actions/random_sleep/cli.py
CHANGED
|
@@ -16,8 +16,8 @@ def random_sleep_sub_cmd(settings: Settings, /) -> None:
|
|
|
16
16
|
return
|
|
17
17
|
basic_config(obj=LOGGER)
|
|
18
18
|
random_sleep(
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
min=settings.min,
|
|
20
|
+
max=settings.max,
|
|
21
21
|
step=settings.step,
|
|
22
22
|
log_freq=settings.log_freq,
|
|
23
23
|
)
|
actions/random_sleep/lib.py
CHANGED
|
@@ -4,7 +4,8 @@ from math import ceil, floor
|
|
|
4
4
|
from random import choice
|
|
5
5
|
from time import sleep
|
|
6
6
|
|
|
7
|
-
from utilities.
|
|
7
|
+
from utilities.functions import get_func_name
|
|
8
|
+
from utilities.tabulate import func_param_desc
|
|
8
9
|
from utilities.whenever import get_now
|
|
9
10
|
from whenever import TimeDelta, ZonedDateTime
|
|
10
11
|
|
|
@@ -15,33 +16,23 @@ from actions.random_sleep.settings import SETTINGS
|
|
|
15
16
|
|
|
16
17
|
def random_sleep(
|
|
17
18
|
*,
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
min: int = SETTINGS.min, # noqa: A002
|
|
20
|
+
max: int = SETTINGS.max, # noqa: A002
|
|
20
21
|
step: int = SETTINGS.step,
|
|
21
22
|
log_freq: int = SETTINGS.log_freq,
|
|
22
23
|
) -> None:
|
|
23
24
|
LOGGER.info(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- max_ = %s
|
|
28
|
-
- step = %s
|
|
29
|
-
- log_freq = %s
|
|
30
|
-
"""),
|
|
31
|
-
random_sleep.__name__,
|
|
32
|
-
__version__,
|
|
33
|
-
min_,
|
|
34
|
-
max_,
|
|
35
|
-
step,
|
|
36
|
-
log_freq,
|
|
25
|
+
func_param_desc(
|
|
26
|
+
random_sleep, __version__, f"{min=}", f"{max=}", f"{step=}", f"{log_freq=}"
|
|
27
|
+
)
|
|
37
28
|
)
|
|
38
29
|
start = get_now()
|
|
39
|
-
delta = TimeDelta(seconds=choice(range(
|
|
30
|
+
delta = TimeDelta(seconds=choice(range(min, max, step)))
|
|
40
31
|
LOGGER.info("Sleeping for %s...", delta)
|
|
41
32
|
end = (start + delta).round(mode="ceil")
|
|
42
33
|
while (now := get_now()) < end:
|
|
43
34
|
_intermediate(start, now, end, log_freq=log_freq)
|
|
44
|
-
LOGGER.info("Finished
|
|
35
|
+
LOGGER.info("Finished running %r", get_func_name(random_sleep))
|
|
45
36
|
|
|
46
37
|
|
|
47
38
|
def _intermediate(
|
|
@@ -6,16 +6,16 @@ echo_date() { echo "[$(date +'%Y-%m-%d %H:%M:%S')] $*" >&2; }
|
|
|
6
6
|
|
|
7
7
|
# main
|
|
8
8
|
wait-for-it.sh \
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
--host="${GITEA_HOST}" \
|
|
10
|
+
--port="${GITEA_PORT}" \
|
|
11
|
+
--strict \
|
|
12
|
+
-- \
|
|
13
|
+
echo "${GITEA_HOST}:${GITEA_PORT} is up"
|
|
14
14
|
|
|
15
15
|
if ! command -v update-ca-certificates >/dev/null 2>&1; then
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
echo_date "Installing 'ca-certificates'..."
|
|
17
|
+
apk update
|
|
18
|
+
apk add --no-cache ca-certificates
|
|
19
19
|
fi
|
|
20
20
|
|
|
21
21
|
update-ca-certificates || true
|