gha-utils 4.14.2__py3-none-any.whl → 4.15.1__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 gha-utils might be problematic. Click here for more details.
- gha_utils/__init__.py +1 -1
- gha_utils/changelog.py +1 -5
- gha_utils/cli.py +75 -18
- gha_utils/metadata.py +17 -27
- gha_utils/test_plan.py +62 -34
- {gha_utils-4.14.2.dist-info → gha_utils-4.15.1.dist-info}/METADATA +6 -8
- gha_utils-4.15.1.dist-info/RECORD +14 -0
- {gha_utils-4.14.2.dist-info → gha_utils-4.15.1.dist-info}/WHEEL +1 -1
- gha_utils-4.14.2.dist-info/RECORD +0 -14
- {gha_utils-4.14.2.dist-info → gha_utils-4.15.1.dist-info}/entry_points.txt +0 -0
- {gha_utils-4.14.2.dist-info → gha_utils-4.15.1.dist-info}/top_level.txt +0 -0
gha_utils/__init__.py
CHANGED
gha_utils/changelog.py
CHANGED
|
@@ -18,15 +18,11 @@ from __future__ import annotations
|
|
|
18
18
|
|
|
19
19
|
import logging
|
|
20
20
|
import re
|
|
21
|
-
import sys
|
|
22
21
|
from functools import cached_property
|
|
23
22
|
from pathlib import Path
|
|
24
23
|
from textwrap import indent
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
import tomllib
|
|
28
|
-
else:
|
|
29
|
-
import tomli as tomllib # type: ignore[import-not-found]
|
|
25
|
+
import tomllib
|
|
30
26
|
|
|
31
27
|
|
|
32
28
|
class Changelog:
|
gha_utils/cli.py
CHANGED
|
@@ -19,11 +19,12 @@ from __future__ import annotations
|
|
|
19
19
|
import logging
|
|
20
20
|
import os
|
|
21
21
|
import sys
|
|
22
|
+
from collections import Counter
|
|
22
23
|
from datetime import datetime
|
|
23
24
|
from pathlib import Path
|
|
24
25
|
from typing import IO
|
|
25
26
|
|
|
26
|
-
import
|
|
27
|
+
from boltons.iterutils import unique
|
|
27
28
|
from click_extra import (
|
|
28
29
|
Choice,
|
|
29
30
|
Context,
|
|
@@ -35,12 +36,14 @@ from click_extra import (
|
|
|
35
36
|
option,
|
|
36
37
|
pass_context,
|
|
37
38
|
)
|
|
39
|
+
from click_extra.envvar import merge_envvar_ids
|
|
40
|
+
from extra_platforms import ALL_IDS
|
|
38
41
|
|
|
39
42
|
from . import __version__
|
|
40
43
|
from .changelog import Changelog
|
|
41
44
|
from .mailmap import Mailmap
|
|
42
45
|
from .metadata import Dialects, Metadata
|
|
43
|
-
from .test_plan import DEFAULT_TEST_PLAN, parse_test_plan
|
|
46
|
+
from .test_plan import DEFAULT_TEST_PLAN, SkippedTest, parse_test_plan
|
|
44
47
|
|
|
45
48
|
|
|
46
49
|
def is_stdout(filepath: Path) -> bool:
|
|
@@ -275,19 +278,36 @@ def mailmap_sync(ctx, source, create_if_missing, destination_mailmap):
|
|
|
275
278
|
@gha_utils.command(short_help="Run a test plan from a file against a binary")
|
|
276
279
|
@option(
|
|
277
280
|
"--binary",
|
|
278
|
-
|
|
279
|
-
# `file_path` type.
|
|
280
|
-
type=click.Path(exists=True, executable=True, resolve_path=True),
|
|
281
|
+
type=file_path(exists=True, executable=True, resolve_path=True),
|
|
281
282
|
required=True,
|
|
282
283
|
metavar="FILE_PATH",
|
|
283
284
|
help="Path to the binary file to test.",
|
|
284
285
|
)
|
|
285
286
|
@option(
|
|
286
|
-
"
|
|
287
|
+
"-F",
|
|
288
|
+
"--plan-file",
|
|
287
289
|
type=file_path(exists=True, readable=True, resolve_path=True),
|
|
290
|
+
multiple=True,
|
|
288
291
|
metavar="FILE_PATH",
|
|
289
|
-
help="Path to
|
|
290
|
-
"plan will be
|
|
292
|
+
help="Path to a test plan file in YAML. This option can be repeated to run "
|
|
293
|
+
"multiple test plans in sequence. If not provided, a default test plan will be "
|
|
294
|
+
"executed.",
|
|
295
|
+
)
|
|
296
|
+
@option(
|
|
297
|
+
"-E",
|
|
298
|
+
"--plan-envvar",
|
|
299
|
+
multiple=True,
|
|
300
|
+
metavar="ENVVAR_NAME",
|
|
301
|
+
help="Name of an environment variable containing a test plan in YAML. This "
|
|
302
|
+
"option can be repeated to collect multiple test plans.",
|
|
303
|
+
)
|
|
304
|
+
@option(
|
|
305
|
+
"-s",
|
|
306
|
+
"--skip-platform",
|
|
307
|
+
type=Choice(sorted(ALL_IDS), case_sensitive=False),
|
|
308
|
+
multiple=True,
|
|
309
|
+
help="Skip tests for the specified platforms. This option can be repeated to "
|
|
310
|
+
"skip multiple platforms.",
|
|
291
311
|
)
|
|
292
312
|
@option(
|
|
293
313
|
"-t",
|
|
@@ -300,17 +320,54 @@ def mailmap_sync(ctx, source, create_if_missing, destination_mailmap):
|
|
|
300
320
|
help="Set the default timeout for each CLI call, if not specified in the "
|
|
301
321
|
"test plan.",
|
|
302
322
|
)
|
|
303
|
-
def test_plan(
|
|
323
|
+
def test_plan(
|
|
324
|
+
binary: Path,
|
|
325
|
+
plan_file: tuple[Path, ...] | None,
|
|
326
|
+
plan_envvar: tuple[str, ...] | None,
|
|
327
|
+
skip_platform: tuple[str, ...] | None,
|
|
328
|
+
timeout: float | None,
|
|
329
|
+
) -> None:
|
|
304
330
|
# Load test plan from workflow input, or use a default one.
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
331
|
+
test_list = []
|
|
332
|
+
if plan_file or plan_envvar:
|
|
333
|
+
for file in unique(plan_file):
|
|
334
|
+
logging.info(f"Get test plan from {file} file")
|
|
335
|
+
tests = list(parse_test_plan(file.read_text(encoding="UTF-8")))
|
|
336
|
+
logging.info(f"{len(tests)} test cases found.")
|
|
337
|
+
test_list.extend(tests)
|
|
338
|
+
for envvar_id in merge_envvar_ids(plan_envvar):
|
|
339
|
+
logging.info(f"Get test plan from {envvar_id!r} environment variable")
|
|
340
|
+
tests = list(parse_test_plan(os.getenv(envvar_id)))
|
|
341
|
+
logging.info(f"{len(tests)} test cases found.")
|
|
342
|
+
test_list.extend(tests)
|
|
343
|
+
|
|
308
344
|
else:
|
|
309
|
-
logging.warning(
|
|
310
|
-
|
|
311
|
-
|
|
345
|
+
logging.warning(
|
|
346
|
+
"No test plan provided through --plan-file/-F or --plan-envvar/-E options:"
|
|
347
|
+
" use default test plan."
|
|
348
|
+
)
|
|
349
|
+
test_list = DEFAULT_TEST_PLAN
|
|
350
|
+
logging.debug(f"Test plan: {test_list}")
|
|
351
|
+
|
|
352
|
+
stats = Counter(total=len(test_list), skipped=0, failed=0)
|
|
312
353
|
|
|
313
|
-
for index, test_case in enumerate(
|
|
354
|
+
for index, test_case in enumerate(test_list):
|
|
314
355
|
logging.info(f"Run test #{index + 1}")
|
|
315
|
-
|
|
316
|
-
|
|
356
|
+
try:
|
|
357
|
+
logging.debug(f"Test case parameters: {test_case}")
|
|
358
|
+
test_case.run_cli_test(
|
|
359
|
+
binary, additional_skip_platforms=skip_platform, default_timeout=timeout
|
|
360
|
+
)
|
|
361
|
+
except SkippedTest as ex:
|
|
362
|
+
stats["skipped"] += 1
|
|
363
|
+
logging.warning(f"Test skipped: {ex}")
|
|
364
|
+
except Exception as ex:
|
|
365
|
+
stats["failed"] += 1
|
|
366
|
+
logging.error(f"Test failed: {ex}")
|
|
367
|
+
|
|
368
|
+
logging.info(
|
|
369
|
+
"Test plan results - "
|
|
370
|
+
+ ", ".join((f"{k.title()}: {v}" for k, v in stats.items()))
|
|
371
|
+
)
|
|
372
|
+
if stats["failed"]:
|
|
373
|
+
sys.exit(1)
|
gha_utils/metadata.py
CHANGED
|
@@ -49,7 +49,7 @@ release_commits_matrix={'commit': ['6f27db47612aaee06fdf08744b09a9f5f6c2'],
|
|
|
49
49
|
nuitka_matrix={'entry_point': ['mpm'],
|
|
50
50
|
'commit': ['346ce664f055fbd042a25ee0b7e96702e95',
|
|
51
51
|
'6f27db47612aaee06fdf08744b09a9f5f6c2'],
|
|
52
|
-
'os': ['ubuntu-24.04', 'ubuntu-24.04-arm', 'macos-15', 'macos-13', 'windows-
|
|
52
|
+
'os': ['ubuntu-24.04', 'ubuntu-24.04-arm', 'macos-15', 'macos-13', 'windows-2025'],
|
|
53
53
|
'include': [{'entry_point': 'mpm',
|
|
54
54
|
'cli_id': 'mpm',
|
|
55
55
|
'module_id': 'meta_package_manager.__main__',
|
|
@@ -77,7 +77,7 @@ nuitka_matrix={'entry_point': ['mpm'],
|
|
|
77
77
|
'platform_id': 'macos',
|
|
78
78
|
'arch': 'x64',
|
|
79
79
|
'extension': 'bin'},
|
|
80
|
-
{'os': 'windows-
|
|
80
|
+
{'os': 'windows-2025',
|
|
81
81
|
'platform_id': 'windows',
|
|
82
82
|
'arch': 'x64',
|
|
83
83
|
'extension': 'exe'},
|
|
@@ -123,12 +123,12 @@ nuitka_matrix={'entry_point': ['mpm'],
|
|
|
123
123
|
'bin_name': 'mpm-macos-x64-build-6f27db4.bin'},
|
|
124
124
|
{'entry_point': 'mpm',
|
|
125
125
|
'commit': '346ce664f055fbd042a25ee0b7e96702e95',
|
|
126
|
-
'os': 'windows-
|
|
126
|
+
'os': 'windows-2025',
|
|
127
127
|
'arch': 'x64',
|
|
128
128
|
'bin_name': 'mpm-windows-x64-build-346ce66.exe'},
|
|
129
129
|
{'entry_point': 'mpm',
|
|
130
130
|
'commit': '6f27db47612aaee06fdf08744b09a9f5f6c2',
|
|
131
|
-
'os': 'windows-
|
|
131
|
+
'os': 'windows-2025',
|
|
132
132
|
'arch': 'x64',
|
|
133
133
|
'bin_name': 'mpm-windows-x64-build-6f27db4.exe'}]}
|
|
134
134
|
```
|
|
@@ -147,22 +147,15 @@ import json
|
|
|
147
147
|
import logging
|
|
148
148
|
import os
|
|
149
149
|
import re
|
|
150
|
-
import sys
|
|
151
150
|
from collections.abc import Iterable
|
|
151
|
+
from enum import StrEnum
|
|
152
152
|
from functools import cached_property
|
|
153
153
|
from pathlib import Path
|
|
154
154
|
from random import randint
|
|
155
155
|
from re import escape
|
|
156
156
|
from typing import Any, Final, Iterator, cast
|
|
157
157
|
|
|
158
|
-
|
|
159
|
-
from enum import StrEnum
|
|
160
|
-
|
|
161
|
-
import tomllib
|
|
162
|
-
else:
|
|
163
|
-
import tomli as tomllib # type: ignore[import-not-found]
|
|
164
|
-
from backports.strenum import StrEnum # type: ignore[import-not-found]
|
|
165
|
-
|
|
158
|
+
import tomllib
|
|
166
159
|
from bumpversion.config import get_configuration # type: ignore[import-untyped]
|
|
167
160
|
from bumpversion.config.files import find_config_file # type: ignore[import-untyped]
|
|
168
161
|
from bumpversion.show import resolve_name # type: ignore[import-untyped]
|
|
@@ -457,7 +450,7 @@ class Metadata:
|
|
|
457
450
|
return matrix
|
|
458
451
|
|
|
459
452
|
@cached_property
|
|
460
|
-
def event_type(self) -> WorkflowEvent | None:
|
|
453
|
+
def event_type(self) -> WorkflowEvent | None:
|
|
461
454
|
"""Returns the type of event that triggered the workflow run.
|
|
462
455
|
|
|
463
456
|
.. caution::
|
|
@@ -481,8 +474,8 @@ class Metadata:
|
|
|
481
474
|
return None
|
|
482
475
|
|
|
483
476
|
if bool(os.environ.get("GITHUB_BASE_REF")):
|
|
484
|
-
return WorkflowEvent.pull_request
|
|
485
|
-
return WorkflowEvent.push
|
|
477
|
+
return WorkflowEvent.pull_request
|
|
478
|
+
return WorkflowEvent.push
|
|
486
479
|
|
|
487
480
|
@cached_property
|
|
488
481
|
def commit_range(self) -> tuple[str, str] | None:
|
|
@@ -515,7 +508,7 @@ class Metadata:
|
|
|
515
508
|
if not self.github_context or not self.event_type:
|
|
516
509
|
return None
|
|
517
510
|
# Pull request event.
|
|
518
|
-
if self.event_type in (
|
|
511
|
+
if self.event_type in (
|
|
519
512
|
WorkflowEvent.pull_request,
|
|
520
513
|
WorkflowEvent.pull_request_target,
|
|
521
514
|
):
|
|
@@ -880,7 +873,7 @@ class Metadata:
|
|
|
880
873
|
"ubuntu-24.04-arm",
|
|
881
874
|
"macos-15",
|
|
882
875
|
"macos-13",
|
|
883
|
-
"windows-
|
|
876
|
+
"windows-2025",
|
|
884
877
|
],
|
|
885
878
|
"include": [
|
|
886
879
|
{
|
|
@@ -925,7 +918,7 @@ class Metadata:
|
|
|
925
918
|
"extension": "bin",
|
|
926
919
|
},
|
|
927
920
|
{
|
|
928
|
-
"os": "windows-
|
|
921
|
+
"os": "windows-2025",
|
|
929
922
|
"platform_id": "windows",
|
|
930
923
|
"arch": "x64",
|
|
931
924
|
"extension": "exe",
|
|
@@ -989,14 +982,14 @@ class Metadata:
|
|
|
989
982
|
{
|
|
990
983
|
"entry_point": "mpm",
|
|
991
984
|
"commit": "346ce664f055fbd042a25ee0b7e96702e95",
|
|
992
|
-
"os": "windows-
|
|
985
|
+
"os": "windows-2025",
|
|
993
986
|
"arch": "x64",
|
|
994
987
|
"bin_name": "mpm-windows-x64-build-346ce66.exe",
|
|
995
988
|
},
|
|
996
989
|
{
|
|
997
990
|
"entry_point": "mpm",
|
|
998
991
|
"commit": "6f27db47612aaee06fdf08744b09a9f5f6c2",
|
|
999
|
-
"os": "windows-
|
|
992
|
+
"os": "windows-2025",
|
|
1000
993
|
"arch": "x64",
|
|
1001
994
|
"bin_name": "mpm-windows-x64-build-6f27db4.exe",
|
|
1002
995
|
},
|
|
@@ -1021,7 +1014,7 @@ class Metadata:
|
|
|
1021
1014
|
"ubuntu-24.04-arm", # arm64
|
|
1022
1015
|
"macos-15", # arm64
|
|
1023
1016
|
"macos-13", # x64
|
|
1024
|
-
"windows-
|
|
1017
|
+
"windows-2025", # x64
|
|
1025
1018
|
),
|
|
1026
1019
|
)
|
|
1027
1020
|
|
|
@@ -1086,7 +1079,7 @@ class Metadata:
|
|
|
1086
1079
|
"extension": "bin",
|
|
1087
1080
|
},
|
|
1088
1081
|
{
|
|
1089
|
-
"os": "windows-
|
|
1082
|
+
"os": "windows-2025",
|
|
1090
1083
|
"platform_id": "windows",
|
|
1091
1084
|
"arch": "x64",
|
|
1092
1085
|
"extension": "exe",
|
|
@@ -1180,10 +1173,7 @@ class Metadata:
|
|
|
1180
1173
|
|
|
1181
1174
|
return cast(str, value)
|
|
1182
1175
|
|
|
1183
|
-
def dump(
|
|
1184
|
-
self,
|
|
1185
|
-
dialect: Dialects = Dialects.github, # type: ignore[valid-type]
|
|
1186
|
-
) -> str:
|
|
1176
|
+
def dump(self, dialect: Dialects = Dialects.github) -> str:
|
|
1187
1177
|
"""Returns all metadata in the specified format.
|
|
1188
1178
|
|
|
1189
1179
|
Defaults to GitHub dialect.
|
gha_utils/test_plan.py
CHANGED
|
@@ -28,14 +28,23 @@ from typing import Generator, Sequence
|
|
|
28
28
|
import yaml
|
|
29
29
|
from boltons.iterutils import flatten
|
|
30
30
|
from boltons.strutils import strip_ansi
|
|
31
|
-
from click_extra.testing import args_cleanup,
|
|
31
|
+
from click_extra.testing import args_cleanup, render_cli_run
|
|
32
|
+
from extra_platforms import Group, _TNestedReferences, current_os
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class SkippedTest(Exception):
|
|
36
|
+
"""Raised when a test case should be skipped."""
|
|
37
|
+
|
|
38
|
+
pass
|
|
32
39
|
|
|
33
40
|
|
|
34
41
|
@dataclass(order=True)
|
|
35
|
-
class
|
|
42
|
+
class CLITestCase:
|
|
36
43
|
cli_parameters: tuple[str, ...] | str = field(default_factory=tuple)
|
|
37
44
|
"""Parameters, arguments and options to pass to the CLI."""
|
|
38
45
|
|
|
46
|
+
skip_platforms: _TNestedReferences = field(default_factory=tuple)
|
|
47
|
+
only_platforms: _TNestedReferences = field(default_factory=tuple)
|
|
39
48
|
timeout: float | str | None = None
|
|
40
49
|
exit_code: int | str | None = None
|
|
41
50
|
strip_ansi: bool = False
|
|
@@ -87,11 +96,16 @@ class TestCase:
|
|
|
87
96
|
if isinstance(field_data, str) or not isinstance(
|
|
88
97
|
field_data, Sequence
|
|
89
98
|
):
|
|
90
|
-
# CLI parameters needs to be split
|
|
91
|
-
#
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
# CLI parameters provided as a long string needs to be split so
|
|
100
|
+
# that each argument is a separate item in the final tuple.
|
|
101
|
+
if field_id == "cli_parameters":
|
|
102
|
+
# XXX Maybe we should rely on a library to parse them:
|
|
103
|
+
# https://github.com/maxpat78/w32lex
|
|
104
|
+
if sys.platform == "win32":
|
|
105
|
+
field_data = field_data.split()
|
|
106
|
+
# For Unix platforms, we have the dedicated shlex module.
|
|
107
|
+
else:
|
|
108
|
+
field_data = shlex.split(field_data)
|
|
95
109
|
else:
|
|
96
110
|
field_data = (field_data,)
|
|
97
111
|
|
|
@@ -101,6 +115,10 @@ class TestCase:
|
|
|
101
115
|
# Ignore blank value.
|
|
102
116
|
field_data = tuple(i for i in field_data if i.strip())
|
|
103
117
|
|
|
118
|
+
# Normalize any mishmash of platform and group IDs into a set of platforms.
|
|
119
|
+
if field_id.endswith("_platforms") and field_data:
|
|
120
|
+
field_data = frozenset(Group._extract_platforms(field_data))
|
|
121
|
+
|
|
104
122
|
# Validates fields containing one or more regexes.
|
|
105
123
|
if "_regex_" in field_id and field_data:
|
|
106
124
|
# Compile all regexes.
|
|
@@ -124,16 +142,30 @@ class TestCase:
|
|
|
124
142
|
|
|
125
143
|
setattr(self, field_id, field_data)
|
|
126
144
|
|
|
127
|
-
def
|
|
145
|
+
def run_cli_test(
|
|
146
|
+
self,
|
|
147
|
+
binary: str | Path,
|
|
148
|
+
additional_skip_platforms: _TNestedReferences | None,
|
|
149
|
+
default_timeout: float | None,
|
|
150
|
+
):
|
|
128
151
|
"""Run a CLI command and check its output against the test case.
|
|
129
152
|
|
|
130
153
|
..todo::
|
|
131
154
|
Add support for environment variables.
|
|
132
155
|
|
|
133
156
|
..todo::
|
|
134
|
-
Add support for proper mixed stdout
|
|
157
|
+
Add support for proper mixed <stdout>/<stderr> stream as a single,
|
|
135
158
|
intertwined output.
|
|
136
159
|
"""
|
|
160
|
+
if self.only_platforms:
|
|
161
|
+
if current_os() not in self.only_platforms: # type: ignore[operator]
|
|
162
|
+
raise SkippedTest(f"Test case only runs on platform: {current_os()}")
|
|
163
|
+
|
|
164
|
+
if current_os() in Group._extract_platforms(
|
|
165
|
+
self.skip_platforms, additional_skip_platforms
|
|
166
|
+
):
|
|
167
|
+
raise SkippedTest(f"Skipping test case on platform: {current_os()}")
|
|
168
|
+
|
|
137
169
|
if self.timeout is None and default_timeout is not None:
|
|
138
170
|
logging.info(f"Set default test case timeout to {default_timeout} seconds")
|
|
139
171
|
self.timeout = default_timeout
|
|
@@ -176,7 +208,8 @@ class TestCase:
|
|
|
176
208
|
f"CLI timed out after {self.timeout} seconds: {' '.join(clean_args)}"
|
|
177
209
|
)
|
|
178
210
|
|
|
179
|
-
|
|
211
|
+
for line in render_cli_run(clean_args, result).splitlines():
|
|
212
|
+
logging.info(line)
|
|
180
213
|
|
|
181
214
|
for field_id, field_data in asdict(self).items():
|
|
182
215
|
if field_id == "exit_code":
|
|
@@ -211,55 +244,50 @@ class TestCase:
|
|
|
211
244
|
name = "<stderr>"
|
|
212
245
|
|
|
213
246
|
if self.strip_ansi:
|
|
214
|
-
logging.info(f"Strip ANSI
|
|
247
|
+
logging.info(f"Strip ANSI sequences from {name}")
|
|
215
248
|
output = strip_ansi(output)
|
|
216
249
|
|
|
217
250
|
if field_id.endswith("_contains"):
|
|
218
251
|
for sub_string in field_data:
|
|
219
|
-
logging.info(f"Check if
|
|
252
|
+
logging.info(f"Check if {name} contains {sub_string!r}")
|
|
220
253
|
if sub_string not in output:
|
|
221
|
-
raise AssertionError(
|
|
222
|
-
f"CLI's {name} does not contain {sub_string!r}"
|
|
223
|
-
)
|
|
254
|
+
raise AssertionError(f"{name} does not contain {sub_string!r}")
|
|
224
255
|
|
|
225
256
|
elif field_id.endswith("_regex_matches"):
|
|
226
257
|
for regex in field_data:
|
|
227
|
-
logging.info(f"Check if
|
|
258
|
+
logging.info(f"Check if {name} matches {sub_string!r}")
|
|
228
259
|
if not regex.search(output):
|
|
229
|
-
raise AssertionError(
|
|
230
|
-
f"CLI's {name} does not match regex {regex}"
|
|
231
|
-
)
|
|
260
|
+
raise AssertionError(f"{name} does not match regex {regex}")
|
|
232
261
|
|
|
233
262
|
elif field_id.endswith("_regex_fullmatch"):
|
|
234
263
|
regex = field_data
|
|
235
264
|
if not regex.fullmatch(output):
|
|
236
|
-
raise AssertionError(
|
|
237
|
-
f"CLI's {name} does not fully match regex {regex}"
|
|
238
|
-
)
|
|
239
|
-
|
|
240
|
-
logging.info("All tests passed for CLI.")
|
|
265
|
+
raise AssertionError(f"{name} does not fully match regex {regex}")
|
|
241
266
|
|
|
242
267
|
|
|
243
|
-
DEFAULT_TEST_PLAN =
|
|
268
|
+
DEFAULT_TEST_PLAN: list[CLITestCase] = [
|
|
244
269
|
# Output the version of the CLI.
|
|
245
|
-
|
|
270
|
+
CLITestCase(cli_parameters="--version"),
|
|
246
271
|
# Test combination of version and verbosity.
|
|
247
|
-
|
|
272
|
+
CLITestCase(cli_parameters=("--verbosity", "DEBUG", "--version")),
|
|
248
273
|
# Test help output.
|
|
249
|
-
|
|
250
|
-
|
|
274
|
+
CLITestCase(cli_parameters="--help"),
|
|
275
|
+
]
|
|
276
|
+
|
|
251
277
|
|
|
278
|
+
def parse_test_plan(plan_string: str | None) -> Generator[CLITestCase, None, None]:
|
|
279
|
+
if not plan_string:
|
|
280
|
+
raise ValueError("Empty test plan")
|
|
252
281
|
|
|
253
|
-
|
|
254
|
-
plan = yaml.full_load(plan_path.read_text(encoding="UTF-8"))
|
|
282
|
+
plan = yaml.full_load(plan_string)
|
|
255
283
|
|
|
256
284
|
# Validates test plan structure.
|
|
257
285
|
if not plan:
|
|
258
|
-
raise ValueError(
|
|
286
|
+
raise ValueError("Empty test plan")
|
|
259
287
|
if not isinstance(plan, list):
|
|
260
288
|
raise ValueError(f"Test plan is not a list: {plan}")
|
|
261
289
|
|
|
262
|
-
directives = frozenset(
|
|
290
|
+
directives = frozenset(CLITestCase.__dataclass_fields__.keys())
|
|
263
291
|
|
|
264
292
|
for index, test_case in enumerate(plan):
|
|
265
293
|
# Validates test case structure.
|
|
@@ -271,4 +299,4 @@ def parse_test_plan(plan_path: Path) -> Generator[TestCase, None, None]:
|
|
|
271
299
|
f"{set(test_case) - directives}"
|
|
272
300
|
)
|
|
273
301
|
|
|
274
|
-
yield
|
|
302
|
+
yield CLITestCase(**test_case)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: gha-utils
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.15.1
|
|
4
4
|
Summary: ⚙️ CLI helpers for GitHub Actions + reuseable workflows
|
|
5
5
|
Author-email: Kevin Deldycke <kevin@deldycke.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/kdeldycke/workflows
|
|
@@ -19,7 +19,6 @@ Classifier: Operating System :: MacOS :: MacOS X
|
|
|
19
19
|
Classifier: Operating System :: Microsoft :: Windows
|
|
20
20
|
Classifier: Operating System :: POSIX :: Linux
|
|
21
21
|
Classifier: Programming Language :: Python :: 3
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
23
22
|
Classifier: Programming Language :: Python :: 3.11
|
|
24
23
|
Classifier: Programming Language :: Python :: 3.12
|
|
25
24
|
Classifier: Programming Language :: Python :: 3.13
|
|
@@ -43,17 +42,16 @@ Classifier: Topic :: Text Processing :: Markup :: HTML
|
|
|
43
42
|
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
|
44
43
|
Classifier: Topic :: Utilities
|
|
45
44
|
Classifier: Typing :: Typed
|
|
46
|
-
Requires-Python: >=3.
|
|
45
|
+
Requires-Python: >=3.11
|
|
47
46
|
Description-Content-Type: text/markdown
|
|
48
|
-
Requires-Dist: backports.strenum~=1.3.1; python_version < "3.11"
|
|
49
47
|
Requires-Dist: boltons>=24.0.0
|
|
50
|
-
Requires-Dist: bump-my-version>=0.
|
|
51
|
-
Requires-Dist: click-extra~=4.
|
|
48
|
+
Requires-Dist: bump-my-version>=0.32.2
|
|
49
|
+
Requires-Dist: click-extra~=4.15.0
|
|
50
|
+
Requires-Dist: extra-platforms~=3.1.0
|
|
52
51
|
Requires-Dist: packaging~=24.1
|
|
53
52
|
Requires-Dist: PyDriller~=2.6
|
|
54
53
|
Requires-Dist: pyproject-metadata~=0.9.0
|
|
55
54
|
Requires-Dist: pyyaml~=6.0.0
|
|
56
|
-
Requires-Dist: tomli~=2.0.1; python_version < "3.11"
|
|
57
55
|
Requires-Dist: wcmatch>=8.5
|
|
58
56
|
Provides-Extra: test
|
|
59
57
|
Requires-Dist: coverage[toml]~=7.6.0; extra == "test"
|
|
@@ -137,7 +135,7 @@ $ uvx gha-utils --version
|
|
|
137
135
|
gha-utils, version 4.9.0
|
|
138
136
|
```
|
|
139
137
|
|
|
140
|
-
That's the best way to get started with `gha-utils
|
|
138
|
+
That's the best way to get started with `gha-utils` and experiment with it.
|
|
141
139
|
|
|
142
140
|
### Executables
|
|
143
141
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
gha_utils/__init__.py,sha256=U6S-lf9LBMc4aLqIpN6_b_EWdcO7WqZcG6kCvWeyioI,866
|
|
2
|
+
gha_utils/__main__.py,sha256=Dck9BjpLXmIRS83k0mghAMcYVYiMiFLltQdfRuMSP_Q,1703
|
|
3
|
+
gha_utils/changelog.py,sha256=JR7iQrWjLoIOpVNe6iXQSyEii82_hM_zrYpR7QO_Uxo,5777
|
|
4
|
+
gha_utils/cli.py,sha256=rE9sjDj4iFqzyj8PwwSt8JkDSgULltm9qvUgXOqGtT4,12858
|
|
5
|
+
gha_utils/mailmap.py,sha256=naUqJYJnE3fLTjju1nd6WMm7ODiSaI2SHuJxRtmaFWs,6269
|
|
6
|
+
gha_utils/matrix.py,sha256=_afJD0K-xZLNxwykVnUhD0Gj9cdO0Z43g3VHa-q_tkI,11941
|
|
7
|
+
gha_utils/metadata.py,sha256=AbiEdWjcJfUaVwlhV31J-HXJldZgFB0OKS2fHJ60FXU,48282
|
|
8
|
+
gha_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
gha_utils/test_plan.py,sha256=57qwIaYfOLbyVKA5X4wldAKePxfvclK7lut--If2fSA,13149
|
|
10
|
+
gha_utils-4.15.1.dist-info/METADATA,sha256=6qHGLG5o_rE-wJgiPiBvlCdmFgzqR68UrByB2cjOnVk,20372
|
|
11
|
+
gha_utils-4.15.1.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
|
12
|
+
gha_utils-4.15.1.dist-info/entry_points.txt,sha256=8bJOwQYf9ZqsLhBR6gUCzvwLNI9f8tiiBrJ3AR0EK4o,54
|
|
13
|
+
gha_utils-4.15.1.dist-info/top_level.txt,sha256=C94Blb61YkkyPBwCdM3J_JPDjWH0lnKa5nGZeZ5M6yE,10
|
|
14
|
+
gha_utils-4.15.1.dist-info/RECORD,,
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
gha_utils/__init__.py,sha256=dR8lNlVY_u847eZ0CTxmll40WHAkfXzWXN26hheu824,866
|
|
2
|
-
gha_utils/__main__.py,sha256=Dck9BjpLXmIRS83k0mghAMcYVYiMiFLltQdfRuMSP_Q,1703
|
|
3
|
-
gha_utils/changelog.py,sha256=oahY88A9FRV14f1JSFKIiYrN_TS7Jo3QlljXqJbeuaE,5892
|
|
4
|
-
gha_utils/cli.py,sha256=Gq2pGpIOmvXtsexmg6nwN2ZuZ1lpHrJ5A43CeuDjK68,10985
|
|
5
|
-
gha_utils/mailmap.py,sha256=naUqJYJnE3fLTjju1nd6WMm7ODiSaI2SHuJxRtmaFWs,6269
|
|
6
|
-
gha_utils/matrix.py,sha256=_afJD0K-xZLNxwykVnUhD0Gj9cdO0Z43g3VHa-q_tkI,11941
|
|
7
|
-
gha_utils/metadata.py,sha256=Oumkmo4-O549hxlw8zaTWIPkITpUxUjpulj_MXn6fjA,48649
|
|
8
|
-
gha_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
gha_utils/test_plan.py,sha256=B6EiiGWVTrNS7jSIO9EE0kebccx10Fn0ZPapJTOOyGA,11928
|
|
10
|
-
gha_utils-4.14.2.dist-info/METADATA,sha256=uPoJ9lj1TvWEt1Izsipp-4R6bsQ-gwHjnqwILdpL0fQ,20514
|
|
11
|
-
gha_utils-4.14.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
12
|
-
gha_utils-4.14.2.dist-info/entry_points.txt,sha256=8bJOwQYf9ZqsLhBR6gUCzvwLNI9f8tiiBrJ3AR0EK4o,54
|
|
13
|
-
gha_utils-4.14.2.dist-info/top_level.txt,sha256=C94Blb61YkkyPBwCdM3J_JPDjWH0lnKa5nGZeZ5M6yE,10
|
|
14
|
-
gha_utils-4.14.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|