Skip to content

Commit

Permalink
Bundle and catalogs are mutually exclusive
Browse files Browse the repository at this point in the history
The pipeline refuse RPs with mix of bundle and catalog changes.

JIRA: ISV-4639
Signed-off-by: Ales Raszka <[email protected]>
  • Loading branch information
Allda committed Jun 7, 2024
1 parent bf9c9f1 commit e02cd8a
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ def _validate_result(result: dict[str, list[str]]) -> None:
message += f"The PR deletes existing bundles: {sorted(deleted_bundles)}\n"
if len(added_bundles := result.get("added_bundles", [])) > 1:
message += f"The PR affects more than one bundle: {sorted(added_bundles)}\n"
if len(
affected_catalog_operators := result.get("affected_catalog_operators", [])
) > 0 and (len(affected_bundles := result.get("affected_bundles", [])) > 0):
message += (
f"The PR affects a bundle ({affected_bundles}) and catalog"
f"({affected_catalog_operators}) at the same time. Split operator and "
"catalog changes into 2 separate pull requests.\n"
)

catalog_operators = sorted(
list(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,20 +569,109 @@ def test_github_pr_affected_files_invalid_url(
pytest.param(
{
"extra_files": ["empty.txt", "operators/empty.txt"],
"affected_operators": [],
"modified_bundles": [],
"deleted_bundles": [],
"added_bundles": [],
"affected_catalog_operators": [],
},
False,
"The PR affects non-operator files: ['empty.txt', 'operators/empty.txt']\n",
id="Extra files",
),
pytest.param(
{
"extra_files": [],
"affected_operators": ["operator-e2e", "operator-clone-e2e"],
"modified_bundles": [],
"deleted_bundles": [],
"added_bundles": [],
"affected_catalog_operators": [],
},
False,
"The PR affects more than one operator: ['operator-clone-e2e', 'operator-e2e']\n",
id="Multiple operators",
),
pytest.param(
{
"extra_files": [],
"affected_operators": [],
"modified_bundles": ["operator-e2e/0.0.101"],
"deleted_bundles": [],
"added_bundles": [],
"affected_catalog_operators": [],
},
False,
"The PR modifies existing bundles: ['operator-e2e/0.0.101']\n",
id="Modified bundles",
),
pytest.param(
{
"extra_files": [],
"affected_operators": [],
"modified_bundles": [],
"deleted_bundles": ["operator-clone-e2e/0.0.100"],
"added_bundles": [],
"affected_catalog_operators": [],
},
False,
"The PR deletes existing bundles: ['operator-clone-e2e/0.0.100']\n",
id="Deleted bundles",
),
pytest.param(
{
"extra_files": [],
"affected_operators": [],
"modified_bundles": [],
"deleted_bundles": [],
"added_bundles": ["operator-e2e/0.0.101", "operator-clone-e2e/0.0.100"],
"affected_catalog_operators": [],
},
False,
"The PR affects more than one bundle: ['operator-clone-e2e/0.0.100', 'operator-e2e/0.0.101']\n",
id="Multiple bundles",
),
pytest.param(
{
"extra_files": [],
"affected_operators": [],
"modified_bundles": [],
"deleted_bundles": [],
"added_bundles": [],
"affected_catalog_operators": ["v4.15/operator-1", "v4.15/operator-2"],
},
False,
"The PR affects non-operator files: ['empty.txt', 'operators/empty.txt']\n"
"The PR affects more than one operator: ['operator-clone-e2e', 'operator-e2e']\n"
"The PR modifies existing bundles: ['operator-e2e/0.0.101']\n"
"The PR deletes existing bundles: ['operator-clone-e2e/0.0.100']\n"
"The PR affects more than one bundle: ['operator-clone-e2e/0.0.100', 'operator-e2e/0.0.101']\n"
"The PR affects more than one catalog operator: ['operator-1', 'operator-2']",
id="Invalid changes detected",
id="Multiple catalog operators",
),
pytest.param(
{
"extra_files": ["empty.txt", "operators/empty.txt"],
"affected_operators": ["operator-e2e", "operator-clone-e2e"],
"modified_bundles": [],
"deleted_bundles": [],
"added_bundles": [],
"affected_catalog_operators": [],
},
False,
"The PR affects non-operator files: ['empty.txt', 'operators/empty.txt']\n"
"The PR affects more than one operator: ['operator-clone-e2e', 'operator-e2e']\n",
id="Multiple issues",
),
pytest.param(
{
"extra_files": [],
"affected_operators": ["operator-e2e"],
"modified_bundles": [],
"deleted_bundles": [],
"affected_bundles": ["operator-e2e/0.0.101"],
"added_bundles": [],
"affected_catalog_operators": ["v4.15/operator-e2e"],
},
False,
"The PR affects a bundle (['operator-e2e/0.0.101']) and catalog(['v4.15/operator-e2e']) "
"at the same time. Split operator and catalog changes into 2 separate pull requests.\n",
id="Operator and catalog changes are mixed",
),
pytest.param(
{
Expand All @@ -591,11 +680,24 @@ def test_github_pr_affected_files_invalid_url(
"modified_bundles": [],
"deleted_bundles": [],
"added_bundles": ["operator-e2e/0.0.101"],
"affected_catalog_operators": ["v4.15/operator-1", "v4.16/operator-1"],
"affected_catalog_operators": [],
},
True,
None,
id="Add bundle",
),
pytest.param(
{
"extra_files": [],
"affected_operators": [],
"modified_bundles": [],
"deleted_bundles": [],
"added_bundles": [],
"affected_catalog_operators": ["v4.15/operator-e2e"],
},
True,
None,
id="Valid result",
id="Add operator catalog",
),
],
)
Expand Down

0 comments on commit e02cd8a

Please sign in to comment.