Skip to content

Commit

Permalink
chore(IDX): remove branch protections check (#377)
Browse files Browse the repository at this point in the history
* chore(IDX): remove branch protections check

* Update check_compliance.py

* Update test_compliance_checks.py
  • Loading branch information
cgundy authored Nov 25, 2024
1 parent 2954f22 commit 3fc82f2
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 47 deletions.
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

0 comments on commit 3fc82f2

Please sign in to comment.