[go: nahoru, domu]

Skip to content

Commit

Permalink
Switch from opt_in to opt_out
Browse files Browse the repository at this point in the history
  • Loading branch information
silv-io committed Jun 25, 2024
1 parent ceb3983 commit 12e1a82
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 90 deletions.
85 changes: 0 additions & 85 deletions localstack-core/localstack/testing/testselection/opt_in.py

This file was deleted.

18 changes: 18 additions & 0 deletions localstack-core/localstack/testing/testselection/opt_out.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import fnmatch
from typing import Iterable

OPT_OUT = []


def opted_out(changed_files: list[str], opt_out: Iterable[str] | None = None) -> bool:
"""
Do not perform test selection if at least one file is opted out
:param changed_files: List of changed file paths
:param opt_out: Iterable of globs to match the changed files against. Defaults to the rules defined in OPT_OUT
:return: True if any changed file matches at least one glob, False otherwise
"""
if opt_out is None:
opt_out = OPT_OUT

return any(any(fnmatch.fnmatch(cf, glob) for glob in opt_out) for cf in changed_files)
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
get_pr_details_from_url,
)
from localstack.testing.testselection.matching import MatchingRule
from localstack.testing.testselection.opt_in import complies_with_opt_in
from localstack.testing.testselection.opt_out import opted_out
from localstack.testing.testselection.testselection import get_affected_tests_from_changes


def generate_test_selection(
opt_in_rules: Iterable[str] | None = None,
opt_out: Iterable[str] | None = None,
matching_rules: list[MatchingRule] | None = None,
repo_name: str = "localstack",
):
Expand Down Expand Up @@ -87,11 +87,10 @@ def generate_test_selection(
repo_root_path, merge_base_commit, head_commit_sha
)

# opt-in guard, can be removed after initial testing phase
print("Checking for confirming to opt-in guards")
if not complies_with_opt_in(changed_files, opt_in_rules=opt_in_rules):
if opted_out(changed_files, opt_out=opt_out):
print(
f"Change outside of opt-in guards. Extend the list at {repo_name}/testing/testselection/opt_in.py"
f"Explicitly opted out changed file. Remove from {repo_name}/testing/testselection/opt_out.py if needed"
)
test_files = ["SENTINEL_ALL_TESTS"]
else:
Expand Down

0 comments on commit 12e1a82

Please sign in to comment.