dycw-actions 0.6.4__py3-none-any.whl → 0.7.7__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.
Files changed (73) hide show
  1. actions/__init__.py +1 -1
  2. actions/action_dicts/lib.py +8 -8
  3. actions/clean_dir/cli.py +0 -12
  4. actions/clean_dir/constants.py +7 -0
  5. actions/clean_dir/lib.py +1 -0
  6. actions/cli.py +90 -29
  7. actions/constants.py +5 -1
  8. actions/pre_commit/click.py +15 -0
  9. actions/{conformalize_repo → pre_commit/conformalize_repo}/cli.py +2 -14
  10. actions/{conformalize_repo → pre_commit/conformalize_repo}/constants.py +8 -2
  11. actions/{conformalize_repo → pre_commit/conformalize_repo}/lib.py +97 -313
  12. actions/{conformalize_repo → pre_commit/conformalize_repo}/settings.py +1 -1
  13. actions/pre_commit/constants.py +8 -0
  14. actions/pre_commit/format_requirements/cli.py +24 -0
  15. actions/pre_commit/format_requirements/constants.py +7 -0
  16. actions/pre_commit/format_requirements/lib.py +52 -0
  17. actions/pre_commit/replace_sequence_strs/__init__.py +1 -0
  18. actions/pre_commit/replace_sequence_strs/cli.py +24 -0
  19. actions/pre_commit/replace_sequence_strs/constants.py +7 -0
  20. actions/{replace_sequence_strs → pre_commit/replace_sequence_strs}/lib.py +16 -22
  21. actions/pre_commit/touch_empty_py/__init__.py +1 -0
  22. actions/pre_commit/touch_empty_py/cli.py +24 -0
  23. actions/pre_commit/touch_empty_py/constants.py +7 -0
  24. actions/pre_commit/touch_empty_py/lib.py +62 -0
  25. actions/pre_commit/touch_py_typed/__init__.py +1 -0
  26. actions/pre_commit/touch_py_typed/cli.py +24 -0
  27. actions/pre_commit/touch_py_typed/constants.py +7 -0
  28. actions/pre_commit/touch_py_typed/lib.py +72 -0
  29. actions/pre_commit/update_requirements/__init__.py +1 -0
  30. actions/pre_commit/update_requirements/classes.py +130 -0
  31. actions/pre_commit/update_requirements/cli.py +24 -0
  32. actions/pre_commit/update_requirements/constants.py +7 -0
  33. actions/pre_commit/update_requirements/lib.py +140 -0
  34. actions/pre_commit/utilities.py +386 -0
  35. actions/publish_package/cli.py +7 -19
  36. actions/publish_package/constants.py +7 -0
  37. actions/publish_package/lib.py +3 -3
  38. actions/py.typed +0 -0
  39. actions/random_sleep/cli.py +6 -15
  40. actions/random_sleep/constants.py +7 -0
  41. actions/register_gitea_runner/__init__.py +1 -0
  42. actions/register_gitea_runner/cli.py +32 -0
  43. actions/register_gitea_runner/configs/config.yml +110 -0
  44. actions/register_gitea_runner/configs/entrypoint.sh +23 -0
  45. actions/register_gitea_runner/constants.py +23 -0
  46. actions/register_gitea_runner/lib.py +289 -0
  47. actions/register_gitea_runner/settings.py +33 -0
  48. actions/run_hooks/cli.py +3 -15
  49. actions/run_hooks/constants.py +7 -0
  50. actions/run_hooks/lib.py +2 -2
  51. actions/setup_cronjob/cli.py +0 -12
  52. actions/setup_cronjob/constants.py +5 -1
  53. actions/tag_commit/cli.py +7 -19
  54. actions/tag_commit/constants.py +7 -0
  55. actions/tag_commit/lib.py +8 -8
  56. actions/types.py +4 -1
  57. actions/utilities.py +68 -14
  58. {dycw_actions-0.6.4.dist-info → dycw_actions-0.7.7.dist-info}/METADATA +5 -3
  59. dycw_actions-0.7.7.dist-info/RECORD +84 -0
  60. actions/format_requirements/cli.py +0 -37
  61. actions/format_requirements/lib.py +0 -121
  62. actions/publish_package/doc.py +0 -6
  63. actions/random_sleep/doc.py +0 -6
  64. actions/replace_sequence_strs/cli.py +0 -37
  65. actions/run_hooks/doc.py +0 -6
  66. actions/tag_commit/doc.py +0 -6
  67. dycw_actions-0.6.4.dist-info/RECORD +0 -56
  68. /actions/{conformalize_repo → pre_commit}/__init__.py +0 -0
  69. /actions/{format_requirements → pre_commit/conformalize_repo}/__init__.py +0 -0
  70. /actions/{conformalize_repo → pre_commit/conformalize_repo}/configs/gitignore +0 -0
  71. /actions/{replace_sequence_strs → pre_commit/format_requirements}/__init__.py +0 -0
  72. {dycw_actions-0.6.4.dist-info → dycw_actions-0.7.7.dist-info}/WHEEL +0 -0
  73. {dycw_actions-0.6.4.dist-info → dycw_actions-0.7.7.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,23 @@
1
+ from __future__ import annotations
2
+
3
+ import actions.constants
4
+ from actions.constants import PATH_ACTIONS
5
+
6
+ REGISTER_GITEA_RUNNER_SUB_CMD = "register-gitea-runner"
7
+ REGISTER_GITEA_RUNNER_DOCSTRING = "Register a Gitea runner"
8
+
9
+
10
+ PATH_CACHE = actions.constants.PATH_CACHE / REGISTER_GITEA_RUNNER_SUB_CMD
11
+ PATH_CONFIGS = PATH_ACTIONS / "register_gitea_runner/configs"
12
+ PATH_WAIT_FOR_IT = PATH_CACHE / "wait-for-it.sh"
13
+ URL_WAIT_FOR_IT = "https://raw.githubusercontent.com/vishnubob/wait-for-it/refs/heads/master/wait-for-it.sh"
14
+
15
+
16
+ __all__ = [
17
+ "PATH_CACHE",
18
+ "PATH_CONFIGS",
19
+ "PATH_WAIT_FOR_IT",
20
+ "REGISTER_GITEA_RUNNER_DOCSTRING",
21
+ "REGISTER_GITEA_RUNNER_SUB_CMD",
22
+ "URL_WAIT_FOR_IT",
23
+ ]
@@ -0,0 +1,289 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+ from re import search
5
+ from string import Template
6
+ from typing import TYPE_CHECKING
7
+
8
+ from requests import get
9
+ from utilities.atomicwrites import writer
10
+ from utilities.subprocess import chmod, run, ssh
11
+ from utilities.text import strip_and_dedent
12
+
13
+ from actions import __version__
14
+ from actions.logging import LOGGER
15
+ from actions.register_gitea_runner.constants import (
16
+ PATH_CACHE,
17
+ PATH_CONFIGS,
18
+ PATH_WAIT_FOR_IT,
19
+ URL_WAIT_FOR_IT,
20
+ )
21
+ from actions.register_gitea_runner.settings import SETTINGS
22
+
23
+ if TYPE_CHECKING:
24
+ from utilities.types import PathLike
25
+
26
+
27
+ def register_gitea_runner(
28
+ *,
29
+ ssh_user: str = SETTINGS.ssh_user,
30
+ ssh_host: str = SETTINGS.ssh_host,
31
+ gitea_container_user: str = SETTINGS.gitea_container_user,
32
+ gitea_container_name: str = SETTINGS.gitea_container_name,
33
+ runner_certificate: PathLike = SETTINGS.runner_certificate,
34
+ runner_capacity: int = SETTINGS.runner_capacity,
35
+ runner_container_name: str = SETTINGS.runner_container_name,
36
+ gitea_host: str = SETTINGS.gitea_host,
37
+ gitea_port: int = SETTINGS.gitea_port,
38
+ runner_instance_name: str = SETTINGS.runner_instance_name,
39
+ ) -> None:
40
+ """Register against a remote instance of Gitea."""
41
+ LOGGER.info(
42
+ strip_and_dedent("""
43
+ Running '%s' (version %s) with settings:
44
+ - ssh_user = %s
45
+ - ssh_host = %s
46
+ - gitea_container_user = %s
47
+ - gitea_container_name = %s
48
+ - runner_certificate = %s
49
+ - runner_capacity = %d
50
+ - runner_container_name = %s
51
+ - gitea_host = %s
52
+ - gitea_port = %d
53
+ - runner_instance_name = %s
54
+ """),
55
+ register_gitea_runner.__name__,
56
+ __version__,
57
+ ssh_user,
58
+ ssh_host,
59
+ gitea_container_user,
60
+ gitea_container_name,
61
+ runner_certificate,
62
+ runner_capacity,
63
+ runner_container_name,
64
+ gitea_host,
65
+ gitea_port,
66
+ runner_instance_name,
67
+ )
68
+ token = ssh(
69
+ ssh_user,
70
+ ssh_host,
71
+ *_docker_exec_generate(user=gitea_container_user, name=gitea_container_name),
72
+ return_=True,
73
+ )
74
+ _start_runner(
75
+ token,
76
+ runner_certificate=runner_certificate,
77
+ runner_capacity=runner_capacity,
78
+ runner_container_name=runner_container_name,
79
+ gitea_host=gitea_host,
80
+ gitea_port=gitea_port,
81
+ runner_instance_name=runner_instance_name,
82
+ )
83
+
84
+
85
+ def register_against_local(
86
+ *,
87
+ gitea_container_user: str = SETTINGS.gitea_container_user,
88
+ gitea_container_name: str = SETTINGS.gitea_container_name,
89
+ runner_certificate: PathLike = SETTINGS.runner_certificate,
90
+ runner_capacity: int = SETTINGS.runner_capacity,
91
+ runner_container_name: str = SETTINGS.runner_container_name,
92
+ gitea_host: str = SETTINGS.gitea_host,
93
+ gitea_port: int = SETTINGS.gitea_port,
94
+ runner_instance_name: str = SETTINGS.runner_instance_name,
95
+ ) -> None:
96
+ """Register against a local instance of Gitea."""
97
+ LOGGER.info("Registering against %s:%d...", gitea_host, gitea_port)
98
+ token = run(
99
+ *_docker_exec_generate(user=gitea_container_user, name=gitea_container_name),
100
+ return_=True,
101
+ logger=LOGGER,
102
+ )
103
+ _start_runner(
104
+ token,
105
+ runner_certificate=runner_certificate,
106
+ runner_capacity=runner_capacity,
107
+ runner_container_name=runner_container_name,
108
+ gitea_host=gitea_host,
109
+ gitea_port=gitea_port,
110
+ runner_instance_name=runner_instance_name,
111
+ )
112
+
113
+
114
+ def _check_certificate(*, certificate: PathLike = SETTINGS.runner_certificate) -> None:
115
+ if not Path(certificate).is_file():
116
+ msg = f"Missing certificate {certificate!r}"
117
+ raise FileNotFoundError(msg)
118
+
119
+
120
+ def _check_token(text: str, /) -> None:
121
+ if not search(r"^[A-Za-z0-9]{40}$", text):
122
+ msg = f"Invalid token; got {text!r}"
123
+ raise ValueError(msg)
124
+
125
+
126
+ def _docker_exec_generate(
127
+ *,
128
+ user: str = SETTINGS.gitea_container_user,
129
+ name: str = SETTINGS.gitea_container_name,
130
+ ) -> list[str]:
131
+ return [
132
+ "docker",
133
+ "exec",
134
+ "--user",
135
+ user,
136
+ name,
137
+ "gitea",
138
+ "actions",
139
+ "generate-runner-token",
140
+ ]
141
+
142
+
143
+ def _docker_run_act_runner_args(
144
+ token: str,
145
+ /,
146
+ *,
147
+ host: str = SETTINGS.gitea_host,
148
+ port: int = SETTINGS.gitea_port,
149
+ runner_certificate: PathLike = SETTINGS.runner_certificate,
150
+ instance_name: str = SETTINGS.runner_instance_name,
151
+ container_name: str = SETTINGS.runner_container_name,
152
+ ) -> list[str]:
153
+ config_host = _get_config_path(token)
154
+ config_cont = "/config.yml"
155
+ entrypoint_host = _get_entrypoint_path(host=host, port=port)
156
+ entrypoint_cont = Path("/usr/local/bin/entrypoint.sh")
157
+ return [
158
+ "docker",
159
+ "run",
160
+ "--detach",
161
+ "--entrypoint",
162
+ str(entrypoint_cont),
163
+ "--env",
164
+ f"CONFIG_FILE={config_cont}",
165
+ "--env",
166
+ f"GITEA_INSTANCE_URL=https://{host}:{port}",
167
+ "--env",
168
+ f"GITEA_RUNNER_NAME={instance_name}",
169
+ "--env",
170
+ f"GITEA_RUNNER_REGISTRATION_TOKEN={token}",
171
+ "--name",
172
+ container_name,
173
+ "--volume",
174
+ "/var/run/docker.sock:/var/run/docker.sock",
175
+ "--volume",
176
+ f"{PATH_WAIT_FOR_IT}:/usr/local/bin/wait-for-it.sh:ro",
177
+ "--volume",
178
+ f"{Path.cwd()}/data:/data",
179
+ "--volume",
180
+ f"{config_host}:{config_cont}:ro",
181
+ "--volume",
182
+ f"{entrypoint_host}:{entrypoint_cont}:ro",
183
+ "--volume",
184
+ f"{runner_certificate}:/etc/ssl/certs/runner-certificate.pem:ro",
185
+ "gitea/act_runner",
186
+ ]
187
+
188
+
189
+ def _docker_stop_runner_args(
190
+ *, name: str = SETTINGS.runner_container_name
191
+ ) -> list[str]:
192
+ return ["docker", "rm", "--force", name]
193
+
194
+
195
+ def _get_config_contents(
196
+ *,
197
+ capacity: int = SETTINGS.runner_capacity,
198
+ certificate: PathLike = SETTINGS.runner_certificate,
199
+ ) -> str:
200
+ src = PATH_CONFIGS / "config.yml"
201
+ return Template(src.read_text()).safe_substitute(
202
+ CAPACITY=capacity, CERTIFICATE=certificate
203
+ )
204
+
205
+
206
+ def _get_config_path(token: str, /) -> Path:
207
+ return PATH_CACHE / f"configs/{token}.yml"
208
+
209
+
210
+ def _get_entrypoint_contents(
211
+ *, host: str = SETTINGS.gitea_host, port: int = SETTINGS.gitea_port
212
+ ) -> str:
213
+ src = PATH_CONFIGS / "entrypoint.sh"
214
+ return Template(src.read_text()).safe_substitute(GITEA_HOST=host, GITEA_PORT=port)
215
+
216
+
217
+ def _get_entrypoint_path(
218
+ *, host: str = SETTINGS.gitea_host, port: int = SETTINGS.gitea_port
219
+ ) -> Path:
220
+ return PATH_CACHE / f"entrypoints/{host}-{port}"
221
+
222
+
223
+ def _start_runner(
224
+ token: str,
225
+ /,
226
+ *,
227
+ runner_certificate: PathLike = SETTINGS.runner_certificate,
228
+ runner_capacity: int = SETTINGS.runner_capacity,
229
+ runner_container_name: str = SETTINGS.runner_container_name,
230
+ gitea_host: str = SETTINGS.gitea_host,
231
+ gitea_port: int = SETTINGS.gitea_port,
232
+ runner_instance_name: str = SETTINGS.runner_instance_name,
233
+ ) -> None:
234
+ _check_certificate(certificate=runner_certificate)
235
+ _check_token(token)
236
+ _write_config(token, capacity=runner_capacity, certificate=runner_certificate)
237
+ _write_entrypoint(host=gitea_host, port=gitea_port)
238
+ _write_wait_for_it()
239
+ run(
240
+ *_docker_stop_runner_args(name=runner_container_name), print=True, logger=LOGGER
241
+ )
242
+ run(
243
+ *_docker_run_act_runner_args(
244
+ token,
245
+ host=gitea_host,
246
+ port=gitea_port,
247
+ runner_certificate=runner_certificate,
248
+ instance_name=runner_instance_name,
249
+ container_name=runner_container_name,
250
+ ),
251
+ print=True,
252
+ logger=LOGGER,
253
+ )
254
+
255
+
256
+ def _write_config(
257
+ token: str,
258
+ /,
259
+ *,
260
+ capacity: int = SETTINGS.runner_capacity,
261
+ certificate: PathLike = SETTINGS.runner_certificate,
262
+ ) -> None:
263
+ dest = _get_config_path(token)
264
+ text = _get_config_contents(capacity=capacity, certificate=certificate)
265
+ with writer(dest, overwrite=True) as temp:
266
+ _ = temp.write_text(text)
267
+
268
+
269
+ def _write_entrypoint(
270
+ *, host: str = SETTINGS.gitea_host, port: int = SETTINGS.gitea_port
271
+ ) -> None:
272
+ dest = _get_entrypoint_path(host=host, port=port)
273
+ text = _get_entrypoint_contents(host=host, port=port)
274
+ with writer(dest, overwrite=True) as temp:
275
+ _ = temp.write_text(text)
276
+ chmod(temp, "u=rwx,g=rx,o=rx")
277
+
278
+
279
+ def _write_wait_for_it() -> None:
280
+ if PATH_WAIT_FOR_IT.is_file():
281
+ return
282
+ with writer(PATH_WAIT_FOR_IT, overwrite=True) as temp:
283
+ resp = get(URL_WAIT_FOR_IT, timeout=60)
284
+ resp.raise_for_status()
285
+ _ = temp.write_bytes(resp.content)
286
+ chmod(temp, "u=rwx,g=rx,o=rx")
287
+
288
+
289
+ __all__ = ["register_against_local"]
@@ -0,0 +1,33 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+
5
+ from typed_settings import load_settings, option, settings
6
+ from utilities.getpass import USER
7
+ from utilities.socket import HOSTNAME
8
+
9
+ from actions.utilities import LOADER
10
+
11
+
12
+ @settings
13
+ class Settings:
14
+ ssh_user: str = option(default="user", help="SSH username")
15
+ ssh_host: str = option(default="gitea", help="SSH host")
16
+ gitea_container_user: str = option(default="git", help="Gitea container user name")
17
+ gitea_container_name: str = option(default="gitea", help="Gitea container name")
18
+ gitea_host: str = option(default="gitea", help="Gitea host")
19
+ gitea_port: int = option(default=3000, help="Gitea port")
20
+ runner_capacity: int = option(default=1, help="Runner capacity")
21
+ runner_instance_name: str = option(
22
+ default=f"{USER}--{HOSTNAME}", help="Runner instance name"
23
+ )
24
+ runner_certificate: Path = option(
25
+ default=Path("root.pem"), help="Runner root certificate"
26
+ )
27
+ runner_container_name: str = option(default="runner", help="Runner container name")
28
+
29
+
30
+ SETTINGS = load_settings(Settings, [LOADER])
31
+
32
+
33
+ __all__ = ["SETTINGS", "Settings"]
actions/run_hooks/cli.py CHANGED
@@ -1,33 +1,21 @@
1
1
  from __future__ import annotations
2
2
 
3
- from rich.pretty import pretty_repr
4
3
  from typed_settings import click_options
5
4
  from utilities.logging import basic_config
6
5
  from utilities.os import is_pytest
7
- from utilities.text import strip_and_dedent
8
6
 
9
- from actions import __version__
10
7
  from actions.logging import LOGGER
11
8
  from actions.run_hooks.lib import run_hooks
12
9
  from actions.run_hooks.settings import Settings
13
10
  from actions.utilities import LOADER
14
11
 
15
12
 
16
- @click_options(Settings, [LOADER], show_envvars_in_help=True, argname="hooks")
17
- def run_hooks_sub_cmd(*, hooks: Settings) -> None:
13
+ @click_options(Settings, [LOADER], show_envvars_in_help=True)
14
+ def run_hooks_sub_cmd(settings: Settings, /) -> None:
18
15
  if is_pytest():
19
16
  return
20
17
  basic_config(obj=LOGGER)
21
- LOGGER.info(
22
- strip_and_dedent("""
23
- Running '%s' (version %s) with settings:
24
- %s
25
- """),
26
- run_hooks.__name__,
27
- __version__,
28
- pretty_repr(hooks),
29
- )
30
- run_hooks(repos=hooks.repos, hooks=hooks.hooks, sleep=hooks.sleep)
18
+ run_hooks(repos=settings.repos, hooks=settings.hooks, sleep=settings.sleep)
31
19
 
32
20
 
33
21
  __all__ = ["run_hooks_sub_cmd"]
@@ -0,0 +1,7 @@
1
+ from __future__ import annotations
2
+
3
+ RUN_HOOKS_DOCSTRING = "Run 'pre-commit' hooks"
4
+ RUN_HOOKS_SUB_CMD = "run-hooks"
5
+
6
+
7
+ __all__ = ["RUN_HOOKS_DOCSTRING", "RUN_HOOKS_SUB_CMD"]
actions/run_hooks/lib.py CHANGED
@@ -14,7 +14,7 @@ from yaml import safe_load
14
14
  from actions import __version__
15
15
  from actions.logging import LOGGER
16
16
  from actions.run_hooks.settings import SETTINGS
17
- from actions.utilities import log_run
17
+ from actions.utilities import logged_run
18
18
 
19
19
  if TYPE_CHECKING:
20
20
  from collections.abc import Iterator
@@ -77,7 +77,7 @@ def _yield_repo_hooks(repo: dict[str, Any], /) -> Iterator[str]:
77
77
  def _run_hook(hook: str, /, *, sleep: int = SETTINGS.sleep) -> bool:
78
78
  LOGGER.info("Running '%s'...", hook)
79
79
  try:
80
- log_run("pre-commit", "run", "--verbose", "--all-files", hook, print=True)
80
+ logged_run("pre-commit", "run", "--verbose", "--all-files", hook, print=True)
81
81
  except CalledProcessError:
82
82
  is_success = False
83
83
  else:
@@ -1,12 +1,9 @@
1
1
  from __future__ import annotations
2
2
 
3
- from rich.pretty import pretty_repr
4
3
  from typed_settings import click_options
5
4
  from utilities.logging import basic_config
6
5
  from utilities.os import is_pytest
7
- from utilities.text import strip_and_dedent
8
6
 
9
- from actions import __version__
10
7
  from actions.logging import LOGGER
11
8
  from actions.setup_cronjob.lib import setup_cronjob
12
9
  from actions.setup_cronjob.settings import Settings
@@ -18,15 +15,6 @@ def setup_cronjob_sub_cmd(settings: Settings, /) -> None:
18
15
  if is_pytest():
19
16
  return
20
17
  basic_config(obj=LOGGER)
21
- LOGGER.info(
22
- strip_and_dedent("""
23
- Running '%s' (version %s) with settings:
24
- %s
25
- """),
26
- setup_cronjob.__name__,
27
- __version__,
28
- pretty_repr(settings),
29
- )
30
18
  setup_cronjob(
31
19
  name=settings.name,
32
20
  prepend_path=settings.prepend_path,
@@ -5,4 +5,8 @@ from actions.constants import PATH_ACTIONS
5
5
  PATH_CONFIGS = PATH_ACTIONS / "setup_cronjob/configs"
6
6
 
7
7
 
8
- __all__ = ["PATH_CONFIGS"]
8
+ SETUP_CRONJOB_SUB_CMD = "setup-cronjob"
9
+ SETUP_CRONJOB_DOCSTRING = "Setup a cronjob"
10
+
11
+
12
+ __all__ = ["PATH_CONFIGS", "SETUP_CRONJOB_DOCSTRING", "SETUP_CRONJOB_SUB_CMD"]
actions/tag_commit/cli.py CHANGED
@@ -1,38 +1,26 @@
1
1
  from __future__ import annotations
2
2
 
3
- from rich.pretty import pretty_repr
4
3
  from typed_settings import click_options
5
4
  from utilities.logging import basic_config
6
5
  from utilities.os import is_pytest
7
- from utilities.text import strip_and_dedent
8
6
 
9
- from actions import __version__
10
7
  from actions.logging import LOGGER
11
8
  from actions.tag_commit.lib import tag_commit
12
9
  from actions.tag_commit.settings import Settings
13
10
  from actions.utilities import LOADER
14
11
 
15
12
 
16
- @click_options(Settings, [LOADER], show_envvars_in_help=True, argname="tag")
17
- def tag_commit_sub_cmd(*, tag: Settings) -> None:
13
+ @click_options(Settings, [LOADER], show_envvars_in_help=True)
14
+ def tag_commit_sub_cmd(settings: Settings, /) -> None:
18
15
  if is_pytest():
19
16
  return
20
17
  basic_config(obj=LOGGER)
21
- LOGGER.info(
22
- strip_and_dedent("""
23
- Running '%s' (version %s) with settings:
24
- %s
25
- """),
26
- tag_commit.__name__,
27
- __version__,
28
- pretty_repr(tag),
29
- )
30
18
  tag_commit(
31
- user_name=tag.user_name,
32
- user_email=tag.user_email,
33
- major_minor=tag.major_minor,
34
- major=tag.major,
35
- latest=tag.latest,
19
+ user_name=settings.user_name,
20
+ user_email=settings.user_email,
21
+ major_minor=settings.major_minor,
22
+ major=settings.major,
23
+ latest=settings.latest,
36
24
  )
37
25
 
38
26
 
@@ -0,0 +1,7 @@
1
+ from __future__ import annotations
2
+
3
+ TAG_COMMIT_DOCSTRING = "Tag the latest commit"
4
+ TAG_COMMIT_SUB_CMD = "tag-commit"
5
+
6
+
7
+ __all__ = ["TAG_COMMIT_DOCSTRING", "TAG_COMMIT_SUB_CMD"]
actions/tag_commit/lib.py CHANGED
@@ -9,7 +9,7 @@ from utilities.version import parse_version
9
9
  from actions import __version__
10
10
  from actions.logging import LOGGER
11
11
  from actions.tag_commit.settings import SETTINGS
12
- from actions.utilities import log_run
12
+ from actions.utilities import logged_run
13
13
 
14
14
 
15
15
  def tag_commit(
@@ -37,10 +37,10 @@ def tag_commit(
37
37
  major,
38
38
  latest,
39
39
  )
40
- log_run("git", "config", "--global", "user.name", user_name)
41
- log_run("git", "config", "--global", "user.email", user_email)
40
+ logged_run("git", "config", "--global", "user.name", user_name)
41
+ logged_run("git", "config", "--global", "user.email", user_email)
42
42
  version = parse_version(
43
- log_run("bump-my-version", "show", "current_version", return_=True)
43
+ logged_run("bump-my-version", "show", "current_version", return_=True)
44
44
  )
45
45
  _tag(str(version))
46
46
  if major_minor:
@@ -53,11 +53,11 @@ def tag_commit(
53
53
 
54
54
  def _tag(version: str, /) -> None:
55
55
  with suppress(CalledProcessError):
56
- log_run("git", "tag", "--delete", version)
56
+ logged_run("git", "tag", "--delete", version)
57
57
  with suppress(CalledProcessError):
58
- log_run("git", "push", "--delete", "origin", version)
59
- log_run("git", "tag", "-a", version, "HEAD", "-m", version)
60
- log_run("git", "push", "--tags", "--force", "--set-upstream", "origin")
58
+ logged_run("git", "push", "--delete", "origin", version)
59
+ logged_run("git", "tag", "-a", version, "HEAD", "-m", version)
60
+ logged_run("git", "push", "--tags", "--force", "--set-upstream", "origin")
61
61
 
62
62
 
63
63
  __all__ = ["tag_commit"]
actions/types.py CHANGED
@@ -1,18 +1,21 @@
1
1
  from __future__ import annotations
2
2
 
3
+ from collections.abc import Callable
3
4
  from typing import TYPE_CHECKING, Any
4
5
 
5
6
  from tomlkit.items import Array, Table
6
7
  from typed_settings import Secret
8
+ from utilities.packaging import Requirement
7
9
 
8
10
  if TYPE_CHECKING:
9
11
  from tomlkit.container import Container
10
12
 
11
13
 
14
+ type FuncRequirement = Callable[[Requirement], Requirement]
12
15
  type HasAppend = Array | list[Any]
13
16
  type HasSetDefault = Container | StrDict | Table
14
17
  type SecretLike = str | Secret[str]
15
18
  type StrDict = dict[str, Any]
16
19
 
17
20
 
18
- __all__ = ["HasAppend", "HasSetDefault", "SecretLike", "StrDict"]
21
+ __all__ = ["FuncRequirement", "HasAppend", "HasSetDefault", "SecretLike", "StrDict"]