Skip to content

Commit e02cd8a

Browse files
committed
Bundle and catalogs are mutually exclusive
The pipeline refuse RPs with mix of bundle and catalog changes. JIRA: ISV-4639 Signed-off-by: Ales Raszka <[email protected]>
1 parent bf9c9f1 commit e02cd8a

File tree

2 files changed

+118
-8
lines changed

2 files changed

+118
-8
lines changed

operator-pipeline-images/operatorcert/entrypoints/detect_changed_operators.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,14 @@ def _validate_result(result: dict[str, list[str]]) -> None:
260260
message += f"The PR deletes existing bundles: {sorted(deleted_bundles)}\n"
261261
if len(added_bundles := result.get("added_bundles", [])) > 1:
262262
message += f"The PR affects more than one bundle: {sorted(added_bundles)}\n"
263+
if len(
264+
affected_catalog_operators := result.get("affected_catalog_operators", [])
265+
) > 0 and (len(affected_bundles := result.get("affected_bundles", [])) > 0):
266+
message += (
267+
f"The PR affects a bundle ({affected_bundles}) and catalog"
268+
f"({affected_catalog_operators}) at the same time. Split operator and "
269+
"catalog changes into 2 separate pull requests.\n"
270+
)
263271

264272
catalog_operators = sorted(
265273
list(

operator-pipeline-images/tests/entrypoints/test_detect_changed_operators.py

Lines changed: 110 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -569,20 +569,109 @@ def test_github_pr_affected_files_invalid_url(
569569
pytest.param(
570570
{
571571
"extra_files": ["empty.txt", "operators/empty.txt"],
572+
"affected_operators": [],
573+
"modified_bundles": [],
574+
"deleted_bundles": [],
575+
"added_bundles": [],
576+
"affected_catalog_operators": [],
577+
},
578+
False,
579+
"The PR affects non-operator files: ['empty.txt', 'operators/empty.txt']\n",
580+
id="Extra files",
581+
),
582+
pytest.param(
583+
{
584+
"extra_files": [],
572585
"affected_operators": ["operator-e2e", "operator-clone-e2e"],
586+
"modified_bundles": [],
587+
"deleted_bundles": [],
588+
"added_bundles": [],
589+
"affected_catalog_operators": [],
590+
},
591+
False,
592+
"The PR affects more than one operator: ['operator-clone-e2e', 'operator-e2e']\n",
593+
id="Multiple operators",
594+
),
595+
pytest.param(
596+
{
597+
"extra_files": [],
598+
"affected_operators": [],
573599
"modified_bundles": ["operator-e2e/0.0.101"],
600+
"deleted_bundles": [],
601+
"added_bundles": [],
602+
"affected_catalog_operators": [],
603+
},
604+
False,
605+
"The PR modifies existing bundles: ['operator-e2e/0.0.101']\n",
606+
id="Modified bundles",
607+
),
608+
pytest.param(
609+
{
610+
"extra_files": [],
611+
"affected_operators": [],
612+
"modified_bundles": [],
574613
"deleted_bundles": ["operator-clone-e2e/0.0.100"],
614+
"added_bundles": [],
615+
"affected_catalog_operators": [],
616+
},
617+
False,
618+
"The PR deletes existing bundles: ['operator-clone-e2e/0.0.100']\n",
619+
id="Deleted bundles",
620+
),
621+
pytest.param(
622+
{
623+
"extra_files": [],
624+
"affected_operators": [],
625+
"modified_bundles": [],
626+
"deleted_bundles": [],
575627
"added_bundles": ["operator-e2e/0.0.101", "operator-clone-e2e/0.0.100"],
628+
"affected_catalog_operators": [],
629+
},
630+
False,
631+
"The PR affects more than one bundle: ['operator-clone-e2e/0.0.100', 'operator-e2e/0.0.101']\n",
632+
id="Multiple bundles",
633+
),
634+
pytest.param(
635+
{
636+
"extra_files": [],
637+
"affected_operators": [],
638+
"modified_bundles": [],
639+
"deleted_bundles": [],
640+
"added_bundles": [],
576641
"affected_catalog_operators": ["v4.15/operator-1", "v4.15/operator-2"],
577642
},
578643
False,
579-
"The PR affects non-operator files: ['empty.txt', 'operators/empty.txt']\n"
580-
"The PR affects more than one operator: ['operator-clone-e2e', 'operator-e2e']\n"
581-
"The PR modifies existing bundles: ['operator-e2e/0.0.101']\n"
582-
"The PR deletes existing bundles: ['operator-clone-e2e/0.0.100']\n"
583-
"The PR affects more than one bundle: ['operator-clone-e2e/0.0.100', 'operator-e2e/0.0.101']\n"
584644
"The PR affects more than one catalog operator: ['operator-1', 'operator-2']",
585-
id="Invalid changes detected",
645+
id="Multiple catalog operators",
646+
),
647+
pytest.param(
648+
{
649+
"extra_files": ["empty.txt", "operators/empty.txt"],
650+
"affected_operators": ["operator-e2e", "operator-clone-e2e"],
651+
"modified_bundles": [],
652+
"deleted_bundles": [],
653+
"added_bundles": [],
654+
"affected_catalog_operators": [],
655+
},
656+
False,
657+
"The PR affects non-operator files: ['empty.txt', 'operators/empty.txt']\n"
658+
"The PR affects more than one operator: ['operator-clone-e2e', 'operator-e2e']\n",
659+
id="Multiple issues",
660+
),
661+
pytest.param(
662+
{
663+
"extra_files": [],
664+
"affected_operators": ["operator-e2e"],
665+
"modified_bundles": [],
666+
"deleted_bundles": [],
667+
"affected_bundles": ["operator-e2e/0.0.101"],
668+
"added_bundles": [],
669+
"affected_catalog_operators": ["v4.15/operator-e2e"],
670+
},
671+
False,
672+
"The PR affects a bundle (['operator-e2e/0.0.101']) and catalog(['v4.15/operator-e2e']) "
673+
"at the same time. Split operator and catalog changes into 2 separate pull requests.\n",
674+
id="Operator and catalog changes are mixed",
586675
),
587676
pytest.param(
588677
{
@@ -591,11 +680,24 @@ def test_github_pr_affected_files_invalid_url(
591680
"modified_bundles": [],
592681
"deleted_bundles": [],
593682
"added_bundles": ["operator-e2e/0.0.101"],
594-
"affected_catalog_operators": ["v4.15/operator-1", "v4.16/operator-1"],
683+
"affected_catalog_operators": [],
684+
},
685+
True,
686+
None,
687+
id="Add bundle",
688+
),
689+
pytest.param(
690+
{
691+
"extra_files": [],
692+
"affected_operators": [],
693+
"modified_bundles": [],
694+
"deleted_bundles": [],
695+
"added_bundles": [],
696+
"affected_catalog_operators": ["v4.15/operator-e2e"],
595697
},
596698
True,
597699
None,
598-
id="Valid result",
700+
id="Add operator catalog",
599701
),
600702
],
601703
)

0 commit comments

Comments
 (0)