22
33from click .testing import CliRunner , Result
44from ruamel .yaml import YAML as Yaml
5+ from semver .version import Version
56
7+ from ci_starter .action import Action
68from ci_starter .cli import cli
79from ci_starter .constants import GITHUB_WORKFLOWS_DIR
8- from ci_starter .dataclasses import CommitVersion , OwnerRepo
910from ci_starter .utils import get_actions
1011from tests .e2e .constants import SUCCESSFUL_RETURN_CODE
1112
@@ -18,34 +19,59 @@ def test_update_action(cli_runner: CliRunner, test_project_path_str, step_parser
1819
1920 workflows = Path (test_project_path_str , GITHUB_WORKFLOWS_DIR ).rglob ("*.yml" )
2021
21- expected_actions : dict [OwnerRepo , CommitVersion ] = {}
22+ expected_actions : dict [str , Action ] = {}
2223
2324 # adding keys and values to expected_actions is managed by scripts/update-test_update_actions.sh
24- expected_actions [OwnerRepo ("actions" , "checkout" )] = CommitVersion (
25- "08c6903cd8c0fde910a37f88322edcfb5dd907a8" , "5.0.0"
25+ expected_actions ["actions/checkout" ] = Action (
26+ owner = "actions" ,
27+ repo = "checkout" ,
28+ commit = "08c6903cd8c0fde910a37f88322edcfb5dd907a8" ,
29+ version = Version .parse ("5.0.0" ),
2630 )
27- expected_actions [OwnerRepo ("actions" , "download-artifact" )] = CommitVersion (
28- "634f93cb2916e3fdff6788551b99b062d0335ce0" , "5.0.0"
31+ expected_actions ["actions/download-artifact" ] = Action (
32+ owner = "actions" ,
33+ repo = "download-artifact" ,
34+ commit = "634f93cb2916e3fdff6788551b99b062d0335ce0" ,
35+ version = Version .parse ("5.0.0" ),
2936 )
30- expected_actions [OwnerRepo ("actions" , "setup-python" )] = CommitVersion (
31- "e797f83bcb11b83ae66e0230d6156d7c80228e7c" , "6.0.0"
37+ expected_actions ["actions/setup-python" ] = Action (
38+ owner = "actions" ,
39+ repo = "setup-python" ,
40+ commit = "e797f83bcb11b83ae66e0230d6156d7c80228e7c" ,
41+ version = Version .parse ("6.0.0" ),
3242 )
33- expected_actions [OwnerRepo ("actions" , "upload-artifact" )] = CommitVersion (
34- "ea165f8d65b6e75b540449e92b4886f43607fa02" , "4.6.2"
43+ expected_actions ["actions/upload-artifact" ] = Action (
44+ owner = "actions" ,
45+ repo = "upload-artifact" ,
46+ commit = "ea165f8d65b6e75b540449e92b4886f43607fa02" ,
47+ version = Version .parse ("4.6.2" ),
3548 )
36- expected_actions [OwnerRepo ("astral-sh" , "ruff-action" )] = CommitVersion (
37- "57714a7c8a2e59f32539362ba31877a1957dded1" , "3.5.1"
49+ expected_actions ["astral-sh/ruff-action" ] = Action (
50+ owner = "astral-sh" ,
51+ repo = "ruff-action" ,
52+ commit = "57714a7c8a2e59f32539362ba31877a1957dded1" ,
53+ version = Version .parse ("3.5.1" ),
3854 )
39- expected_actions [OwnerRepo ("astral-sh" , "setup-uv" )] = CommitVersion (
40- "eb1897b8dc4b5d5bfe39a428a8f2304605e0983c" , "7.0.0"
55+ expected_actions ["astral-sh/setup-uv" ] = Action (
56+ owner = "astral-sh" ,
57+ repo = "setup-uv" ,
58+ commit = "eb1897b8dc4b5d5bfe39a428a8f2304605e0983c" ,
59+ version = Version .parse ("7.0.0" ),
4160 )
42- expected_actions [OwnerRepo ("pypa" , "gh-action-pypi-publish" )] = CommitVersion (
43- "ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e" , "1.13.0"
61+ expected_actions ["pypa/gh-action-pypi-publish" ] = Action (
62+ owner = "pypa" ,
63+ repo = "gh-action-pypi-publish" ,
64+ commit = "ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e" ,
65+ version = Version .parse ("1.13.0" ),
4466 )
4567
4668 for file in workflows :
4769 data = step_parser .load (file )
4870 for action in get_actions (data ):
49- actual_commit_and_version = CommitVersion (action .commit , str (action .version ))
50- expected_commit_and_version = expected_actions [OwnerRepo (action .owner , action .repo )]
51- assert actual_commit_and_version == expected_commit_and_version
71+ actual_commit = action .commit
72+ actual_version = action .version
73+ expected_commit = expected_actions [action .name ].commit
74+ expected_version = expected_actions [action .name ].version
75+
76+ assert actual_commit == expected_commit
77+ assert actual_version == expected_version
0 commit comments