Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(IDX): remove branch protections check #377

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/custom_python_actions/check_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import github3

from compliance_checks import (
BranchProtection,
ComplianceCheckHelper,
CodeOwners,
License,
Expand Down Expand Up @@ -32,7 +31,6 @@ def main() -> None:

checks_passed = True
for compliance_check in [
BranchProtection(),
CodeOwners(),
License(),
Readme(),
Expand Down
13 changes: 0 additions & 13 deletions .github/custom_python_actions/compliance_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,6 @@ def check(self, helper: ComplianceCheckHelper) -> None:
but must have either write or maintain permissions. Team {team_name} has {role}.""" # noqa: E501


@dataclass
class BranchProtection(ComplianceCheck):
name: str = "branch_protection"
succeeds: bool = False
message: Optional[str] = None

def check(self, helper: ComplianceCheckHelper):
repo = helper.repo
branch = repo.branch(repo.default_branch)

self.succeeds = branch.protected


@dataclass
class License(ComplianceCheck):
name: str = "license"
Expand Down
32 changes: 0 additions & 32 deletions .github/tests/test_compliance_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from github3.exceptions import NotFoundError

from custom_python_actions.compliance_checks import (
BranchProtection,
CodeOwners,
ComplianceCheckHelper,
get_code_owners,
Expand Down Expand Up @@ -158,37 +157,6 @@ def test_check_code_owners_fails_other_error():
assert code_owners_check.message == "Raised error: some other error"


def test_branch_protection_enabled():
helper = mock.Mock()
repo = mock.Mock()
repo.default_branch = "main"
branch = mock.Mock()
branch.protected = True
helper.repo.branch.return_value = branch
branch_protection_check = BranchProtection()

branch_protection_check.check(helper)

assert repo.branch.called_with("main")
assert branch_protection_check.name == "branch_protection"
assert branch_protection_check.succeeds == True


def test_branch_protection_disabled():
helper = mock.Mock()
repo = mock.Mock()
repo.default_branch = "main"
branch = mock.Mock()
branch.protected = False
helper.repo.branch.return_value = branch
branch_protection_check = BranchProtection()

branch_protection_check.check(helper)

assert repo.branch.called_with("main")
assert branch_protection_check.succeeds == False


def test_check_license_exists():
repo = mock.Mock()
repo.license.return_value = "license"
Expand Down
Loading