4
4
5
5
from pathlib import Path
6
6
import re
7
- import pytest
8
7
from typing import List , Optional
9
8
9
+ import pytest
10
10
11
11
README_CANDIDATES = [
12
12
Path ("README.md" ),
@@ -57,8 +57,7 @@ def test_top_badges_present(readme_text: str) -> None:
57
57
t ,
58
58
), "GitHub release (latest SemVer) badge should be present"
59
59
assert re .search (
60
- r"https://img\.shields\.io/static/v1\?label=Used%20by&message=\d+&color=informational" ,
61
- t ,
60
+ r"https://img\.shields\.io/static/v1\?label=Used%20by&message=\d+&color=informational" , t
62
61
), "'Used by' shields.io badge should be present (do not assert specific count)"
63
62
assert "https://img.shields.io/badge/Marketplace-commit--check--action-blue" in t , "Marketplace badge should be present"
64
63
assert re .search (r"slsa\.dev/images/gh-badge-level3\.svg\?color=blue" , t ), "SLSA level 3 badge should be present"
@@ -75,7 +74,9 @@ def test_table_of_contents_has_expected_links(readme_text: str) -> None:
75
74
]
76
75
for anchor in anchors :
77
76
slug = anchor .lower ().replace (" " , "-" )
78
- assert re .search (rf"^\* \[{ re .escape (anchor )} \]\(#{ re .escape (slug )} \)\s*$" , readme_text , flags = re .MULTILINE ), f"TOC entry for { anchor } should exist"
77
+ assert re .search (
78
+ rf"^\* \[{ re .escape (anchor )} \]\(#{ re .escape (slug )} \)\s*$" , readme_text , flags = re .MULTILINE
79
+ ), f"TOC entry for { anchor } should exist"
79
80
80
81
81
82
def test_usage_yaml_block_contains_required_items (readme_text : str ) -> None :
@@ -104,7 +105,9 @@ def test_usage_yaml_block_contains_required_items(readme_text: str) -> None:
104
105
105
106
# Validate GitHub expressions patterns
106
107
assert re .search (r"\$\{\{\s*github\.event\.pull_request\.head\.sha\s*\}\}" , y ), "PR head SHA expression must be present"
107
- assert re .search (r"\$\{\{\s*github\.event_name\s*==\s*['\"]pull_request['\"]\s*\}\}" , y ), "Conditional pr-comments expression must be present"
108
+ assert re .search (
109
+ r"\$\{\{\s*github\.event_name\s*==\s*['\"]pull_request['\"]\s*\}\}" , y
110
+ ), "Conditional pr-comments expression must be present"
108
111
109
112
110
113
def test_commit_check_action_inputs_in_usage_block (readme_text : str ) -> None :
@@ -212,7 +215,10 @@ def test_workflow_badge_consistency(readme_text: str) -> None:
212
215
# Top badge and badging section should reference the same workflow path
213
216
t = readme_text
214
217
# Extract all commit-check workflow badge URLs
215
- urls = re .findall (r"https://github\.com/commit-check/commit-check-action/actions/workflows/commit-check\.yml(?:/badge\.svg)?" , t )
218
+ urls = re .findall (
219
+ r"https://github\.com/commit-check/commit-check-action/actions/workflows/commit-check\.yml(?:/badge\.svg)?" ,
220
+ t ,
221
+ )
216
222
assert urls , "Expected workflow badge/link URLs"
217
223
# Ensure both base workflow URL and badge.svg appear
218
224
assert any (u .endswith ("badge.svg" ) for u in urls ) or "actions/workflows/commit-check.yml/badge.svg" in t , "badge.svg URL should be present"
0 commit comments