Skip to content

Commit 5d0c8e7

Browse files
committed
Avoid adding go-fips test to empty packages
1 parent 0b581ee commit 5d0c8e7

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

pre_commit_hooks/check_for_go_fips_test.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@ def check_go_fips_compliance(melange_cfg: dict[str, Any]) -> tuple[bool, list[st
4242
# Check main test section
4343
test_section = melange_cfg.get("test", {})
4444
test_pipelines = test_section.get("pipeline", [])
45+
main_has_emptypackage_test = False
4546
for step in test_pipelines:
4647
if step.get("uses") == "test/go-fips-check":
4748
main_has_test = True
48-
break
49+
elif step.get("uses") == "test/emptypackage":
50+
main_has_emptypackage_test = True
4951

50-
if main_uses_fips and not main_has_test:
52+
# If main package has emptypackage test, it doesn't need go-fips test
53+
if main_uses_fips and not main_has_test and not main_has_emptypackage_test:
5154
issues.append("main package uses go-fips but lacks test/go-fips-check")
5255

5356
# Check each subpackage
@@ -68,12 +71,15 @@ def check_go_fips_compliance(melange_cfg: dict[str, Any]) -> tuple[bool, list[st
6871
# Check subpackage test sections
6972
subpkg_test_section = subpkg.get("test", {})
7073
subpkg_test_pipelines = subpkg_test_section.get("pipeline", [])
74+
subpkg_has_emptypackage_test = False
7175
for step in subpkg_test_pipelines:
7276
if step.get("uses") == "test/go-fips-check":
7377
subpkg_has_test = True
74-
break
78+
elif step.get("uses") == "test/emptypackage":
79+
subpkg_has_emptypackage_test = True
7580

76-
if subpkg_uses_fips and not subpkg_has_test:
81+
# If subpackage has emptypackage test, it doesn't need go-fips test
82+
if subpkg_uses_fips and not subpkg_has_test and not subpkg_has_emptypackage_test:
7783
issues.append(
7884
f"subpackage '{subpkg_name}' uses go-fips but lacks test/go-fips-check",
7985
)

0 commit comments

Comments
 (0)