winipedia-utils 0.4.48__py3-none-any.whl → 0.4.53__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.

Potentially problematic release.


This version of winipedia-utils might be problematic. Click here for more details.

@@ -2,7 +2,7 @@
2
2
 
3
3
  from abc import abstractmethod
4
4
  from pathlib import Path
5
- from typing import Any
5
+ from typing import Any, ClassVar
6
6
 
7
7
  import winipedia_utils
8
8
  from winipedia_utils.modules.module import make_obj_importpath
@@ -15,6 +15,37 @@ from winipedia_utils.text.string import split_on_uppercase
15
15
  class Workflow(YamlConfigFile):
16
16
  """Base class for workflows."""
17
17
 
18
+ EMPTY_CONFIG: ClassVar[dict[str, Any]] = {
19
+ "on": {
20
+ "workflow_dispatch": {},
21
+ },
22
+ "jobs": {
23
+ "empty": {
24
+ "runs-on": "ubuntu-latest",
25
+ "steps": [
26
+ {
27
+ "name": "Empty Step",
28
+ "run": "echo 'Empty Step'",
29
+ }
30
+ ],
31
+ },
32
+ },
33
+ }
34
+
35
+ @classmethod
36
+ def is_correct(cls) -> bool:
37
+ """Check if the config is correct.
38
+
39
+ Needs some special handling since workflow files cannot be empty.
40
+ We need a workflow that will never trigger and even if doesnt do anything.
41
+ """
42
+ correct = super().is_correct()
43
+ if cls.get_path().read_text() == "":
44
+ # dump a dispatch in there for on and an empty job for jobs
45
+ cls.dump(cls.EMPTY_CONFIG)
46
+
47
+ return correct or cls.load() == cls.EMPTY_CONFIG
48
+
18
49
  @classmethod
19
50
  @abstractmethod
20
51
  def get_workflow_triggers(cls) -> dict[str, Any]:
@@ -113,7 +144,7 @@ class Workflow(YamlConfigFile):
113
144
  return step
114
145
 
115
146
  @classmethod
116
- def get_poetry_setup_steps(
147
+ def get_poetry_setup_steps( # noqa: PLR0913
117
148
  cls,
118
149
  *,
119
150
  install_dependencies: bool = False,
@@ -121,6 +152,7 @@ class Workflow(YamlConfigFile):
121
152
  configure_pipy_token: bool = False,
122
153
  force_main_head: bool = False,
123
154
  token: bool = False,
155
+ with_keyring: bool = False,
124
156
  ) -> list[dict[str, Any]]:
125
157
  """Get the poetry steps.
126
158
 
@@ -132,6 +164,7 @@ class Workflow(YamlConfigFile):
132
164
  equal to the most recent commit on main. This is useful for workflows that
133
165
  should only run on main.
134
166
  token: Whether to use the repository token.
167
+ with_keyring: Whether to setup the keyring.
135
168
 
136
169
  Returns:
137
170
  The poetry steps.
@@ -161,6 +194,7 @@ class Workflow(YamlConfigFile):
161
194
  "run": "curl -sSL https://install.python-poetry.org | python3 -",
162
195
  }
163
196
  )
197
+
164
198
  if configure_pipy_token:
165
199
  steps.append(
166
200
  {
@@ -168,8 +202,13 @@ class Workflow(YamlConfigFile):
168
202
  "run": "poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}",
169
203
  }
170
204
  )
205
+
171
206
  if install_dependencies:
172
207
  steps.append({"name": "Install Dependencies", "run": "poetry install"})
208
+
209
+ if with_keyring:
210
+ steps.append(cls.get_setup_keyring_step())
211
+
173
212
  return steps
174
213
 
175
214
  @classmethod
@@ -243,6 +282,14 @@ class Workflow(YamlConfigFile):
243
282
  "run": "git commit --no-verify -m '[skip ci] CI/CD: Committing possible added changes (e.g.: pyproject.toml and poetry.lock)'", # noqa: E501
244
283
  }
245
284
 
285
+ @classmethod
286
+ def get_setup_keyring_step(cls) -> dict[str, Any]:
287
+ """Get the setup keyring step."""
288
+ return {
289
+ "name": "Setup CI keyring",
290
+ "run": """poetry run pip install keyrings.alt && poetry run python -c "import keyring; from keyrings.alt.file import PlaintextKeyring; keyring.set_keyring(PlaintextKeyring()); keyring.set_password('video_vault','ci_user','ci-secret-token'); print('Keyring OK:', keyring.get_password('video_vault','ci_user'))" """, # noqa: E501
291
+ }
292
+
246
293
  @classmethod
247
294
  def get_protect_repository_step(cls) -> dict[str, Any]:
248
295
  """Get the protect repository step."""
@@ -46,6 +46,7 @@ class HealthCheckWorkflow(Workflow):
46
46
  cls.get_poetry_setup_steps(
47
47
  install_dependencies=True,
48
48
  token=True,
49
+ with_keyring=True,
49
50
  )
50
51
  ),
51
52
  cls.get_protect_repository_step(),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: winipedia-utils
3
- Version: 0.4.48
3
+ Version: 0.4.53
4
4
  Summary: A package with many utility functions
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -16,8 +16,8 @@ winipedia_utils/git/github/repo/protect.py,sha256=nOVjb5GVinGIClp7k9_qqgKnAl_gk1
16
16
  winipedia_utils/git/github/repo/repo.py,sha256=OqoOfqDhe_Iik71dNqi4h3fGrMno33hSjk0bpNg3eZk,7865
17
17
  winipedia_utils/git/github/workflows/__init__.py,sha256=BPdntTwFEyBMJ6MyT7gddPHswvRdH9tsRtfK72VSV7Y,57
18
18
  winipedia_utils/git/github/workflows/base/__init__.py,sha256=XHsbmjiaGom-KX-S3leCY9cJD3aP9p_0X6xYMcdkHBU,23
19
- winipedia_utils/git/github/workflows/base/base.py,sha256=t2jYHVpvhCaKpaZI9Yhr8YJEp-2D_G4VUJKVVYIUolc,9749
20
- winipedia_utils/git/github/workflows/health_check.py,sha256=cPjSJxNy9h0bKNK69crmcERACx4VGR2XytyZ1JM_wMQ,1567
19
+ winipedia_utils/git/github/workflows/base/base.py,sha256=4MAHU_oPqicwO7tZE0B99RK9ZKRMFIZhUYkWr1NrYqo,11405
20
+ winipedia_utils/git/github/workflows/health_check.py,sha256=pjGZckvfPHuR6QepHia6_FKcwUQAXuhGGVaVCpLQNaY,1614
21
21
  winipedia_utils/git/github/workflows/publish.py,sha256=TPbSp5QH2vVl55UdqE_kjf1HIkdubcgqWlkLjWFX5EA,1378
22
22
  winipedia_utils/git/github/workflows/release.py,sha256=hnMT12J17LmFpPCTzva-lW95MOFDQ-1bAOrTVCxeaR8,1301
23
23
  winipedia_utils/git/gitignore/__init__.py,sha256=k-2E26JaZPkF69UUOJkpQl8T_PudrC7EYCIOxwgIQVU,57
@@ -88,7 +88,7 @@ winipedia_utils/testing/tests/conftest.py,sha256=BLgUJtLecOwuEsIyJ__0buqovd5AhiG
88
88
  winipedia_utils/text/__init__.py,sha256=j2bwtK6kyeHI6SnoBjpRju0C1W2n2paXBDlNjNtaUxA,48
89
89
  winipedia_utils/text/config.py,sha256=BPpuD4ywzzzt6Jz2M5Eln5d1NLlDp4r7CPwQOgHkxcg,7782
90
90
  winipedia_utils/text/string.py,sha256=yXmwOab5hXyVQG1NwlWDpy2prj0U7Vb2F5HKLT2Y77Q,3382
91
- winipedia_utils-0.4.48.dist-info/METADATA,sha256=Cpe2X9GV4-qJUvJhHg7ipY7gweMTuBn8rt2azARZm-8,14694
92
- winipedia_utils-0.4.48.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
93
- winipedia_utils-0.4.48.dist-info/licenses/LICENSE,sha256=o316mE2gGzd__JT69p7S_zlOmKiHh8YjpImCCcWyTvM,1066
94
- winipedia_utils-0.4.48.dist-info/RECORD,,
91
+ winipedia_utils-0.4.53.dist-info/METADATA,sha256=dHVCIWf2JB02S9ZNLS0WWKMjr_oH6kgudHrU682IrZo,14694
92
+ winipedia_utils-0.4.53.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
93
+ winipedia_utils-0.4.53.dist-info/licenses/LICENSE,sha256=o316mE2gGzd__JT69p7S_zlOmKiHh8YjpImCCcWyTvM,1066
94
+ winipedia_utils-0.4.53.dist-info/RECORD,,